Skip to main content
All API errors return a JSON body with this shape:
{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable message"
  }
}

HTTP status codes

StatusCodeMeaning
400VALIDATION_ERRORThe request body or query parameters are invalid.
401UNAUTHORIZEDThe API key is missing, invalid, or has been revoked.
401API_KEY_EXPIREDThe API key has passed its expiry date.
403INSUFFICIENT_SCOPEThe API key does not have the required scope for this operation.
404AGENT_NOT_FOUNDThe agent ID does not exist in your workspace.
404POLICY_NOT_FOUNDThe policy ID does not exist in your workspace.
404API_KEY_NOT_FOUNDThe API key ID does not exist in your workspace.
429RATE_LIMITEDYou have exceeded the rate limit. Check the Retry-After header.
500INTERNAL_ERRORAn unexpected server error occurred.
POST /v1/authorize always returns 200, even when a request is denied. The authorization decision is in the allowed and outcome fields of the response body. HTTP errors from /v1/authorize indicate authentication or server failures only.

SDK error classes

The Veto Node.js SDK surfaces API errors as typed exceptions.
ClassStatusExtra fields
VetoErroranycode, statusCode — base class for all errors
UnauthorizedError401Extends VetoError with code: "UNAUTHORIZED"
RateLimitError429Extends VetoError; adds retryAfterMs (milliseconds to wait)

Handling errors in TypeScript

import { VetoClient, VetoError, UnauthorizedError, RateLimitError } from "@useveto/node";

const veto = new VetoClient({ apiKey: process.env.VETO_API_KEY! });

try {
  const result = await veto.authorize(
    "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "file.write",
    { path: "/home/user/doc.txt" },
  );

  if (!result.allowed) {
    console.log("Action denied:", result.reason);
  }
} catch (err) {
  if (err instanceof UnauthorizedError) {
    // 401 — invalid or expired API key
    console.error("Check your VETO_API_KEY environment variable.");
  } else if (err instanceof RateLimitError) {
    // 429 — back off and retry
    const waitMs = err.retryAfterMs;
    console.log(`Rate limited. Retry in ${waitMs}ms.`);
    await new Promise((resolve) => setTimeout(resolve, waitMs));
  } else if (err instanceof VetoError) {
    console.error(`API error ${err.statusCode}: ${err.code}${err.message}`);
  } else {
    throw err;
  }
}