Error Handling

HTTP status code is used to indicate success or failure of an API call. The body of the response contains the details of the error in JSON format.

Sample error response:

Below is the sample error that is returned for 'create subscription' api call when the customer referred in the body request is not exist. The returned http status code will be 400.

{
  "customer": [
    "Primary key \"cus_Po7v57HtZ923LpOau6ZT\" invalid - object is not exists."
  ]
}

When it comes to errors in the sent fields, the error template obeys to field: [errors_list], while that if comes to general errors, the errors template obeys to non_errors_key: [errors_list]

{
  "field_1": [
      "error_1",
      "error_2",
      ...
  ],
  "non_field_errors": [
      "error_1",
      "error_2",
      ...
  ],
  "field_2": [
    {
      "sub_field_1": [
        {
          "sub_sub_field_1": [
            "This field is required."
          ]
        }
      ]
    }
  ]
}

Last updated