Errors
A list of the error format returned when an API call fails, with causes and fixes for each status. The Content API and the media API use the same format. The Admin API uses a different format.
Content API
Section titled “Content API”The Content API (/api/v1/content/…) and the media API (/api/v1/media/…) return errors in the following format.
{ "error": { "code": "bad_request", "message": "title: is required", "details": { "issues": [{ "path": "title", "message": "is required" }] } }}| Item | Contents |
|---|---|
code |
A fixed name for each status. Use this when your program branches on errors |
message |
An English sentence for people to read. It may change, so do not compare it in your program |
details.issues |
Only when the input does not follow the rules. An array of path (where) and message (why) |
details.limit |
Only for limit_reached. The name and value of the limit |
| Status | code |
Cause | Fix |
|---|---|---|---|
400 |
bad_request |
Parameters, where, or the body do not follow the rules. An unknown parameter. A value that does not match the schema. The response exceeds 5 MB. A POST to a single |
message and details.issues show what is wrong. If the response is too large, reduce it with limit or select |
401 |
unauthorized |
The API key is missing, wrong, or revoked. The space in the path differs from the key’s space | Check that you put the key starting with hako_ as is after Authorization: Bearer . Check whether the key is revoked on the [API キー](API keys) screen |
403 |
forbidden |
The key does not have permission for the operation (this API key cannot create entries and so on). preview=true was added with a key without permission |
Check the key’s permissions on the [API キー] screen. For content types under [個別に設定](Set individually), only the individual permissions apply |
404 |
not_found |
The content type or entry does not exist. It is not published. An unknown path under /api/v1 |
Check that the content type ID in the URL matches [エンドポイント](Endpoint) and that the entry is [公開中](Published) |
405 |
method_not_allowed |
A method that cannot be used on that path | Check the method for the operation in the Content API reference |
409 |
conflict |
An ID or a value that must be unique collides with another. sys.version differs from the current revision. An operation not possible in the current state (no draft to discard, unpublishing something not published, deleting something referenced by others, and so on) |
If the revision differs, read the entry again before writing again |
409 |
limit_reached |
A usage limit has been reached (number of entries, total media size) | details.limit shows which limit. Delete what you do not need, or see Usage limits |
413 |
payload_too_large |
The uploaded file is too large | Make the file smaller |
414 |
uri_too_long |
The URL exceeds 8 KB | Shorten where or select |
415 |
unsupported_media_type |
A media upload is not multipart/form-data |
Send multipart/form-data with the file in the file part |
422 |
unprocessable_entity |
The body has the wrong shape (an unknown key and so on) | Check the key shown in message |
429 |
too_many_requests |
Too many requests | Wait a moment and send again |
500 |
internal |
An internal Hako CMS error | If it continues after some time, contact us with the date and time you sent the request and the URL |
For limit_reached, the following is returned.
{ "error": { "code": "limit_reached", "message": "this space has reached its limit of 100 entries; ask the server operator to raise it", "details": { "limit": { "name": "space.entries", "max": 100 } } }}A syntax error in where returns 400, and message shows which character position is wrong. Examples are in Filter, sort, and paginate. Rich text errors are in Rich text format.
Admin API
Section titled “Admin API”The Admin API (/admin/api/…) returns errors in the following format.
{ "message": "slug already exists" }When the input does not follow the rules, issues is also included. message is issues joined with ; .
{ "message": "fields.id: fieldId is reserved; fields.n: min must not exceed max", "issues": [ { "path": "fields.id", "message": "fieldId is reserved" }, { "path": "fields.n", "message": "min must not exceed max" } ]}Some operations include other items too (such as violationCount, the number of entries that do not match in a schema update).
| Status | Cause | Fix |
|---|---|---|
400 |
An input value does not follow the rules. A JSON syntax error | message and issues show what is wrong |
401 |
Not signed in (login required). The access token is wrong, expired, or revoked (invalid or expired access token) |
Check that you put a token starting with hako_pat_ after Authorization: Bearer . If it has expired, create a new one |
403 |
Not enough permission (you do not have permission to do this). A write with a [読み取りだけ](Read only) token (this access token can only read). An operation tokens cannot do (access tokens cannot do this; sign in to the admin UI). A write from another site (cross-origin request rejected) |
Check the role’s permissions or the token’s [できること](What it can do). Sign in to the admin to create tokens |
404 |
The target does not exist. A space you are not a member of (returns 404 so as not to reveal that it exists) |
Check the slug or ID in the path, and whether you are a member of the space |
409 |
A name or ID collides. Someone else changed it first and your version is old (schema was changed by someone else and so on). It is referenced and cannot be deleted. An operation not possible in the current state. Confirmation is needed (send again with confirm). A usage limit has been reached |
Read message, read the data again, and send again |
415 |
Content-Type: application/json is missing |
When the body is JSON, add the header |
422 |
The JSON syntax is correct, but a required key is missing, a type is wrong, or there is an unknown key | Check the key shown in message |
429 |
Too many requests (many failed sign-ins and so on) | Wait for the number of seconds in the Retry-After header and send again |
500 |
An internal Hako CMS error | If it continues after some time, contact us with the date and time you sent the request and the URL |
When a usage limit is reached, 409 is returned, and limit contains the name and value of the limit.
{ "message": "this space has reached its limit of 100 entries; ask the server operator to raise it", "limit": { "name": "space.entries", "max": 100 }}limit.name |
What it counts | Operations that stop |
|---|---|---|
spaces |
Spaces | Creating spaces, import |
users |
Users not deleted | Creating users, inviting and accepting people without an account |
media |
Total media size (whole environment) | Uploading media, import |
space.content_types |
Content types | Creating content types, applying schemas, import |
space.entries |
Entries (total across all content types) | Creating entries, import |
space.members |
Members and invitations not yet accepted | Invitations |
space.api_keys |
API keys not revoked | Issuing API keys, restoring revoked keys |
space.webhooks |
Webhooks | Creating webhooks, import |
space.media |
Total media size (space) | Uploading media, import |
Exceeding a limit does not delete what already exists. Only operations that add more stop. You can get the current usage with Usage in the Admin API.
Image delivery and transformation
Section titled “Image delivery and transformation”When the transformation parameters added to an image URL are not valid, or the image is too large to transform, the following errors are returned. The format is { "message": … }, the same as the Admin API.
| Status | Example message |
Cause | Fix |
|---|---|---|---|
400 |
w: must be an integer between 1 and 8192 |
A parameter value is out of range or not valid | Check the value ranges in Transform and serve images |
400 |
fm: png is only available for PNG images |
fm=png was added to an image that is not PNG |
Use another format (webp and so on) |
400 |
image is too large to transform |
The image has too many pixels to transform | Upload a smaller image again. The original image, without transformation, can still be delivered |
Adding transformation parameters to a file that is not JPEG, PNG, WebP, or GIF (SVG, AVIF, and so on) does not cause an error. The original file is returned.