Error Handling
The Metabind API uses standard HTTP status codes and returns detailed error objects to help you understand and handle errors effectively.Error Response Format
All error responses follow a consistent format:| Field | Type | Description |
|---|---|---|
code | string | Machine-readable error code |
message | string | Human-readable error description |
details | object | Additional context (optional) |
HTTP Status Codes
Success Codes
| Code | Description |
|---|---|
200 OK | Request succeeded |
201 Created | Resource created successfully |
204 No Content | Request succeeded with no response body |
Client Error Codes
| Code | Description |
|---|---|
400 Bad Request | Invalid request syntax or parameters |
401 Unauthorized | Missing or invalid authentication |
403 Forbidden | Valid auth but insufficient permissions |
404 Not Found | Resource does not exist |
409 Conflict | Resource conflict (e.g., duplicate name) |
422 Unprocessable Entity | Validation failed |
429 Too Many Requests | Rate limit exceeded |
Server Error Codes
| Code | Description |
|---|---|
500 Internal Server Error | Unexpected server error |
502 Bad Gateway | Upstream service error |
503 Service Unavailable | Service temporarily unavailable |
Common Error Codes
Validation Errors
Resource Not Found
Duplicate Resource
Invalid Status Transition
Resource In Use
Package Dependency Errors
Circular Dependency
Rate Limiting
When you exceed the rate limit, you’ll receive a429 Too Many Requests response:
retryAfter field indicates the number of seconds to wait before retrying.
Rate Limit Headers
Rate limit information is included in response headers:| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests per window |
X-RateLimit-Remaining | Remaining requests in current window |
X-RateLimit-Reset | Unix timestamp when the limit resets |
Handling Errors
JavaScript Example
Retry Strategy
For transient errors (5xx, 429), implement exponential backoff:Best Practices
Always check the error code
Always check the error code
Use the
code field for programmatic error handling, not the message field which may change.Log error details
Log error details
The
details object contains valuable debugging information. Log it for troubleshooting.Handle rate limits gracefully
Handle rate limits gracefully
Implement exponential backoff and respect the
retryAfter value.Validate before sending
Validate before sending
Validate data client-side before making API calls to avoid unnecessary 400/422 errors.
