Guides
Authentication and keys
Secret keys, scopes, single-use upload tokens, test and live environments, and key rotation.
Every request is authenticated with a bearer credential in the Authorization header. There are two kinds: secret keys, which identify your organization and stay on your server, and upload tokens, which let one device submit one transcript.
Secret keys
curl https://api.aimedintake.com/v1/sessions \
-H "Authorization: Bearer $AIMEDINTAKE_API_KEY"- Keys begin with
sk_live_orsk_test_and are 256 bits of random data. - A key is shown once, when it is issued. We store only a SHA-256 hash of it and cannot show it again.
- A key belongs to one organization. Every request it makes is confined to that organization’s data.
- Keys are issued, scoped, rotated and revoked through your AI Medical Intake contact. Request keys.
Scopes
Each key carries one or more scopes. A request with a key that lacks the required scope is rejected with 403 insufficient_scope.
| Scope | Allows | Typical holder |
|---|---|---|
sessions:write | Create sessions, submit transcripts, delete sessions. | The service that starts calls. |
records:read | Read sessions, list sessions and read results, including clinical content. | The service that stores results or feeds a dashboard. |
usage:read | Read usage records. No clinical content. | Finance and reconciliation jobs. |
Issue separate keys for separate services. A kiosk backend that only starts calls does not need records:read, and a billing job needs only usage:read.
Upload tokens
Creating a session returns an upload_token beginning with upl_. It lets the device that ran the call submit the transcript itself, without your secret key and without a round trip through your server.
- It is bound to one session and to one operation: submitting that session’s transcript.
- It is single use. Once a transcript is accepted the token is consumed, and any further request with it returns
401 invalid_upload_token, even a repeat of the same body. A device that did not see the response must not retry with the token; see When an upload is uncertain. - It expires at the session’s
upload_expires_at, 24 hours after creation by default. - Calling
POST /sessionsagain for the same reference issues a fresh token and revokes the previous one, but only while the session is stillcreated. The deadline is not extended. - It cannot read anything. Results are available only to a secret key with
records:read.
curl https://api.aimedintake.com/v1/sessions/ses_01JDK8Z3Q4/transcript \
-H "Authorization: Bearer upl_3kTq8ZxV1mN0pLr7EXAMPLE" \
-H "Content-Type: application/json" \
-d @transcript.jsonTo upload directly from a browser, the page’s origin must be registered for your organization. Tell us the origins your interface is served from. For registered origins, the two upload routes (/transcript and /ambient-note) answer the CORS preflight for the Authorization and Content-Type headers and expose Retry-After to the page, so that browser code can honour a rate limit. No other route accepts cross-origin requests: everything else is called from your server.
Test and live
Test keys belong to a separate test organization. Test and live data never mix: a test key cannot see a live session, and the reverse.
| Test | Live | |
|---|---|---|
| Key prefix | sk_test_ | sk_live_ |
| Base URL | The same | The same |
| Data | Synthetic data only. Do not send real patient data. | Production data, governed by your agreement with us. |
| Webhooks | Its own endpoint and signing secret. | Its own endpoint and signing secret. |
| Billing | Never charged. Usage records show billable: false. | One usage record per completed session. Only records with billable: true are charged; see what is billable. |
Rotating and revoking keys
Rotate keys on a schedule and whenever someone with access leaves. Rotation does not need downtime:
- Ask for a new key with the same scopes. The old key keeps working.
- Deploy the new key to your services.
- Confirm the old key is no longer in use, then ask us to revoke it.
Once a key is revoked, the next request with it receives 401 unauthorized. The last use of each key is recorded, which helps confirm that an old key is idle.
If a key may have leaked, write to security@aimedintake.com and ask for it to be revoked; rotate afterwards. Identify the key by its prefix and last four characters, never by sending the key itself. We acknowledge the request when we receive it and confirm separately when the key has been revoked. Until that confirmation, the key still works.
Webhook signing secrets rotate the same way; see Webhooks.
Authentication errors
| Status | Code | Cause |
|---|---|---|
| 401 | unauthorized | The key is missing, malformed or revoked. |
| 401 | invalid_upload_token | The upload token is expired, already used or bound to another session. |
| 403 | insufficient_scope | The key is valid but lacks the scope the endpoint requires. |
{
"type": "https://aimedintake.com/docs/errors#insufficient_scope",
"title": "Key lacks the required scope",
"status": 403,
"code": "insufficient_scope",
"detail": "This key does not carry the scope this endpoint requires.",
"request_id": "req_01JDKD2C9M"
}