StateSet API uses standard HTTP response codes and provides detailed error information to help you handle issues gracefully.
Error Response Format
All errors follow a consistent JSON structure to make error handling predictable:HTTP Status Codes
Status Code | Meaning | Common Causes |
---|---|---|
200 | OK | Request succeeded |
201 | Created | Resource successfully created |
202 | Accepted | Request accepted for async processing |
204 | No Content | Request succeeded with no response body |
400 | Bad Request | Invalid request parameters or malformed syntax |
401 | Unauthorized | Missing or invalid authentication |
403 | Forbidden | Valid auth but insufficient permissions |
404 | Not Found | Resource doesn’t exist |
409 | Conflict | Resource conflict or duplicate |
422 | Unprocessable Entity | Valid syntax but semantic errors |
429 | Too Many Requests | Rate limit exceeded |
500 | Internal Server Error | Server error - retry with backoff |
502 | Bad Gateway | Upstream service error |
503 | Service Unavailable | Temporary service outage |
Error Types and Codes
Authentication Errors (401)
Error Code | Description | Resolution |
---|---|---|
INVALID_API_KEY | API key is invalid or revoked | Check key in dashboard |
EXPIRED_API_KEY | API key has expired | Generate new API key |
MISSING_AUTH_HEADER | No Authorization header provided | Include Bearer token |
INVALID_TOKEN_FORMAT | Token format is incorrect | Use Bearer sk_... format |
INACTIVE_ACCOUNT | Account is suspended or inactive | Contact support |
Authorization Errors (403)
Error Code | Description | Resolution |
---|---|---|
INSUFFICIENT_PERMISSIONS | API key lacks required permissions | Use key with proper scopes |
RESOURCE_ACCESS_DENIED | Cannot access this specific resource | Check resource ownership |
PLAN_LIMIT_EXCEEDED | Feature not available on current plan | Upgrade plan |
IP_NOT_ALLOWED | Request from unauthorized IP | Add IP to allowlist |
Validation Errors (400/422)
Error Code | Description | Resolution |
---|---|---|
VALIDATION_ERROR | Request validation failed | Check field requirements |
MISSING_REQUIRED_FIELD | Required field not provided | Include all required fields |
INVALID_FIELD_VALUE | Field value doesn’t meet requirements | Validate field format |
INVALID_ENUM_VALUE | Value not in allowed enum list | Use accepted values |
FIELD_TOO_LONG | Field exceeds maximum length | Truncate field value |
INVALID_DATE_FORMAT | Date format incorrect | Use ISO 8601 format |
Resource Errors (404/409)
Error Code | Description | Resolution |
---|---|---|
RESOURCE_NOT_FOUND | Requested resource doesn’t exist | Verify resource ID |
RESOURCE_ALREADY_EXISTS | Duplicate resource creation attempt | Use existing resource |
RESOURCE_LOCKED | Resource is locked for editing | Wait and retry |
RESOURCE_ARCHIVED | Resource has been archived | Unarchive or use different resource |
PARENT_NOT_FOUND | Parent resource doesn’t exist | Create parent first |
Business Logic Errors (422)
Error Code | Description | Resolution |
---|---|---|
INSUFFICIENT_INVENTORY | Not enough inventory available | Reduce quantity or check stock |
PAYMENT_FAILED | Payment processing failed | Verify payment details |
INVALID_STATE_TRANSITION | Invalid status change | Check allowed transitions |
OUTSIDE_RETURN_WINDOW | Return period expired | Check return policy |
DUPLICATE_REQUEST | Duplicate request detected | Use idempotency key |
Rate Limiting Errors (429)
Error Handling Best Practices
1. Implement Exponential Backoff
2. Handle Specific Error Types
3. Implement Circuit Breaker Pattern
4. Log and Monitor Errors
Error Recovery Strategies
Idempotency for Safe Retries
Graceful Degradation
Common Error Scenarios
Handling Validation Errors
Handling Resource Conflicts
Error Webhooks
Configure error webhooks to receive notifications for critical failures:SDK Error Handling
Our SDKs provide built-in error handling:Testing Error Scenarios
Use test mode to simulate error conditions:Support
If you encounter persistent errors or need help with error handling:- API Status: Check status.stateset.com
- Support: Contact api-support@stateset.com
- Discord: Join our developer community
Related: Rate Limiting | Authentication | Webhooks