Developers

Errors

Every error has one shape. Branch on type and code; show message to developers only.

The envelope#

{
  "error": {
    "type": "invalid_request_error",
    "code": "parameter_invalid",
    "message": "limit must be a whole number from 1 to 100.",
    "param": "limit",
    "request_id": "GON6k_hAgBsHUEMAAGhx"
  }
}
FieldMeaning
typeThe class of problem. One of six, below. Treat an unknown type as api_error.
codeThe specific problem. Stable once published.
messageFor the developer. Wording may change, and follows the region's spelling. Never parse it.
paramThe parameter or header at fault, or null. For wrong_region, the base URL to use instead.
request_idAlso in the x-request-id header. Quote it when you contact us.

Types and codes#

StatustypecodeWhat to do
401authentication_errorinvalid_credentialThe key or token is missing, wrong, revoked or rotated. Get a new one.
401authentication_errorapi_key_wrong_modeA test key on a live clinic, or a live key on the sandbox.
401authentication_errormachine_credential_requiredA signed-in session was sent. Use a key or OAuth token.
403permission_errorinsufficient_scopeAsk the clinic for a credential with the scope.
403permission_errorroute_not_allowedThis endpoint is not open to credentials.
403permission_errorno_clinic_accessThe credential reaches no clinic, for example after its person left.
403permission_errorpatients_not_visibleThe person the credential acts as cannot see all the clinic's patients.
400invalid_request_errorparameter_invalidFix the parameter named in param.
400invalid_request_errorparameter_unsupportedThis list does not take that parameter, such as updated_since on clinics.
400invalid_request_errorclinic_requiredSend Claro-Clinic. See Choosing a clinic.
400invalid_request_errorparameter_missingSend the required parameter named in param, such as subscription on GET /events.
400invalid_request_errorevent_type_not_subscribedA type on GET /events that the subscription does not take.
400invalid_request_erroridempotency_key_invalidThe key must be 1 to 255 characters.
404invalid_request_errorresource_missingNo such object, or not one this credential reaches.
404invalid_request_errorroute_not_foundNo such endpoint, whatever the method. Check the path against the reference.
405invalid_request_errormethod_not_allowedThe path exists, but not with this method. The Allow header lists the ones it takes.
421invalid_request_errorwrong_regionThe API key belongs to the other region. param is the base URL to use. See Regions.
409idempotency_erroridempotency_key_reusedThe key was used for a different request. Use a new key.
409idempotency_erroridempotency_key_in_progressThe first request is still running. Retry after Retry-After.
429rate_limit_errorrate_limitedWait Retry-After seconds. See Rate limits.
500api_errorvariesOur problem. Retry with backoff, and quote request_id if it persists.

New codes can be added within a type. Handle an unknown code by its type.

Not found means not yours, too#

A record at a clinic your credential does not reach is a 404, exactly like one that does not exist. The API never confirms that someone else's record exists.

Retrying#

  • Retry 429, 409 idempotency_key_in_progress and 5xx, with exponential backoff and jitter.
  • Do not retry other 4xx errors unchanged. They fail the same way again.
  • When writes arrive, retry a POST with the same Idempotency-Key.