Skip to main content
SureCart uses conventional HTTP response codes to indicate the success or failure of an API request. In general: codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.). Codes in the 5xx range indicate an error with SureCart’s servers (these are rare).

HTTP Status Codes

These are all of the status codes that the SureCart API will return.

Error Responses

All error responses will be formatted like the example below, and they will have at least the following keys:
  • http_status – The HTTP status code – matching the HTTP response status.
  • type – The type of error – more specific than the http_status.
  • code – The unique code for the error – this should be used for translations.
  • message – The human readable error message.

Validation Errors

If an error is due to object validation a validation_errors key will also be set within the error response. The validation errors response will be formatted like the example below, and each validation error will have the following keys:
  • attribute – The attribute the validation error is associated with.
  • type – The type of validation error.
  • code – The unique code for the validation error – this should be used for translations.
  • options – Any options that apply to this error – these can be used for translation interpolation. (For example, a numerical validation error might have options for min and max.)
  • message – The human readable validation error message.