Error Handling

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

CodeHTTPDescription
unauthorized401Missing or invalid API key
forbidden403Key lacks permission for this resource
not_found404Resource not found
validation_error422Request body failed schema validation
insufficient_balance402Agent wallet has insufficient USDC
policy_cap_exceeded402Daily, total, or window cap would be breached
policy_domain_blocked403Target hostname not permitted by policy
agent_frozen403Agent policy is frozen; no spends allowed
agent_paused403Agent is in paused status
agent_terminated410Agent has been permanently terminated
spend_token_expired401Spend token has expired (TTL 60 s)
spend_token_invalid401Spend token signature verification failed
rate_limit_exceeded429Too many requests — retry after Retry-After header
conflict409Resource already exists (e.g. duplicate agent name)
internal_error500Unexpected 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;
  },
});
Error Handling — Nomiqon Docs