Build Basics

Handling Errors

Square APIs always return a response. If an endpoint request fails, the response body includes an errors array as explained in the following section.

Square API errors Permalink Get a link to this section

When a request fails, Square endpoints return a response that includes the errors field in the body. It provides one or more errors of the Error type. The following is an example response of a failed CreatePayment request:

{
  "errors": [
    {
      "category": "AUTHENTICATION_ERROR",
      "code": "VALUE_EMPTY",
      "detail": "Field must not be blank.",
      “Field” : “idempotency_key”field”
    }
  ]
}

Note

The Square Connect V1 API is a deprecated API. If you are still using the API, note that all Connect V1 endpoints return JSON error responses to indicate the related HTTP protocol status code and a human-readable message describing the error. The error message is always in English. For example:

{
  "type": "not_found",
  "message": "The resource specified in the request wasn't found.",
}

Protocol status codes Permalink Get a link to this section

Square API endpoints use HTTP protocol status codes to indicate errors. For more information about HTTP response status codes, see HTTP response status codes. The error code values range from 400 to 599.