Skip to main content
Every method throws a NaiveError on a non-2xx response:
import { Naive, NaiveError } from "@usenaive-sdk/node";

try {
  await naive.forUser(alice.id).connections.connect("slack");
} catch (err) {
  if (err instanceof NaiveError) {
    console.log(err.status); // HTTP status
    console.log(err.code);   // canonical code
    console.log(err.hint);   // actionable hint, when present
  }
}

Common codes

CodeMeaning
not_foundResource (or cross-tenant user) not in your workspace
forbiddenBlocked by the user’s AccountKit (e.g. toolkit_not_allowed, tool_not_allowed, primitive_disabled_by_kit)
feature_not_configuredConnections provider or Vault KMS not configured on the API
invalid_inputBad request body / params
provider_errorUpstream provider (connections/KMS) failure

Pending approval is not an error

A sensitive call gated by the user’s AccountKit returns HTTP 202 with { status: "pending_approval", approval_id }. This is a success-with-deferral — it does not throw. The gated methods (cards.create, domains.purchase, verification.start, formation.submit, connections.connect, …) resolve to either their normal result or a PendingApproval. Discriminate with the typed helper:
import { isPendingApproval } from "@usenaive-sdk/node";

const res = await naive.forUser(alice.id).cards.create({ name: "Ads", spendingLimitCents: 50000 });
if (isPendingApproval(res)) {
  // queued — a human must approve it (res.approval_id)
} else {
  // executed normally
}
See Approvals.