Skip to main content
The Unkey API uses conventional HTTP status codes and returns detailed error information following the Problem Details for HTTP APIs standard (RFC 7807). This ensures consistent, machine-readable error responses across all endpoints.

Error Response Format

All error responses follow this structure:
object
required
Operational metadata
object
required
Error details

HTTP Status Codes

The Unkey API uses these HTTP status codes:

Success Codes

status
Request succeeded. The response includes the requested data.Note: Key verification always returns 200, even when validation fails. Check the valid field in the response data.

Client Error Codes

status
Request cannot be processed due to client error. This occurs when:
  • Required parameters are missing
  • Parameters are malformed or invalid
  • Request fails validation rules
The response includes an errors array with specific validation failures.
status
Authentication failed or credentials are missing. This occurs when:
  • No Authorization header is provided
  • The provided root key is invalid, expired, or malformed
  • The token format doesn’t match expected patterns
Resolution: Ensure you’re including a valid root key in the Authorization header.
status
Credentials are valid but lack sufficient permissions. This occurs when:
  • The root key doesn’t have required permissions for this endpoint
  • The operation requires elevated privileges
  • Access is restricted based on workspace settings
Resolution: Verify your root key has the necessary permissions or contact your workspace administrator.
status
The requested resource doesn’t exist. This occurs when:
  • The resource ID is incorrect
  • The resource has been deleted
  • You lack permissions to access the resource
Note: Some endpoints return 404 instead of 403 to avoid leaking resource existence.
status
Request conflicts with current state. This occurs when:
  • Creating a resource that already exists
  • Modifying a resource with stale data
  • Operation violates uniqueness constraints
Resolution: Check current resource state and adjust your request.
status
Request preconditions were not met. This occurs when:
  • Conditional request headers don’t match
  • Resource state doesn’t match expectations
Resolution: Refresh resource state and retry the operation.
status
Request is well-formed but semantically invalid. This occurs when:
  • Business logic rules are violated
  • Resource constraints prevent the operation
  • Invalid state transitions
Resolution: Review business rules and adjust your request.
status
Rate limit exceeded. This occurs when:
  • Too many requests in a given time period
  • Workspace quota exceeded
Resolution: Implement exponential backoff and retry logic. The rate limit resets automatically after the time window expires.

Server Error Codes

status
Unexpected server error occurred. This indicates an issue on Unkey’s side.Resolution: Retry the request with exponential backoff. If the issue persists, contact support with the requestId.
status
Service is temporarily unavailable. This occurs during:
  • Planned maintenance
  • Temporary outages
  • System overload
Resolution: Retry the request with exponential backoff.

Common Error Scenarios

Validation Errors

400 Bad Request responses include detailed validation errors:
How to handle:
  1. Check the errors array for specific validation failures
  2. Use the location field to identify the problematic parameter
  3. Read the message for details about what’s wrong
  4. Follow the fix suggestion (when provided) to resolve the issue

Permission Errors

When your root key lacks required permissions:
How to handle:
  1. Verify your root key has the required permissions listed in the endpoint documentation
  2. Check if you’re accessing resources outside your permitted scope
  3. Create a new root key with appropriate permissions if needed
  4. Contact your workspace administrator if you need elevated access

Rate Limiting

When you exceed rate limits:
How to handle:
  1. Implement exponential backoff in your retry logic
  2. Cache responses where appropriate to reduce request frequency
  3. Spread requests over time instead of bursting
  4. Contact support if you consistently hit limits

Error Handling Best Practices

Check Status Codes

Always check HTTP status codes before processing responses:

Parse Validation Errors

For 400 responses, iterate through validation errors:

Implement Retry Logic

Retry failed requests with exponential backoff:

Log Request IDs

Always log request IDs for debugging:

Handle Special Cases

Some endpoints have unique error behavior: Key Verification: Always returns 200, check the valid field:

Troubleshooting Guide

Issue: Getting 401 Unauthorized

1

Check Authorization header

Ensure the Authorization header is present and properly formatted:
2

Verify root key

Confirm the root key hasn’t been revoked or expired in your dashboard.
3

Check for typos

Root keys are case-sensitive. Verify you’re using the exact key value.

Issue: Getting 403 Forbidden

1

Check endpoint permissions

Review the endpoint documentation for required permissions.
2

Verify root key permissions

Go to Settings > Root Keys in your dashboard and check the key’s permissions.
3

Update permissions

Create a new root key with the required permissions if needed.

Issue: Getting 400 Bad Request

1

Check validation errors

Read the errors array in the response for specific validation failures.
2

Verify request format

Ensure your request body matches the endpoint’s schema.
3

Check required fields

Confirm all required fields are present and correctly formatted.

Issue: Getting 429 Too Many Requests

1

Implement backoff

Add exponential backoff to your retry logic.
2

Reduce request frequency

Cache responses where possible to reduce API calls.
3

Contact support

If you consistently hit limits, reach out to discuss increasing your quota.

Getting Help

If you encounter persistent errors:
  1. Check the error type URL: Visit the URL in the type field for detailed documentation
  2. Review this documentation: Search for your specific error code or scenario
  3. Include request ID: When contacting support, always include the requestId from the error response
  4. Join our Discord: Get help from the community and Unkey team
  5. Contact support: Reach out at support@unkey.com with:
    • Request ID
    • Error response
    • What you were trying to accomplish
    • Steps to reproduce