Perch uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in theDocumentation Index
Fetch the complete documentation index at: https://docs.myperch.io/llms.txt
Use this file to discover all available pages before exploring further.
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).
HTTP status codes
| 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.) |
Error response format
The error will contain a helpfulmessage 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.
Field validation error codes
When validation fails on specific fields, you’ll receive one of these error codes:| 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. |
Common error scenarios
Authentication errors
401 Unauthorized- Missing
X-API-Keyheader - Invalid or expired API key
- API key format is incorrect
- API key doesn’t have permission for the requested resource
- Trying to access a resource outside your firm’s scope
Client errors
404 Not Found- Resource doesn’t exist (lead, plan, etc.)
- Typo in the endpoint URL
- Resource exists but you don’t have permission to access it
- Duplicate lead with same email for your firm
- Idempotency key collision
- Resource state conflict
- Missing required fields
- Invalid field values or formats
- Business logic validation failures
Rate limiting
429 Too Many Requests- Exceeded your hourly rate limit
- Too many requests in a short burst
- Implement exponential backoff and retry logic
Best practices for error handling
- Always check status codes - Don’t assume requests succeeded without checking the HTTP status
- Parse error messages - The
messagefield often contains human-readable explanations - Handle field errors - Use the
fieldsobject to show specific validation errors to users - Implement retry logic - For
429and5xxerrors, implement smart retry mechanisms - Log errors appropriately - Log enough detail for debugging but avoid logging sensitive data
- Graceful degradation - Handle API errors gracefully in your user interface