Error Handling

Comprehensive guide to handling errors in the AIDP API.

Error Response Format

All API errors follow a consistent format:

{
  "error": "Error message",
  "code": "ERROR_CODE",
  "details": {
    "field": "Additional context"
  },
  "requestId": "req_abc123"
}

HTTP Status Codes

2xx Success

  • 200 OK: Request successful

  • 201 Created: Resource created successfully

4xx Client Errors

  • 400 Bad Request: Invalid request parameters

  • 401 Unauthorized: Missing or invalid API key

  • 403 Forbidden: Insufficient permissions

  • 404 Not Found: Resource doesn't exist

  • 429 Too Many Requests: Rate limit exceeded

5xx Server Errors

  • 500 Internal Server Error: Server-side error

  • 503 Service Unavailable: Temporary service disruption


Common Errors

Authentication Errors

401 Unauthorized

Solution: Check your API key is correct and active.

Validation Errors

400 Bad Request

Solution: Fix the invalid fields listed in details.

Rate Limit Errors

429 Too Many Requests

Solution: Wait retryAfter seconds before retrying.

Not Found Errors

404 Not Found

Solution: Verify the resource ID is correct.


Error Handling Best Practices

1. Always Check Status Codes

2. Implement Retry Logic

3. Log Errors with Request IDs

4. Provide User-Friendly Messages


Error Codes Reference

Code
Description
Action

INVALID_API_KEY

API key is invalid or missing

Check API key

RATE_LIMIT_EXCEEDED

Too many requests

Wait and retry

VALIDATION_ERROR

Invalid request parameters

Fix parameters

BUSINESS_NOT_FOUND

Business doesn't exist

Verify ID

UNAUTHORIZED

Insufficient permissions

Check permissions

INTERNAL_ERROR

Server error

Retry or contact support


Need Help?

Last updated