Understanding error handling and HTTP status codes in the Perch Partner API
2xx
range indicate success. Codes in the 4xx
range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.). Codes in the 5xx
range indicate an error with Perch’s servers (these are rare, but they can happen).
Status | Code | Description |
---|---|---|
200 | OK | Everything worked as expected. |
201 | Created | Successfully created a new resource. |
401 | Unauthorized | No valid API key provided. |
403 | Forbidden | The API key doesn’t have permissions to perform the request. |
404 | Not Found | The requested resource doesn’t exist or you do not have permission to access it. |
409 | Conflict | The request conflicts with another request (perhaps due to using the same idempotent key). |
422 | Unprocessable Entity | The request was unacceptable, often due to missing a required parameter. |
429 | Too Many Requests | Too many requests hit the API too quickly. We recommend an exponential backoff of your requests. |
5xx | Server Error | Something went wrong on Perch’s end. (These are rare.) |
message
and, in some cases (409
and 422
), a fields
object. The fields object will contain fields that failed some validation and an array of validation errors.
Code | Description |
---|---|
INVALID | The field does not follow the intended format, e.g., an invalid email address. |
INCORRECT_TYPE | The field has a value of an incorrect type, e.g., a Boolean passed to a Date field. |
NOT_UNIQUE | There’s a conflict in the database on this field, e.g., a unique constraint is violated. |
NOT_FOUND | No records could be found for a lookup using this field. |
UNSUPPORTED | The field type is unsupported. Check the supported field types in the Changeset. |
REQUIRED | The field is required but is undefined or missing. |
IN_USE | The field is in use by another record. |
X-API-Key
header429
errors, implement exponential backoff in your retry logic. Start with a 1-second delay and double it with each retry, up to a maximum of 60 seconds.message
field often contains human-readable explanationsfields
object to show specific validation errors to users429
and 5xx
errors, implement smart retry mechanisms