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"
}| Field | Type | Description |
|---|---|---|
statusCode | number | The HTTP status code of the response. |
error | string | The name of the status code, such as Bad Request. Some responses leave it out, such as API key errors and unexpected server errors. |
message | string or array of strings | What 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."
}
]
}pathjoins the field names with periods. A number in the path is an array index. An emptypathmeans the problem is with the whole body.- This body has no
statusCode. Read the HTTP status code, which is400. - Other errors from these endpoints, such as
404, use the standard body.
These endpoints return field-level errors:
- Create a merchant contact
- Update a contact
- Set per-role contact assignments for a merchant's connection
- Update a contact via the form's tokenized surface
- Set per-role contact assignments for the form's connection
HTTP status codes
| Code | What it means | What to do |
|---|---|---|
400 Bad Request | The request failed validation, or the action isn't allowed for the resource. | Fix the request. Don't retry it unchanged. |
401 Unauthorized | The 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 Forbidden | The 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 Found | A resource in the path or the request doesn't exist. | Check the ID. |
409 Conflict | The 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 Entity | The 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 Error | Preczn 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:
| Situation | Code |
|---|---|
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.
Updated 31 minutes ago
