When an API request fails, Buttondown returns a structured error response containing an error code and a human-readable message. This page provides a comprehensive reference for all error codes you might encounter. (Be sure to also check out the status code of the response!)
Error response format
Errors tied to a specific error code follow this consistent format:
Validation errors
Requests that fail schema validation — for example, sending an unknown field, an over-long value, or a malformed identifier — instead return a 422 with a detail array containing one entry per invalid field:
Each entry's type names the validation failure (common values include extra_forbidden, missing, string_too_long, and string_pattern_mismatch) and loc points to the offending field. Sending only the documented fields, within their documented limits, avoids these.
Finding endpoint-specific error codes
Error codes specific to each API endpoint are now documented directly on the individual endpoint pages. When viewing an endpoint's documentation, you'll find a dedicated "Error codes" section that lists all possible error codes for that endpoint, along with their descriptions and how to fix them.
For example:
This approach makes it easier to find the relevant error codes when working with a specific endpoint.
Handling errors
Best practices
- Always check the HTTP status code first - This gives you the general category of error
- Parse the error code - Use the specific error code for programmatic handling
- Check metadata fields - Additional context may be provided in the metadata object
- Implement retry logic - For 429 and 5xx errors, implement exponential backoff
- Validate locally - Reduce API errors by validating data before sending requests