Skip to main content

Error Handling

The Daytona API uses standard HTTP status codes to indicate success or failure of requests. All error responses include a JSON body with detailed error information.

Error Response Format

Error responses follow a consistent structure:
number
required
HTTP status code (4xx for client errors, 5xx for server errors)
string
required
Human-readable error summary
string
required
Detailed error description with context

HTTP Status Codes

Success Codes (2xx)

success
Request succeeded. Response body contains requested data.
success
Resource created successfully. Response body contains the new resource.
success
Request succeeded. No response body (common for DELETE operations).

Client Error Codes (4xx)

error
Invalid request format, missing required fields, or validation errors.
error
Missing, invalid, or expired authentication credentials.
error
Authenticated but lacks permission to access the resource.
error
Requested resource does not exist.
error
Request conflicts with current state (e.g., duplicate resource).
error
Rate limit exceeded. See Rate Limits.

Server Error Codes (5xx)

error
Unexpected server error. Contact support if persistent.
error
Upstream service unavailable. Retry with exponential backoff.
error
Service temporarily unavailable (maintenance or overload).

Common Error Scenarios

Authentication Errors

Missing API Key

Solution: Include the Authorization header:

Invalid API Key

Solutions:
  • Verify your API key is correct
  • Check if the key has expired
  • Create a new API key if needed

Insufficient Permissions

Solution: Create an API key with appropriate permissions:

Validation Errors

Missing Required Field

Solution: Include all required fields in the request:

Invalid Field Value

Solution: Provide valid values within acceptable ranges.

Invalid JSON Format

Solution: Ensure request body is valid JSON:

Resource Errors

Resource Not Found

Solutions:
  • Verify the resource ID is correct
  • Check if the resource was deleted
  • Ensure you have access to the resource

Resource Conflict

Solution: Use a unique alias or update the existing resource.

Rate Limit Errors

Solutions:
  • Wait for the time specified in retryAfter
  • Implement exponential backoff
  • See Rate Limits for best practices

Organization Context Errors

Missing Organization ID

Solution: Include organization header for JWT authentication:

Quota Errors

Organization Quota Exceeded

Solutions:
  • Delete unused sandboxes
  • Stop sandboxes not in use
  • Upgrade your organization plan
  • Contact support for quota increase

Region Quota Exceeded

Solutions:
  • Use a different region
  • Reduce resource allocation
  • Contact support for regional quota adjustment

Error Handling Best Practices

Implement Retry Logic

Validate Before Sending

Log Error Details

Graceful Degradation

Debugging Tips

Use verbose mode to see full request/response details:
Every response includes a request ID for troubleshooting:
Include this when contacting support.
Use tools like Swagger UI or Postman to validate requests against the OpenAPI specification.
Before implementing in code, test with curl to isolate issues:

Getting Help

If you encounter persistent errors:
  1. Check status page - Verify there are no ongoing incidents
  2. Review documentation - Ensure you’re using the API correctly
  3. Search community - Check if others have encountered similar issues
  4. Contact support - Include request ID, error message, and reproduction steps
Include the X-Request-ID header value when reporting errors to support for faster resolution.

Next Steps

Authentication

Fix authentication errors

Rate Limits

Handle rate limit errors

SDKs

Use SDKs with built-in error handling

Support

Get help from the community