API Key Management

GET /api/v1/api-keyRetrieves information about the authenticated API key. Use the list_all=true query parameter to list all API keys for the organization (requires a root API key).HEADER PARAMETERS
REQUIREDX-Scrubs-Clinic-Api-Keystring
Your API key for authentication.
REQUIREDX-Scrubs-Clinic-Providerstring
Provider ID associated with your EHR application.
QUERY PARAMETERS
OPTIONALlist_allstring
Optional. Set to "true" to list all API keys for the organization. Requires a root API key.
Error Codes4 cases
Common API key authentication errors
400Provider ID is invalid.The X-Scrubs-Clinic-Provider header does not map to a known organisation.
401API key authentication failed.The API key or provider header is missing, or the supplied API key is invalid for the provider.
500Unexpected server failure.Repository, database, or service errors while reading or mutating API key data.
List all validation
403Root API key is required for list_all=true.A non-root key can retrieve only its own key metadata.
Domain
BASE URL
1https://usescrubs.com
Sample Request
CURL
Node.JS
Python
Go
CURL
1curl --location --request GET 'https://usescrubs.com/api/v1/api-key' \
2--header 'X-Scrubs-Clinic-Api-Key: your_api_key_here' \
3--header 'X-Scrubs-Clinic-Provider: your_provider_id'
4
5# To list all API keys (requires root key):
6curl --location --request GET 'https://usescrubs.com/api/v1/api-key?list_all=true' \
7--header 'X-Scrubs-Clinic-Api-Key: your_root_api_key_here' \
8--header 'X-Scrubs-Clinic-Provider: your_provider_id'
Sample Response
JSON
1{
2  "id": "key_123456789",
3  "friendly_name": "Clinic Main API Key",
4  "created": "2024-01-15T10:30:00Z",
5  "clinic_id": "00A123",
6  "usage_limit": 1000,
7  "root": false
8}
POST /api/v1/api-keyCreates a new API key for a clinic. This endpoint requires a root API key and will automatically create an anonymous clinic if one doesn't exist for the specified clinic ID.HEADER PARAMETERS
REQUIREDX-Scrubs-Clinic-Api-Keystring
Your API key for authentication.
REQUIREDX-Scrubs-Clinic-Providerstring
Provider ID associated with your EHR application.
BODY PARAMETERS
REQUIREDclinic_idstring
The clinic identification code for the clinic that will use this API key.
REQUIREDfriendly_namestring
A human-readable name for the API key.
OPTIONALusage_limitnumber
Optional. The maximum number of API calls allowed. Defaults to 5 if not specified.
Error Codes7 cases
Request validation
400Request body is invalid.clinic_id and friendly_name are required. usage_limit must be numeric when provided.
Common API key authentication errors
400Provider ID is invalid.The X-Scrubs-Clinic-Provider header does not map to a known organisation.
401API key authentication failed.The API key or provider header is missing, or the supplied API key is invalid for the provider.
500Unexpected server failure.Repository, database, or service errors while reading or mutating API key data.
Root API key requirement
403Root API key is required.The authenticated key is valid but does not have root-level permission for this operation.
Creation validation
409Clinic already has an API key.A key already exists for the requested clinic_id in this organisation.
500API key creation failed.The key service did not return a new secret or an unexpected persistence error occurred.
Domain
BASE URL
1https://usescrubs.com
Sample Request
CURL
NodeJS
Python
Go
CURL
1curl --location --request POST 'https://usescrubs.com/api/v1/api-key' \
2--header 'X-Scrubs-Clinic-Api-Key: your_root_api_key_here' \
3--header 'X-Scrubs-Clinic-Provider: your_provider_id' \
4--header 'Content-Type: application/json' \
5--data '{
6  "clinic_id": "00A123",
7  "friendly_name": "New Clinic API Key",
8  "usage_limit": 100
9}'
Sample Response
JSON
1{
2  "apiKey": "sk_live_123456789abcdef",
3  "friendly_name": "New Clinic API Key",
4  "created": "2024-01-25T09:15:00Z",
5  "clinic_id": "00A123",
6  "usage_limit": 100,
7  "root": false
8}
PUT /api/v1/api-keyUpdates an existing API key. Root keys can update subkeys and themselves, but cannot update other root keys. Subkeys cannot update any keys.HEADER PARAMETERS
REQUIREDX-Scrubs-Clinic-Api-Keystring
Your API key for authentication.
REQUIREDX-Scrubs-Clinic-Providerstring
Provider ID associated with your EHR application.
BODY PARAMETERS
REQUIREDidstring
The ID of the API key to update.
OPTIONALfriendly_namestring
Optional. New friendly name for the API key.
OPTIONALusage_limitnumber
Optional. New usage limit for the API key.
Error Codes7 cases
Request validation
400Request body is invalid.id is required. friendly_name and usage_limit are optional, but usage_limit must be numeric when provided.
Common API key authentication errors
400Provider ID is invalid.The X-Scrubs-Clinic-Provider header does not map to a known organisation.
401API key authentication failed.The API key or provider header is missing, or the supplied API key is invalid for the provider.
500Unexpected server failure.Repository, database, or service errors while reading or mutating API key data.
Root API key requirement
403Root API key is required.The authenticated key is valid but does not have root-level permission for this operation.
Update validation
403Cannot update another root key.Root keys can update themselves and subkeys, but cannot update a different root key.
404API key was not found.The id in the request body does not match an API key.
Domain
BASE URL
1https://usescrubs.com
Sample Request
CURL
NodeJS
Python
Go
CURL
1curl --location --request PUT 'https://usescrubs.com/api/v1/api-key' \
2--header 'X-Scrubs-Clinic-Api-Key: your_root_api_key_here' \
3--header 'X-Scrubs-Clinic-Provider: your_provider_id' \
4--header 'Content-Type: application/json' \
5--data '{
6  "id": "key_123456789",
7  "friendly_name": "Updated Clinic API Key",
8  "usage_limit": 1500
9}'
Sample Response
JSON
1{
2  "id": "key_123456789",
3  "friendly_name": "Updated Clinic API Key",
4  "created": "2024-01-15T10:30:00Z",
5  "clinic_id": "00A123",
6  "usage_limit": 1500,
7  "root": false
8}
DELETE /api/v1/api-keyDeletes an API key. This endpoint requires a root API key and will permanently remove the specified API key.HEADER PARAMETERS
REQUIREDX-Scrubs-Clinic-Api-Keystring
Your API key for authentication.
REQUIREDX-Scrubs-Clinic-Providerstring
Provider ID associated with your EHR application.
QUERY PARAMETERS
REQUIREDidstring
The ID of the API key to delete.
Error Codes6 cases
Request validation
400API key ID is missing.The id query parameter is required.
Common API key authentication errors
400Provider ID is invalid.The X-Scrubs-Clinic-Provider header does not map to a known organisation.
401API key authentication failed.The API key or provider header is missing, or the supplied API key is invalid for the provider.
500Unexpected server failure.Repository, database, or service errors while reading or mutating API key data.
Root API key requirement
403Root API key is required.The authenticated key is valid but does not have root-level permission for this operation.
Deletion validation
404API key was not found.The id query parameter does not match an existing API key.
Domain
BASE URL
1https://usescrubs.com
Sample Request
CURL
NodeJS
Python
Go
CURL
1curl --location --request DELETE 'https://usescrubs.com/api/v1/api-key?id=key_123456789' \
2--header 'X-Scrubs-Clinic-Api-Key: your_root_api_key_here' \
3--header 'X-Scrubs-Clinic-Provider: your_provider_id'
Sample Response
JSON
1{
2  "message": "API key deleted successfully"
3}
Contact us: support@usescrubs.com