ApieError
The SDK throwsApieError for client-side failures: registration errors, Enforce blocks, approval timeouts, and ingest failures.
Guardrail failure modes
When guardrail evaluation fails (network error, timeout),guardFailureMode controls behavior:
| Mode | Behavior |
|---|---|
fail_open | Allow the action (default) |
fail_closed | Treat as blocked |
throw | Throw ApieError immediately |
Guard decisions
In Enforce mode,withTool throws when:
| Decision | Error |
|---|---|
block | Guard blocked the action |
require_approval + rejected | Approval rejected |
require_approval + timeout | Approval timed out |
MCP JSON-RPC error codes
When using the MCP proxy in Enforce mode:| Code | Meaning |
|---|---|
-32001 | Guardrail blocked the tool call |
-32002 | Approval denied or timed out |
Queue errors
onError setting | Behavior |
|---|---|
silent | Swallow flush errors |
warn | Log warning (default) |
throw | Throw on flush failure |
Event validation
UsevalidateEvents to check payloads before sending:
Disabled client
Whenenabled: false, the client never throws for network errors — all operations are no-ops with synthetic IDs.
Next steps
Diagnose your setup
Debug connection issues.
Enforce guardrails
Enforce mode behavior.
