Errors

Every Direct API error code, what it means, and whether to retry, including what to do after a paid call fails with a 5xx.

Every error has the same body. Branch on the HTTP status and code; show description or error.message to people.

{
  "description": "Human-readable explanation, safe to log.",
  "code": "machine_readable_code",
  "data": { "request_id": "…", "…": "…" },
  "error": { "error_code": "…", "message": "…" }
}

Every response, success or error, carries X-Request-Id. Include it when you contact support.

Error codes

HTTPcodeMeaningRetry
400invalid_requestmalformed JSON, an unknown body field, or input fails the tool's schema (each bad field is named)no, fix the request
401invalid_api_keymissing, malformed, revoked or expired keyno
402insufficient_creditsthe organization cannot pay for the callafter a top-up
402api_key_credit_limit_reachedthe call would exceed the key's daily, monthly or total limit (data.period says which)after the window resets or the limit is raised
402subscription_pausedthe organization's subscription is pausedafter it is resumed
402payment_requiredthe organization's subscription is past dueafter the payment is completed
403direct_api_disabledthe Direct API is not enabled for this organizationno, contact Morphic
403insufficient_scopethe key lacks the scope this tool needs (data.required_scopes)no, use another key
403plan_upgrade_requiredthe model or feature is not on your planno
403tool_not_availablethe tool charges credits and paid tools are not switched on for your organization yet (data.tool names it); your Morphic contact switches them onno
403model_disabled_by_organizationan org admin switched this model, resolution or audio option off and has not allowed it for the APIno, ask your admin
404not_foundunknown tool, generation or webhook, or one outside this key's reachno
409idempotency_conflictIdempotency-Key reused with a different body or toolno, use a new key
409idempotency_in_progressthe original request with this key is still runningyes, after a second
409idempotency_outcome_unknownthe original request with this Idempotency-Key failed or never answered after it may have run, so its outcome is unknownno: check its result, then use a new key
413payload_too_largebody over 1 MBno
422tool_refusedthe input is well formed but cannot run; nothing was chargedno, change the input
429rate_limiteda rate limit was hityes, after Retry-After
500internal_errorour faulta free call, yes; a paid call, see below
503service_unavailabletemporary overload or maintenancea free call, yes, with backoff; a paid call, see below
504tool_timed_outthe tool did not answer within 60 s; a call that starts generations may still have started thema free call, yes; a paid call, see below

A 422 tool_refused names the field, the value and the values that would have worked; see Tool refusals. A generation that fails after it started reports its own error.error_code on the generation object, and its charge is refunded.

A paid call that answers 500, 503 or 504 may have started work and charged for it before it failed. Retrying it with the same Idempotency-Key never runs it twice: the retry answers 409 idempotency_outcome_unknown.

  1. Check what the call did: list_generations, or GET /v1/direct/usage filtered by time.
  2. Send a new Idempotency-Key only for work that did not start.

When no answer arrived at all (a dropped connection), retry with the same key. You get the stored answer, or 409 idempotency_in_progress while it still runs. See Idempotency.


If you have any trouble or have any questions, feel free to reach out. We're happy to help. Write to us at support@morphic.com.

On this page