Skip to main content

Error Response Format

All error responses from the GaiterGuard API follow a consistent JSON structure:
The Content-Type header is always set to application/json for error responses.

Common HTTP Status Codes

Error Types

Authentication Errors

Returned when authentication fails or credentials are invalid. Missing Authorization Header
Invalid Authorization Format
Invalid or Expired Token
Missing Agent-Key Header
Invalid Agent-Key Format
Invalid Agent-Key
Revoked Agent Key

Validation Errors

Returned when request data fails schema validation. Invalid JSON
Field Validation Error
Missing Required Field
Validation errors include the field path and specific validation message in the format: field.path: Error message

Proxy Errors

Errors that occur during request proxying to target services. SSRF Prevention - Hostname Mismatch
SSRF Prevention - Path Mismatch
SSRF Prevention - Private IP Blocked
SSRF Prevention - Localhost Blocked
Invalid Protocol
Service Not Found
Missing Service Access
Request Timeout
Response Size Limit
Gateway Error

Idempotency Errors

Errors related to idempotency key processing. Duplicate Request Processing
When you receive a 409 error for an idempotency key, wait for the original request to complete before retrying. The cached response will be available once the original request finishes.

Risk Assessment Errors

Returned when a request is flagged as risky and requires human approval. Approval Required
HTTP Status: 428 Precondition Required
Use the action_id to poll for approval status at the provided status_url endpoint, then execute the request using POST /proxy/execute/:actionId once approved.

Approval Queue Errors

Action Not Found
Invalid Action Status
Approval Expired
Service Deleted

Error Handling Best Practices

Retry Logic

  • 401 Unauthorized: Do not retry. Check your authentication credentials.
  • 403 Forbidden: Do not retry. Request is blocked by security policy.
  • 409 Conflict: Wait and poll for idempotency key completion, then use cached response.
  • 428 Precondition Required: Poll for approval status, then execute with /proxy/execute/:actionId.
  • 429 Rate Limited: Implement exponential backoff (not currently returned but reserved).
  • 500/502/504: Retry with exponential backoff up to 3 attempts.

Handling Idempotency Conflicts

When you receive a 409 error:
  1. The original request is still processing
  2. Wait 1-2 seconds
  3. Retry the request with the same idempotency key
  4. The gateway will return the cached response once available

Handling Approval Required (428)

When you receive a 428 error:
  1. Extract the action_id from the response
  2. Poll GET /status/:actionId until status is APPROVED
  3. Execute the approved request with POST /proxy/execute/:actionId
  4. If status becomes EXPIRED, resubmit the original request via POST /proxy

Error Response Headers

All error responses include:

Implementation Details

Error responses are generated using the errorResponse() utility function from utils/responses.ts:26: