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.

HTTP CODE STATUS

200 - OK

Everything worked as expected.

400 - Bad Request

The request was unacceptable, often due to missing a required parameter.

401 - Unauthorized

No valid API key provided or don't have permissions for use organization.

403 - Forbidden

No API key provided.

404 - Not Found

The API resource doesn't exist.

500 - Server Error

The API call was valid but failed due to bugs on the Piriod server side.

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