Documentation Index
Fetch the complete documentation index at: https://docs.mandate.md/llms.txt
Use this file to discover all available pages before exploring further.
Error class hierarchy
The Mandate SDK throws 5 typed error classes. Every error extendsMandateError, which extends the native Error. Use instanceof to handle each scenario precisely.
@mandate.md/sdk. Import them in a single statement:
Catching errors with instanceof
Order matters. Check specific subclasses before the baseMandateError. Here is the complete pattern:
What to do for each error
| Error | HTTP | Action |
|---|---|---|
CircuitBreakerError | 403 | Stop all transactions. Notify the agent owner. Wait for dashboard reset. |
RiskBlockedError | 422 | Verify the destination address. Do not retry with the same address. |
ApprovalRequiredError | 202 | Call waitForApproval(). See Handle Approvals. |
PolicyBlockedError | 422 | Display declineMessage. Log blockReason. Adjust params or update policy. |
MandateError | varies | Check statusCode. Retry 5xx with backoff. Fix 4xx requests. |
Block reason reference
When aPolicyBlockedError fires, the blockReason field tells you exactly which check failed. Here are the most common values:
| blockReason | Meaning | Action |
|---|---|---|
per_tx_limit_exceeded | Single transaction amount too high | Reduce amount or request policy change |
daily_quota_exceeded | Daily spend limit exhausted | Wait until the next UTC day or request increase |
monthly_quota_exceeded | Monthly spend limit exhausted | Wait until the next month or request increase |
address_not_allowed | Destination not in allowlist | Add the address in Policy Builder |
action_not_allowed | Action type blocked by policy | Update allowed actions in policy |
selector_not_allowed | Function selector blocked | Update allowed selectors in policy |
schedule_outside_window | Transaction outside allowed hours | Wait for the schedule window to open |
circuit_breaker_active | Emergency stop is active | Owner must reset the circuit breaker |
reason_blocked | Prompt injection detected in reason field | Review and rewrite the reason text |
aegis_critical_risk | Address flagged as critical risk | Do not transact with this address |
aegis_high_risk | Address flagged as high risk | Verify the address before proceeding |
Retry strategy
Not all errors are retryable. Follow these rules to avoid wasting cycles or triggering rate limits.| Error type | Retryable? | Strategy |
|---|---|---|
| Network error / timeout | Yes | Exponential backoff: 1s, 2s, 4s. Max 3 attempts. |
MandateError (5xx) | Yes | Exponential backoff: 1s, 2s, 4s. Max 3 attempts. |
MandateError (4xx) | No | Fix the request. Client-side problem. |
PolicyBlockedError | No | Same parameters will fail again. Adjust amount, address, or policy. |
ApprovalRequiredError | N/A | Not a failure. Poll with waitForApproval(). |
CircuitBreakerError | No | Do not retry until the owner resets via dashboard. |
RiskBlockedError | No | Do not retry with the same destination address. |
Fail-safe rules
If the Mandate API is unreachable, your agent must block the transaction. Never fall back to unvalidated execution. A network failure is not permission to skip validation. Treat an unreachable API the same as a rejection.Next Steps
Error Classes Reference
Full property tables and code examples for all 5 error classes.
Block Reasons
Complete list of blockReason codes, meanings, and recommended actions.
Validate Transactions
Step-by-step guide to calling validate() in your agent code.
Common Errors
Troubleshoot frequent issues with error codes and solutions.