Using sub-organizations

Every organization has a default sub-organization. Until you've created your first extra sub-organization, the sub-organizations concept is not surfaced.

1. Create a sub-organization

Use the create sub-organization endpoint with your server API key to create a sub-organization.

Request example:

curl --request POST \
     --url https://api.nabla.com/v1/server/sub_organizations \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <YOUR_SERVER_API_KEY>' \
     --data '
{
     "display_name": "Sub Org 1"
}
'

2. Get the list of your sub-organizations

Use the get sub-organization endpoint with your server API key to get the list of your sub-organizations. You will see the default sub-organization.

Request example:

curl --request GET \
     --url https://api.nabla.com/v1/server/sub_organizations \
     --header 'Authorization: Bearer <YOUR_SERVER_API_KEY>'

Response example:

{
    "data": [
        {
            "id": "7f223388-5066-4b06-92d7-b9c687e9d91f",
            "display_name": "Default"
        },
        {
            "id": "e6cface4-2d70-4609-9436-cfc9f570fa26",
            "display_name": "Sub Org 1"
        }
    ],
    "has_more": false,
    "total_count": 2
}

3. Use the API to manage your sub-organization

You will have to use a new header in your API calls to manage your sub-organization: 'X-Nabla-SubOrganization-ID: <YOUR_SUBORG_ID>'. If you don't add this header, your API calls will target the default sub-organization.

Example to create a patient in your new sub-organization:

curl --request POST \
     --url https://api.nabla.com/v1/server/patients \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <YOUR_SERVER_API_KEY>' \
     --header 'X-Nabla-SubOrganization-ID: <YOUR_SUBORG_ID>' \
     --data '
{
     "first_name": "Lola",
     "last_name": "Rastaquere",
     "locale": "en",
     "email": "[email protected]",
     "date_of_birth": "1986-11-20",
     "sex": "FEMALE"
}
'

4. Use the seamless authentication to connect to the sub-organization Console

In order to automatically connect a provider to the sub-organization Console they belong to, you can use the seamless authentication guide. First, create a provider with the API and with the 'X-Nabla-SubOrganization-ID: <YOUR_SUBORG_ID>' header. Then retrieve the refresh_token via the API and with the same header. Finally, add the refresh_token to the URL of your organization Console.