Platform
Errors
Problem responses, every error code and how to handle it, and which requests are safe to retry.
The API uses conventional HTTP status codes and describes every error as a problem document. Each problem has a stable code; write your error handling against that, not against the status or the text.
Problem format
Errors are returned as application/problem+json (RFC 9457).
{
"type": "https://aimedintake.com/docs/errors#validation_failed",
"title": "Request failed validation",
"status": 422,
"code": "validation_failed",
"detail": "One or more fields are invalid.",
"request_id": "req_01JDKD2P5H",
"errors": [
{
"field": "external_ref",
"message": "Must match ^[A-Za-z0-9._:-]+$ and be 1 to 128 characters."
}
]
}| Field | Description |
|---|---|
type | A link to the documentation of this problem, on this page. |
title | A short summary for humans. It may be reworded; do not parse it. |
status | The HTTP status code, repeated for convenience. |
code | The machine-readable error code. Branch on this. |
detail | An explanation of this particular occurrence, for logs and developers. |
request_id | Identifies the request. Log it, and quote it when you contact us. |
errors | Field-level errors, each with field and message. Present only for validation_failed. |
error_code | Why the session failed. Present only for session_failed. |
Problems contain no transcript or result text, so they are safe to log in full.
const response = await fetch(url, options);
if (!response.ok) {
// application/problem+json; a 5xx from the network edge may not be JSON
const problem = await response.json().catch(() => ({ code: 'http_' + response.status }));
switch (problem.code) {
case 'rate_limited':
return retryAfter(Number(response.headers.get('Retry-After')));
case 'result_not_ready':
return waitForWebhook();
case 'validation_failed':
throw new ValidationError(problem.errors);
default:
throw new ApiError(problem.code, problem.request_id);
}
}Request format errors
Three errors are about the request itself and are raised before any field is validated:
| Status | Code | Cause |
|---|---|---|
| 400 | malformed_request | The body is not valid JSON. |
| 413 | payload_too_large | The body is larger than 1 MiB (1,048,576 bytes). |
| 415 | unsupported_media_type | The body was not sent as application/json. |
A 5xx response normally carries the problem internal_error. If a failure happens before the API can answer, the body may not be a problem document or JSON at all, so read the status first and parse the body defensively.
Error codes
| Status | Code | Meaning | What to do |
|---|---|---|---|
| 400 | malformed_request | The request body is not valid JSON. | Send a well-formed JSON body. |
| 401 | unauthorized | The API key is missing, malformed or revoked. | Check the Authorization header and that the key has not been revoked. |
| 401 | invalid_upload_token | The upload token is expired, already used or bound to another session. | Do not retry with the token. Have your server send the exact same body with your secret key, whatever the session status, and branch on the answer: 202 confirms this body; 409 transcript_already_accepted means a different transcript was accepted; 409 session_closed means no further upload is possible and prior receipt is unknown. |
| 403 | insufficient_scope | The key does not carry the scope the endpoint requires. | Use a key with the required scope. |
| 404 | not_found | No such session in your organization. | Check the id, and that you are using the key of the organization and environment that created it. |
| 404 | result_not_ready | The session is created or still processing. | Wait for the session.completed webhook, then fetch again. |
| 409 | external_ref_conflict | The external_ref was already used with a different language or mode. | Use a new external_ref, or repeat the original parameters. |
| 409 | transcript_already_accepted | A different transcript was already accepted for the session. | This body was not accepted and will not be. Tell staff: two different transcripts exist for one session. |
| 409 | session_closed | The session accepts no further upload: it was deleted, or upload_expires_at passed before a transcript was accepted. | No further upload is possible. Prior receipt is unknown: a deleted session may already have had its transcript. Do not resubmit automatically; tell staff. |
| 409 | session_failed | Processing failed for good. The problem carries error_code. | Stop waiting for a result. Create a new session to try again. |
| 409 | session_expired | No transcript was accepted before upload_expires_at. | Create a new session. |
| 410 | deleted | The clinical data was erased from the API at your request. | Mark the result as unavailable from the API. Handle your own copy through your erasure process. |
| 410 | purged | The API deleted the clinical data at the end of its retention period. | Mark the result as unavailable from the API. This does not ask you to delete your own records. |
| 413 | payload_too_large | The request body is larger than 1 MiB (1,048,576 bytes). | Send a smaller body. |
| 415 | unsupported_media_type | The request body is not application/json. | Set Content-Type: application/json. |
| 422 | validation_failed | The body or a parameter is invalid. errors[] names each field. | Fix the fields listed in errors[]. |
| 422 | language_not_enabled | The language is not enabled for your organization. | Use an enabled language, or ask us to enable it. |
| 422 | mode_not_available | The mode is not enabled for your organization. | Ask us to enable the product for your organization. |
| 422 | wrong_mode | The endpoint does not match the session mode. | Use /transcript for intake sessions and /ambient-note for ambient sessions. |
| 422 | transcript_too_short | The joined transcript is shorter than 10 characters. | Do not submit empty calls. Let the session expire or delete it. |
| 422 | transcript_too_long | The joined transcript is longer than 50,000 characters. | Submit a shorter conversation. |
| 422 | cursor_mismatch | The cursor was issued for different filters or a different interval. | Restart paging without after, keeping the filters constant. |
| 429 | rate_limited | The key is over its rate limit. | Wait for the number of seconds in Retry-After, then retry. |
| 500 | internal_error | An unexpected failure on our side. | Retry with backoff. Quote the request_id if it persists. |
| 502 | voice_provider_unavailable | Voice credentials could not be issued. | Retry the same request with backoff. |
New codes may be added over time. Handle an unknown code by its status class: treat 4xx as a request you must change and 5xx as a failure you may retry.
Session error codes
A session that reaches failed records why in error.code. The same value appears as error_code in the session.failed event and in the session_failed problem.
| Code | Meaning |
|---|---|
pipeline_error | Processing failed with an unrecoverable error. |
pipeline_timeout | Processing did not finish within its time limit. |
input_too_large | The transcript was too large to process. |
attempts_exhausted | Processing was attempted three times without success. |
{
"id": "ses_01JDK9W5RT",
"object": "session",
"external_ref": "visit-000479",
"status": "failed",
"mode": "intake",
"language": "es",
"device_type": "mobile",
"tags": {},
"created_at": "2027-01-12T11:40:00Z",
"upload_expires_at": "2027-01-13T11:40:00Z",
"accepted_at": "2027-01-12T11:52:18Z",
"completed_at": null,
"updated_at": "2027-01-12T12:01:44Z",
"purge_at": "2027-02-11T11:52:18Z",
"end_reason": "disconnected",
"error": {
"code": "pipeline_timeout"
},
"deleted": null
}A failed session is final. Processing is attempted up to three times before a session fails, so there is nothing to gain from waiting. To try again, create a new session with a new external_ref and submit the transcript to it.
Retrying safely
The write operations are idempotent, so a retry after a timeout or a dropped connection cannot duplicate work:
| Operation | Why a retry is safe |
|---|---|
POST /sessions | The same external_ref returns the same session. |
POST /sessions/{id}/transcript and /ambient-note | With a secret key, the same body returns the original 202 and starts no second job, unless the session has been deleted: then a valid secret-key replay returns 409 session_closed while the tombstone exists (90 days), and 404 not_found after that. With the upload token, a repeat returns 401 invalid_upload_token at authentication, deleted session or not, because acceptance consumed the token: replay from your server instead. See When an upload is uncertain. |
DELETE /sessions/{id} | Deleting a deleted session returns the same body. |
- Retry network errors, timeouts,
429,502and other5xxresponses, with exponential backoff and jitter. For429, wait forRetry-Afterfirst. - Do not retry other
4xxresponses unchanged. They will fail the same way until the request, the key or the session changes. - Do not loop on
result_not_ready. Wait for the webhook instead.