| 400 | Provider ID is invalid. | The X-Scrubs-Clinic-Provider header does not map to a known organisation. |
| 401 | API key authentication failed. | The API key or provider header is missing, or the supplied API key is invalid for the provider. |
| 500 | Unexpected server failure. | Repository, database, or service errors while reading or mutating API key data. |
| 403 | Root API key is required for list_all=true. | A non-root key can retrieve only its own key metadata. |
1https://usescrubs.com



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'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}| 400 | Request body is invalid. | clinic_id and friendly_name are required. usage_limit must be numeric when provided. |
| 400 | Provider ID is invalid. | The X-Scrubs-Clinic-Provider header does not map to a known organisation. |
| 401 | API key authentication failed. | The API key or provider header is missing, or the supplied API key is invalid for the provider. |
| 500 | Unexpected server failure. | Repository, database, or service errors while reading or mutating API key data. |
| 403 | Root API key is required. | The authenticated key is valid but does not have root-level permission for this operation. |
| 409 | Clinic already has an API key. | A key already exists for the requested clinic_id in this organisation. |
| 500 | API key creation failed. | The key service did not return a new secret or an unexpected persistence error occurred. |
1https://usescrubs.com



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}'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}| 400 | Request body is invalid. | id is required. friendly_name and usage_limit are optional, but usage_limit must be numeric when provided. |
| 400 | Provider ID is invalid. | The X-Scrubs-Clinic-Provider header does not map to a known organisation. |
| 401 | API key authentication failed. | The API key or provider header is missing, or the supplied API key is invalid for the provider. |
| 500 | Unexpected server failure. | Repository, database, or service errors while reading or mutating API key data. |
| 403 | Root API key is required. | The authenticated key is valid but does not have root-level permission for this operation. |
| 403 | Cannot update another root key. | Root keys can update themselves and subkeys, but cannot update a different root key. |
| 404 | API key was not found. | The id in the request body does not match an API key. |
1https://usescrubs.com



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}'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}| 400 | API key ID is missing. | The id query parameter is required. |
| 400 | Provider ID is invalid. | The X-Scrubs-Clinic-Provider header does not map to a known organisation. |
| 401 | API key authentication failed. | The API key or provider header is missing, or the supplied API key is invalid for the provider. |
| 500 | Unexpected server failure. | Repository, database, or service errors while reading or mutating API key data. |
| 403 | Root API key is required. | The authenticated key is valid but does not have root-level permission for this operation. |
| 404 | API key was not found. | The id query parameter does not match an existing API key. |
1https://usescrubs.com



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'1{
2 "message": "API key deleted successfully"
3}