Errors

Learn how to handle errors with the Cosmic API.

Status codes

The Cosmic API uses the following status codes:

Status codeMeaning
200OK - Everything worked as expected.
400Bad Request - Your request is invalid.
401Unauthorized - Your access key is incorrect.
402Payment Required - Your Bucket needs to be upgraded to continue use.
403Forbidden - You are not allowed to access this content.
404Not Found - The requested resource doesn't exist.
429Too Many Requests - Too many requests hit the API too quickly.
500, 502, 503, 504Internal Server Error - Something went wrong on our end.

Error response model

Here is the error response model that you can expect:

  • Name
    status
    Type
    number
    Description

    The status code from the table above.

  • Name
    message
    Type
    string
    Description

    A verbose error message that will try to hint at any possible issues with the request.

Error example

Error messages will attempt to be as specific as possible with what went wrong. For example, if there was an invalid property in a request the following format can be expected:

{
  "status": 400,
  "message": "Metafield validation: invalid 'value' for metafield with key: 'number' and type: 'number'"
}