API Reference

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 StatusDescription
200 - OKEverything worked as expected
400 - Bad RequestThe request was unacceptable, often due to missing a required parameter
401 - UnauthorizedNo valid API key provided or don't have permissions for use organization
403 - ForbiddenNo API key provided
404 - Not FoundThe API resource doesn't exist
500 - Server ErrorThe 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."
          ]
        }
      ]
    }
  ]
}