Skip to main content

Error response format

Every error response from the Mandate API returns JSON with a consistent structure. The exact fields depend on whether the error is a policy block or a general API error.

Policy block response

General error response

The blockReason field is only present on policy blocks (422) and circuit breaker blocks (403). The declineMessage field is an adversarial counter-message designed to override prompt injection attempts.

HTTP status code reference

SDK error class hierarchy

Mapping responses to error classes

The SDK automatically maps API responses to the correct error class:
  • 403 with circuit_breaker_active maps to CircuitBreakerError
  • 422 with aegis_critical_risk maps to RiskBlockedError
  • 422 with any other blockReason maps to PolicyBlockedError
  • 202 with requiresApproval: true maps to ApprovalRequiredError
  • All other non-2xx responses map to MandateError

Handling errors

Always check specific subclasses before the base class:

Next Steps

SDK Error Classes

Detailed reference for each error class with properties and recovery patterns.

Block Reasons

All blockReason values with causes and resolutions.