Error Handling
Error classes, codes, and retry strategies.
Runtime
NomiqonError
typescriptnomiqon.com
import { NomiqonError } from "@nomiqon/sdk";
try {
const agent = await nomiqon.agents.create({ name: "x", policy: { dailyCap: "5.00" } });
} catch (err) {
if (err instanceof NomiqonError) {
console.error(err.code);
console.error(err.status);
console.error(err.requestId);
console.error(err.message);
}
}All error codes
| Code | HTTP | Description |
|---|---|---|
| unauthorized | 401 | Missing or invalid API key |
| forbidden | 403 | Key lacks permission for this resource |
| not_found | 404 | Resource not found |
| validation_error | 422 | Request body failed schema validation |
| insufficient_balance | 402 | Agent wallet has insufficient USDC |
| policy_cap_exceeded | 402 | Daily, total, or window cap would be breached |
| policy_domain_blocked | 403 | Target hostname not permitted by policy |
| agent_frozen | 403 | Agent policy is frozen; no spends allowed |
| agent_paused | 403 | Agent is in paused status |
| agent_terminated | 410 | Agent has been permanently terminated |
| spend_token_expired | 401 | Spend token has expired (TTL 60 s) |
| spend_token_invalid | 401 | Spend token signature verification failed |
| rate_limit_exceeded | 429 | Too many requests — retry after Retry-After header |
| conflict | 409 | Resource already exists (e.g. duplicate agent name) |
| internal_error | 500 | Unexpected server error — idempotent requests safe to retry |
Retry strategy
typescriptnomiqon.com
const nomiqon = new Nomiqon({
apiKey: process.env.NOMIQON_API_KEY!,
retries: 3,
shouldRetry: (err) => {
if (err.status === 429) return true;
if (err.status >= 500) return true;
return false;
},
});