Skip to content
VaultLens Studio

Errors and rate limits

Error format

Every error is JSON with a stable code, a message you can show to a person, and the request’s id:

{
  "error": {
    "code": "PERMISSION_DENIED",
    "message": "This key needs the “write” scope.",
    "requestId": "req_Q2x1c3RlcjE2Ynl0ZXM"
  }
}

Branch on code and the HTTP status, not on message: messages can be reworded.

Statuses and codes

Status Common codes Meaning
400 INVALID_ARGUMENT, CONFIRMATION_REQUIRED, FILE_MISMATCH The request isn’t valid. message names the parameter, for example limit: a whole number from 1 to 200.
401 UNAUTHENTICATED No key, or it’s mistyped, revoked or expired, or its creator is no longer an owner or admin.
402 PLAN_REQUIRED, PLAN_LIMIT The workspace’s plan doesn’t include this, or a plan limit (apps, records) is reached.
403 PERMISSION_DENIED The key lacks the scope, the app, or the IP address for this call.
404 NOT_FOUND No such endpoint, app, job, run, setting or table.
405 METHOD_NOT_ALLOWED The path exists but not with this method.
409 JOB_ACTIVE, FAILED_PRECONDITION, UPLOAD_REQUIRED Conflicts with the current state: a job is already running, the app has no analytics destination yet, or an archive file is in your own bucket.
422 IDEMPOTENCY_MISMATCH An Idempotency-Key was reused for a different request.
429 RATE_LIMITED, BUDGET_EXHAUSTED Too many requests for this key this minute, or the app’s Knack API budget is used up for today. Both come with Retry-After.
500 INTERNAL Something went wrong on VaultLens’s side. Retry later, and quote the request id if it persists.
503 varies A service VaultLens depends on is unavailable. Retry later.

Other codes from the same service layer as the app can appear, for example KNACK_API_KEY_INVALID or DESTINATION_UNREACHABLE when a call reaches Knack or your database. Their messages explain what to fix. The API reference lists the error responses for each endpoint.

Rate limits

Each key may make a set number of requests per minute, by the workspace’s plan:

Plan Requests per minute, per key
Analytics 60
Archive 60
Studio 120
Business 300

GET /me returns your key’s limit as rateLimitPerMinute. The window is the calendar minute. Every keyed request counts, including ones that fail with 403 and idempotent replays. Every keyed response carries:

Header Value
X-RateLimit-Limit Requests allowed per minute.
X-RateLimit-Remaining Requests left in this minute.
X-RateLimit-Reset Seconds until the minute ends.

Over the limit you get 429 RATE_LIMITED with Retry-After (seconds). Wait that long before the next request.

The rate limit is separate from your Knack API budget. Work that reaches Knack spends the app’s daily Knack budget, as it does in the app. Clones, syncs and archive runs spend it as they run, and pause as paused_budget when it’s used up, carrying on after it resets (midnight UTC). Calls that ask Knack something straight away, such as an archive dry run or downloading an archive file stored in Knack, return 429 BUDGET_EXHAUSTED instead, with Retry-After set to the seconds until the reset. Reading the analytics copy uses no Knack budget.

Retry posts safely with Idempotency-Key

A network error can leave you not knowing whether a POST took effect. To make retries safe, send an Idempotency-Key header (up to 200 characters, unique per operation, for example a UUID or nightly-sync-2026-12-01).

  • Repeating the same request (same key, method, path and body) with the same Idempotency-Key within 24 hours returns the first response, with the header Idempotent-Replayed: true. The work isn’t started again.
  • Reusing an Idempotency-Key with a different path or body returns 422 IDEMPOTENCY_MISMATCH.
  • Only successful responses are stored. If the first attempt failed (a 409, say), a retry with the same key runs the request again.
  • Keys are scoped to the API key that sent them.

Idempotency-Key applies to POST only. GET, PATCH and DELETE requests don’t use it.

Request ids

Every response, success or error, has an X-Request-Id header, and errors repeat it as error.requestId. Log it, and quote it when you contact support. You can send your own X-Request-Id (8 to 64 letters, digits, ., _ or -) to tie a call to your logs; VaultLens uses it instead of generating one. Anything else is ignored and a new id is generated.

A retrying client

These helpers retry 429 responses after Retry-After, and network errors and 5xx responses with backoff. They send the same Idempotency-Key on each attempt of a POST, so a retry can’t start the work twice, and their own X-Request-Id so attempts are easy to find in logs. They give up after a few attempts and raise the API’s error.

curl

# --retry retries 408, 429, 500, 502, 503 and 504, and waits for Retry-After when it's sent.
# Keep the same Idempotency-Key and X-Request-Id on every attempt.
curl -sS --retry 4 --retry-max-time 300 -X POST \
  "https://api.vaultlens.studio/v1/apps/<appId>/reconcile" \
  -H "Authorization: Bearer $VAULTLENS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "X-Request-Id: nightly-sync-0001" \
  -D - -o response.json

-D - prints the response headers, including X-Request-Id, X-RateLimit-Remaining and Idempotent-Replayed. Generate the Idempotency-Key once, outside any retry loop of your own.

Node

import { randomUUID } from 'node:crypto';

const BASE = 'https://api.vaultlens.studio/v1';

export async function vaultlens(method, path, { body, attempts = 4 } = {}) {
  const headers = {
    Authorization: `Bearer ${process.env.VAULTLENS_API_KEY}`,
    'X-Request-Id': `job-${randomUUID()}`,
  };
  if (method === 'POST') headers['Idempotency-Key'] = randomUUID(); // same on every attempt
  if (body !== undefined) headers['Content-Type'] = 'application/json';

  for (let attempt = 1; ; attempt++) {
    let res;
    try {
      res = await fetch(BASE + path, {
        method,
        headers,
        body: body === undefined ? undefined : JSON.stringify(body),
      });
    } catch (err) {
      if (attempt >= attempts) throw err;
      await sleep(2 ** attempt * 1000);
      continue;
    }
    if (res.ok) return res.status === 204 ? null : res.json();

    const retryable = res.status === 429 || res.status >= 500;
    if (retryable && attempt < attempts) {
      const wait = Number(res.headers.get('Retry-After')) || 2 ** attempt;
      await sleep(wait * 1000);
      continue;
    }
    const err = (await res.json().catch(() => null))?.error;
    throw Object.assign(new Error(err?.message ?? `HTTP ${res.status}`), {
      status: res.status,
      code: err?.code,
      requestId: err?.requestId ?? res.headers.get('X-Request-Id'),
    });
  }
}

const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

// Example: start a sync.
const { jobId } = await vaultlens('POST', '/apps/<appId>/reconcile');
console.log(jobId);

A BUDGET_EXHAUSTED 429 can have a Retry-After of hours. In a real client, give up when the wait is longer than you’re willing to block, and try again later.

Python

import os
import time
import uuid

import requests

BASE = "https://api.vaultlens.studio/v1"


class VaultLensError(Exception):
    def __init__(self, status, code, message, request_id):
        super().__init__(f"{status} {code}: {message} ({request_id})")
        self.status, self.code, self.request_id = status, code, request_id


def vaultlens(method, path, json_body=None, attempts=4):
    headers = {
        "Authorization": f"Bearer {os.environ['VAULTLENS_API_KEY']}",
        "X-Request-Id": f"job-{uuid.uuid4()}",
    }
    if method == "POST":
        headers["Idempotency-Key"] = str(uuid.uuid4())  # same on every attempt

    for attempt in range(1, attempts + 1):
        try:
            res = requests.request(method, BASE + path, json=json_body, headers=headers, timeout=60)
        except requests.ConnectionError:
            if attempt == attempts:
                raise
            time.sleep(2**attempt)
            continue
        if res.ok:
            return res.json() if res.content else None
        if (res.status_code == 429 or res.status_code >= 500) and attempt < attempts:
            time.sleep(int(res.headers.get("Retry-After", 2**attempt)))
            continue
        try:
            err = res.json()["error"]
        except ValueError:
            err = {"code": f"HTTP_{res.status_code}", "message": res.text}
        raise VaultLensError(
            res.status_code,
            err["code"],
            err["message"],
            err.get("requestId", res.headers.get("X-Request-Id")),
        )


if __name__ == "__main__":
    print(vaultlens("POST", "/apps/<appId>/reconcile")["jobId"])

To get a typed client instead of hand-written calls, see client libraries.