Getting started

Errors

Okaymate answers with an HTTP status and a JSON error whose type and code never change, so your code can branch on them.

The error object

Every error has the same shape. message is for people and may change, type and code are for your code. Every response, error or not, also carries its Request-Id header.

Attributes

  • typestring
    The family of the error, one per HTTP status.
  • codestring
    What went wrong exactly. See the codes below.
  • messagestring
    A sentence that explains the error.
  • paramstring
    The parameter at fault, when there is one. Left out otherwise.
  • request_idstring
    The request's ID, the same as its Request-Id header. Send it to us when you need help.
  • doc_urlstring
    This page, at the code's entry.
Response400
{
  "error": {
    "type": "invalid_request_error",
    "code": "parameter_invalid",
    "message": "limit must be an integer from 1 to 100.",
    "param": "limit",
    "request_id": "req_7Hq2LmX9pT4vK1sN8bYc3dFe",
    "doc_url": "https://okaymate.ai/docs/errors#parameter_invalid"
  }
}

HTTP status codes

StatusTypeMeaning
400invalid_request_errorThe request has a missing or invalid parameter, or a body that is not JSON. A method the path does not take gets this type with a 405, a business whose server is not set up yet with a 409.
401authentication_errorNo key, or a wrong or revoked key.
403permission_errorThe key is valid but cannot do this, like a key with Read access that tries to change data.
404not_found_errorNo such object on the key's business, or no such route.
429rate_limit_errorToo many requests. Wait for Retry-After seconds.
500api_errorSomething went wrong on Okaymate's side, or a 502 when Okaymate's router or the business's server did not answer.

Error codes

CodeStatusMeaning
parameter_invalid400A parameter has a value the API does not accept, like a limit above 100 or a date that is not ISO 8601. param names it.
parameter_missing400A required parameter is missing. param names it.
invalid_json400The body is not valid JSON.
action_failed400The app refused the action or it failed. The message says why, as the app would.
missing_api_key401The request has no Authorization or X-Api-Key header.
invalid_api_key401No key matches. Check that you copied all of it, ok_live_ included. A revoked key answers the same.
insufficient_scope403The key has Read access and the request changes data. Use a key with Read and write access.
account_only403The action is a person's own account, their profile, plan, businesses, affiliate link or chats. It works only for someone signed in to Okaymate, never with a business's key.
resource_missing404No object with this ID on the key's business. An ID of another business answers the same.
route_not_found404No endpoint at this path.
action_not_found404No action with this name. GET /v1/actions lists them.
method_not_allowed405This path does not take this method. The Allow header lists the ones it takes.
agent_not_ready409The business's Okaymate server is not set up yet. Finish its setup in the app, then try again.
rate_limit_exceeded429More than 120 requests in the minute with this key. Wait for Retry-After seconds.
internal_error500An unexpected error on Okaymate's side. The request_id helps us find it.
upstream_unavailable502Okaymate's router or the business's server did not answer. Try again in a moment.

Handle errors

  • 400, 401, 403, 404 and 405 never succeed as they are. Fix the request before sending it again.
  • 409 with agent_not_ready succeeds once the business's Okaymate server is set up. Finish its setup in the app.
  • 429 succeeds after Retry-After seconds. See Rate limits.
  • 500 and 502 can be retried after a short wait. Before you send a message again, list the lead's messages to check the first one did not go through.
  • Log the request_id of every error, it lets us find the request in seconds.