Skip to Content

Errors

One envelope for every failure, and a retry strategy you can write once.

Every API failure uses a JSON error object, including endpoints whose successful response is audio, CSV, PDF, or PCAP. Branch on its stable code and keep the request_id when you need support.

{
  "error": {
    "code": "validation_failed",
    "message": "request failed validation",
    "request_id": "9f2c1a4b-...",
    "details": {
      "fields": [
        {
          "path": "members[0].phone_number_id",
          "code": "not_found",
          "message": "phone number is not active or not visible"
        }
      ]
    }
  }
}
FieldContract
codeStable machine token. Branch on this, never on message text.
messageHuman-readable; wording may improve without notice.
request_idMatches X-Request-Id; quote it in support reports.
detailsOptional structured context; the shape depends on the code.

For validation_failed, details.fields lists every failing field as {path, code, message} — fix all of them before retrying.

The complete code list, with per-code retry guidance, is the error-code catalog. It also ships machine-readable — every operation's OpenAPI entry has an x-sonus-error-codes map (status → exhaustive code list), joined to the top-level x-sonus-error-catalog (allowed statuses, retry class, details contract per code) — and agents and CLIs should branch on those, not prose.

Status codes at a glance

HTTPMeansTypical codes
400Request could not be interpretedinvalid_json, unknown_query_parameter, idempotency_key_required
401Credential rejectedunauthorized
403Authenticated but not allowedforbidden, entitlement_required
404Missing, cross-workspace, or outside the public boundary*_not_found, operation_not_available
408Body didn't arrive in timerequest_timeout
409Current state or duplicate intent blocks itresource conflicts, idempotency_*
410Metadata exists, binary is gonerecording_blob_missing, turn_audio_expired
412Your If-Match is staleprecondition_failed
413 / 415 / 416Body too large / wrong media type / bad Rangerequest_too_large, unsupported_media_type, invalid_range
422Parsed fine, violates field rulesvalidation_failed
429Too many requestsrate_limited, authentication_rate_limited
5xxServer, provider, or dependency failureinternal_error, provider_request_failed, *_unavailable, *_outcome_unknown

Retry strategy

Three rules cover most of it:

  1. 4xx (except 408/409/429): fix something first. Credentials, input, or precondition — retrying unchanged cannot succeed. A 410 artifact must be regenerated, not re-downloaded.
  2. 429 and 503: wait and retry the same request. Honor Retry-After. For 503 authentication_unavailable, retry the same credential — it was not judged invalid.
  3. Other 5xx and ambiguous transport failures: retry only under protection. Re-send the exact bytes with the same Idempotency-Key (POST) or rely on natural idempotency (GET/PUT/DELETE). Exponential backoff with jitter, bounded attempts. Never invent a new intent to "recover" an ambiguous one.

The 409 idempotency_* family (in progress, conflict, context changed, result lost) has precise per-code handling in Idempotency.

Fine print

On this page