{
"error": {
"code": "brand_access_denied",
"message": "This API key has no access to this brand",
"request_id": "4f3c2e1a-9b7d-4c1e-8f2a-1d3e5b7c9a0f"
}
}
| Field | Meaning |
|---|---|
code | Stable. Compare it with a constant in your code. |
message | For a person. It can change at any time. |
request_id | Send it to support@genez.io. The support finds the request in the logs with it. |
details | Only with validation_error: one item for each field that is not valid. |
The error codes of the API
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request | The request names a thing that the brand does not hold, such as a topic of another brand. |
| 401 | unauthorized | The request has no key. |
| 401 | invalid_api_key | The key is wrong, expired or revoked. |
| 403 | insufficient_scope | The key reads only, and the request writes. |
| 403 | brand_access_denied | The key has no access to this brand. |
| 403 | forbidden | The key has no access to this thing, or the plan of the account does not include API access. |
| 403 | plan_limit_reached | The plan of the account holds no more of this thing, such as more scenarios. Nothing was written. |
| 404 | not_found | The thing, or the route, does not exist. |
| 409 | conflict | The thing already exists, or it is not in a state for this request, such as a restore of a scenario that is not deleted. |
| 409 | idempotency_in_progress | A request with the same Idempotency-Key did not finish yet. Send it again in a few seconds. |
| 422 | validation_error | A parameter is not valid. details names each one. |
| 422 | idempotency_key_reused | The Idempotency-Key came with another request. Use a new key for each new write. |
| 429 | rate_limited | The key sent too many requests. See Rate limits. |
| 500 | internal_error | An error of the API. Try again, and send request_id to the support if it continues. |
An example of a validation error
{
"error": {
"code": "validation_error",
"message": "The request has fields that are not valid.",
"request_id": "9147c93b-ca37-41a8-ac69-71706e03866d",
"details": [
{ "field": "page_size", "message": "Input should be less than or equal to 100" }
]
}
}
Handle the errors in your code
answer = requests.get(url, headers={"X-API-Key": key})
if answer.status_code >= 400:
error = answer.json()["error"]
if error["code"] == "rate_limited":
time.sleep(int(answer.headers["Retry-After"]))
elif error["code"] in ("unauthorized", "invalid_api_key"):
raise RuntimeError("Make a new API key.")
else:
raise RuntimeError(f"{error['code']}: {error['message']} ({error['request_id']})")