Errors

The Vanta error model and how to handle failures in your code.

Error classes

The Node SDK surfaces failures as typed errors, exported from @vanta-dev/node:

ClassMeaning
VantaErrorBase class for any Vanta request failure. Carries statusCode and code.
RateLimitErrorHTTP 429. Exposes retryAfter, the number of seconds to wait before retrying.
AuthenticationErrorAuthentication failed, typically a missing or invalid API key.

VantaError is the base class, so a single handler that catches it covers every typed failure. Check statusCode when you need fine-grained handling.

HTTP status codes

StatusMeaningWhat to do
400Invalid request: a missing or malformed field, a rejected event type, or a bad time range.Read the errors detail and fix the request.
401Authentication failed: missing header or unknown key.Verify the key is valid, active, and being sent in the Authorization header.
403Authenticated but not allowed: wrong project, or a route that requires an owner or admin.Check the key belongs to the project or escalate the role.
404Resource not found in the project.Confirm the id and the project scope.
429Rate limited. Single ingestion is 1000/min; batch ingestion is 100/min.Back off for the Retry-After value or retryAfter on RateLimitError.
500Unexpected server error.Retry with backoff. If it persists, contact support.

Handling errors

Treat rate limits as expected: back off, then retry the same work. The retry window is provided for you.

typescript
import { Vanta, RateLimitError } from '@vanta-dev/node'

const vanta = new Vanta({ apiKey: process.env.VANTA_API_KEY })

try {
  await vanta.track({ event: 'x', userId: '1' })
} catch (err) {
  if (err instanceof RateLimitError) {
    await new Promise((resolve) => setTimeout(resolve, err.retryAfter * 1000))
  }
}

Other SDK failures arrive as VantaError. Catch it to read statusCode and code before deciding whether to retry.