Errors

The error body the Preczn API returns, and what each HTTP status code means.

When a request fails, the Preczn API returns a 4xx or 5xx HTTP status code and a JSON body that describes the problem. Branch your code on the status code, and log the body to troubleshoot.


Error response format

Most errors return this body:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "pageSize must be a number between 1 and 50"
}
FieldTypeDescription
statusCodenumberThe HTTP status code of the response.
errorstringThe name of the status code, such as Bad Request. Some responses leave it out, such as API key errors and unexpected server errors.
messagestring or array of stringsWhat went wrong. When request validation fails, message is an array with one entry for each problem.

For example, a request to List Transactions that sends an empty merchantId and an empty lastId returns this body:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": [
    "merchantId should not be empty",
    "lastId should not be empty"
  ]
}

Field-level errors

The contact endpoints return field-level errors when the request body fails validation. Each entry names the field in path and the problem in message:

{
  "errors": [
    {
      "path": "assignments.0.subjectId",
      "message": "Owner not found on this merchant."
    }
  ]
}
  • path joins the field names with periods. A number in the path is an array index. An empty path means the problem is with the whole body.
  • This body has no statusCode. Read the HTTP status code, which is 400.
  • Other errors from these endpoints, such as 404, use the standard body.

These endpoints return field-level errors:


HTTP status codes

CodeWhat it meansWhat to do
400 Bad RequestThe request failed validation, or the action isn't allowed for the resource.Fix the request. Don't retry it unchanged.
401 UnauthorizedThe x-api-key header is missing, or the key is unknown or deactivated. Some endpoints also return 401 when the key can't access the requested resource.Send an active API key. If the key is active, see the endpoint's API reference page.
403 ForbiddenThe API key is valid, but it can't make this request.See the API key errors section and the endpoint's API reference page.
404 Not FoundA resource in the path or the request doesn't exist.Check the ID.
409 ConflictThe request conflicts with the resource's current state, such as deleting a merchant's primary location or signing an SAQ that's already signed. On Process Transaction, a request with the same idempotency key is still in progress.Read the message. For an idempotency conflict, see Idempotency keys.
422 Unprocessable EntityThe request is valid, but the connection couldn't process it with the merchant's credentials or setup.Check the connection's credentials and setup.
500 Internal Server ErrorPreczn couldn't complete the request.Retry the request. Before you retry a request that creates something, such as a transaction, see Idempotency keys.

Successful requests return 200, 201, or 204. Each endpoint's API reference page lists the codes it returns.

API key errors

The API returns these codes for problems with the API key itself:

SituationCode
The x-api-key header is missing.401
The key is unknown or deactivated.401
The key is active, but its type can't call the endpoint, such as a public key on an endpoint that needs a private key.403

To learn which key type each endpoint needs, see API keys.


Endpoint errors

Each endpoint's page in the API reference lists its status codes and when it returns them. Errors for ACH transactions are listed in ACH errors.


Did this page help you?