Skip to content

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

Authenticated request
curl https://api.aimedintake.com/v1/sessions \
  -H "Authorization: Bearer $AIMEDINTAKE_API_KEY"
  • Keys begin with sk_live_ or sk_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.

Scopes
ScopeAllowsTypical holder
sessions:writeCreate sessions, submit transcripts, delete sessions.The service that starts calls.
records:readRead sessions, list sessions and read results, including clinical content.The service that stores results or feeds a dashboard.
usage:readRead 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 /sessions again for the same reference issues a fresh token and revokes the previous one, but only while the session is still created. The deadline is not extended.
  • It cannot read anything. Results are available only to a secret key with records:read.
Upload with a token
curl https://api.aimedintake.com/v1/sessions/ses_01JDK8Z3Q4/transcript \
  -H "Authorization: Bearer upl_3kTq8ZxV1mN0pLr7EXAMPLE" \
  -H "Content-Type: application/json" \
  -d @transcript.json

To 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 and live
TestLive
Key prefixsk_test_sk_live_
Base URLThe sameThe same
DataSynthetic data only. Do not send real patient data.Production data, governed by your agreement with us.
WebhooksIts own endpoint and signing secret.Its own endpoint and signing secret.
BillingNever 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:

  1. Ask for a new key with the same scopes. The old key keeps working.
  2. Deploy the new key to your services.
  3. 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

Authentication errors
StatusCodeCause
401unauthorizedThe key is missing, malformed or revoked.
401invalid_upload_tokenThe upload token is expired, already used or bound to another session.
403insufficient_scopeThe key is valid but lacks the scope the endpoint requires.
403 insufficient_scope
{
  "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"
}