Skip to content

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).

422 validation_failed
{
  "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."
    }
  ]
}
Problem fields
FieldDescription
typeA link to the documentation of this problem, on this page.
titleA short summary for humans. It may be reworded; do not parse it.
statusThe HTTP status code, repeated for convenience.
codeThe machine-readable error code. Branch on this.
detailAn explanation of this particular occurrence, for logs and developers.
request_idIdentifies the request. Log it, and quote it when you contact us.
errorsField-level errors, each with field and message. Present only for validation_failed.
error_codeWhy the session failed. Present only for session_failed.

Problems contain no transcript or result text, so they are safe to log in full.

Handling a problem
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:

Request format errors
StatusCodeCause
400malformed_requestThe body is not valid JSON.
413payload_too_largeThe body is larger than 1 MiB (1,048,576 bytes).
415unsupported_media_typeThe 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

Error codes
StatusCodeMeaningWhat to do
400malformed_requestThe request body is not valid JSON.Send a well-formed JSON body.
401unauthorizedThe API key is missing, malformed or revoked.Check the Authorization header and that the key has not been revoked.
401invalid_upload_tokenThe 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.
403insufficient_scopeThe key does not carry the scope the endpoint requires.Use a key with the required scope.
404not_foundNo such session in your organization.Check the id, and that you are using the key of the organization and environment that created it.
404result_not_readyThe session is created or still processing.Wait for the session.completed webhook, then fetch again.
409external_ref_conflictThe external_ref was already used with a different language or mode.Use a new external_ref, or repeat the original parameters.
409transcript_already_acceptedA 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.
409session_closedThe 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.
409session_failedProcessing failed for good. The problem carries error_code.Stop waiting for a result. Create a new session to try again.
409session_expiredNo transcript was accepted before upload_expires_at.Create a new session.
410deletedThe 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.
410purgedThe 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.
413payload_too_largeThe request body is larger than 1 MiB (1,048,576 bytes).Send a smaller body.
415unsupported_media_typeThe request body is not application/json.Set Content-Type: application/json.
422validation_failedThe body or a parameter is invalid. errors[] names each field.Fix the fields listed in errors[].
422language_not_enabledThe language is not enabled for your organization.Use an enabled language, or ask us to enable it.
422mode_not_availableThe mode is not enabled for your organization.Ask us to enable the product for your organization.
422wrong_modeThe endpoint does not match the session mode.Use /transcript for intake sessions and /ambient-note for ambient sessions.
422transcript_too_shortThe joined transcript is shorter than 10 characters.Do not submit empty calls. Let the session expire or delete it.
422transcript_too_longThe joined transcript is longer than 50,000 characters.Submit a shorter conversation.
422cursor_mismatchThe cursor was issued for different filters or a different interval.Restart paging without after, keeping the filters constant.
429rate_limitedThe key is over its rate limit.Wait for the number of seconds in Retry-After, then retry.
500internal_errorAn unexpected failure on our side.Retry with backoff. Quote the request_id if it persists.
502voice_provider_unavailableVoice 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.

Session error codes
CodeMeaning
pipeline_errorProcessing failed with an unrecoverable error.
pipeline_timeoutProcessing did not finish within its time limit.
input_too_largeThe transcript was too large to process.
attempts_exhaustedProcessing was attempted three times without success.
Failed session
{
  "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:

Idempotency of writes
OperationWhy a retry is safe
POST /sessionsThe same external_ref returns the same session.
POST /sessions/{id}/transcript and /ambient-noteWith 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, 502 and other 5xx responses, with exponential backoff and jitter. For 429, wait for Retry-After first.
  • Do not retry other 4xx responses 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.