Usage Analytics

POST /api/v1/usage-analyticsRetrieves usage analytics data for API keys within your organization. This endpoint requires a root API key and can provide analytics for all API keys in the organization or for a specific API key if api_key_id is provided.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
REQUIREDstart_datestring
Start date for the analytics period in YYYY-MM-DD format.
REQUIREDend_datestring
End date for the analytics period in YYYY-MM-DD format.
OPTIONALapi_key_idstring
Optional. Specific API key ID to get analytics for. If not provided, returns analytics for all API keys in the organization.
Error Codes7 cases
Request validation
400Request body is invalid.start_date and end_date are required in YYYY-MM-DD format. start_date must be before or equal to end_date.
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.
Target API key validation
403Target API key is outside the organisation.A requested api_key_id belongs to a different organisation than the authenticated root key.
404Target API key or clinic was not found.The requested api_key_id does not exist, or the key exists without a linked clinic record.
Domain
BASE URL
1https://usescrubs.com
Sample Request
CURL
Node.JS
Python
Go
CURL
1curl --location --request POST 'https://usescrubs.com/api/v1/usage-analytics' \
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  "start_date": "2024-01-01",
7  "end_date": "2024-01-31"
8}'
9
10# To query specific API key:
11curl --location --request POST 'https://usescrubs.com/api/v1/usage-analytics' \
12--header 'X-Scrubs-Clinic-Api-Key: your_root_api_key_here' \
13--header 'X-Scrubs-Clinic-Provider: your_provider_id' \
14--header 'Content-Type: application/json' \
15--data '{
16  "api_key_id": "key_uuid_here",
17  "start_date": "2024-01-01",
18  "end_date": "2024-01-31"
19}'
Sample Response
JSON
1{
2  "api_key": null,
3  "total": {
4    "stt_duration": 120,
5    "tokens": 5000000,
6    "usage": 150
7  },
8  "deltas": {
9    "2024-01-15": {
10      "tokens": 1000000,
11      "usage": 25,
12      "stt_duration": 30
13    },
14    "2024-01-16": {
15      "tokens": 800000,
16      "usage": 20,
17      "stt_duration": 25
18    }
19  }
20}
Contact us: support@usescrubs.com