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
- typestringThe family of the error, one per HTTP status.
- codestringWhat went wrong exactly. See the codes below.
- messagestringA sentence that explains the error.
- paramstringThe parameter at fault, when there is one. Left out otherwise.
- request_idstringThe request's ID, the same as its
Request-Idheader. Send it to us when you need help. - doc_urlstringThis 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
| Status | Type | Meaning |
|---|---|---|
| 400 | invalid_request_error | The 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. |
| 401 | authentication_error | No key, or a wrong or revoked key. |
| 403 | permission_error | The key is valid but cannot do this, like a key with Read access that tries to change data. |
| 404 | not_found_error | No such object on the key's business, or no such route. |
| 429 | rate_limit_error | Too many requests. Wait for Retry-After seconds. |
| 500 | api_error | Something went wrong on Okaymate's side, or a 502 when Okaymate's router or the business's server did not answer. |
Error codes
| Code | Status | Meaning |
|---|---|---|
parameter_invalid | 400 | A 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_missing | 400 | A required parameter is missing. param names it. |
invalid_json | 400 | The body is not valid JSON. |
action_failed | 400 | The app refused the action or it failed. The message says why, as the app would. |
missing_api_key | 401 | The request has no Authorization or X-Api-Key header. |
invalid_api_key | 401 | No key matches. Check that you copied all of it, ok_live_ included. A revoked key answers the same. |
insufficient_scope | 403 | The key has Read access and the request changes data. Use a key with Read and write access. |
account_only | 403 | The 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_missing | 404 | No object with this ID on the key's business. An ID of another business answers the same. |
route_not_found | 404 | No endpoint at this path. |
action_not_found | 404 | No action with this name. GET /v1/actions lists them. |
method_not_allowed | 405 | This path does not take this method. The Allow header lists the ones it takes. |
agent_not_ready | 409 | The business's Okaymate server is not set up yet. Finish its setup in the app, then try again. |
rate_limit_exceeded | 429 | More than 120 requests in the minute with this key. Wait for Retry-After seconds. |
internal_error | 500 | An unexpected error on Okaymate's side. The request_id helps us find it. |
upstream_unavailable | 502 | Okaymate'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_readysucceeds once the business's Okaymate server is set up. Finish its setup in the app. - 429 succeeds after
Retry-Afterseconds. 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_idof every error, it lets us find the request in seconds.