Skip to content
VaultLens Studio

Read the analytics copy

GET /apps/<appId>/tables/<table>/records reads records from the app’s analytics copy (your hosted or own Postgres, or BigQuery), not from Knack. It uses none of your Knack API budget, so it suits reporting jobs and exports that run often. See the analytics overview for how the copy is kept up to date.

What you need:

  • A key with the data:query scope (plus phi:read in HIPAA workspaces).
  • Analytics set up for the app, with its first clone finished. Otherwise you get 409 FAILED_PRECONDITION (“This app has no analytics destination yet.” or “The first copy of this app hasn’t run yet.”).
  • The table included in analytics. Other tables return 404 NOT_FOUND.

Every call is recorded in the workspace’s audit log (the table and the number of rows, never the values).

Find the table and its columns

<table> is the Knack object key, such as object_1. Get the keys from GET /apps/<appId>/schema (objects[].key and objects[].name). GET /apps/<appId>/workflows lists the tables included in analytics under analytics.tables.

Column names are the copy’s column names, not Knack field keys. Each response lists them in columns, with the Knack field each came from. A first call with limit=1 is a cheap way to see them.

Read a page of records

Query parameter What it does
filter A JSON array of conditions, all of which must match (see below). URL-encode it.
sort A column name for ascending, -column for descending. Default id. Ignored with updatedSince.
updatedSince ISO 8601 date-time: only rows VaultLens wrote at or after this time (see changed since).
limit Rows per page, 1 to 1000. Default 100.
cursor The previous page’s nextCursor.

The response:

{
  "table": "customers",
  "columns": [
    {
      "column": "id",
      "type": "text",
      "fieldKey": null,
      "fieldName": "Record ID",
      "fieldType": "id"
    },
    {
      "column": "name",
      "type": "text",
      "fieldKey": "field_1",
      "fieldName": "Name",
      "fieldType": "name"
    },
    {
      "column": "status",
      "type": "text",
      "fieldKey": "field_7",
      "fieldName": "Status",
      "fieldType": "multiple_choice"
    }
  ],
  "data": [
    {
      "id": "5f1c0e9a2b3c4d5e6f708192",
      "name": "Ada Lovelace",
      "status": "Open",
      "_synced_at": "2026-12-01T16:58:12.000Z",
      "_archived_at": null
    }
  ],
  "nextCursor": "eyJrIjoiaWQiLCJpZCI6IjVmMWMwZTlh..."
}
  • table is the table’s name in your database.
  • Each row has the data columns plus _synced_at (when VaultLens last wrote the row) and _archived_at (when the record was archived from Knack, or null). Archived records stay in the copy; records deleted in Knack don’t appear.
  • nextCursor is null on the last page. Cursors are opaque: pass them back unchanged, with the same filter, sort and updatedSince.

Filters

filter is a JSON array of up to 20 conditions, ANDed together:

[
  { "column": "status", "op": "eq", "value": "Open" },
  { "column": "total", "op": "gte", "value": 100 },
  { "column": "closed_on", "op": "is_null" }
]
op Matches
eq, ne Equal, not equal
gt, gte, lt, lte Greater than, at least, less than, at most
contains The value appears in the column, ignoring case
is_null, not_null The column is empty, or not (no value)

value is a string, number or boolean. Columns that hold lists or objects (JSON or array types in columns[].type) only take contains, is_null and not_null. An unknown column, an operator a column can’t take, or a value that doesn’t fit the column’s type returns 400 INVALID_ARGUMENT with a message saying which.

Sorting and paging

Sorting by id (the default) or _synced_at pages by keyset, so you can page through any number of rows. Sorting by any other column pages by offset, which stops after 100,000 rows: past that, nextCursor comes back null. For bigger tables, narrow the rows with filter, or sort by id.

curl

# -G with --data-urlencode puts the parameters in the query string, encoded.
curl -s -G "https://api.vaultlens.studio/v1/apps/<appId>/tables/object_1/records" \
  -H "Authorization: Bearer $VAULTLENS_API_KEY" \
  --data-urlencode 'filter=[{"column":"status","op":"eq","value":"Open"}]' \
  --data-urlencode 'sort=-_synced_at' \
  --data-urlencode 'limit=500'

Node

// Reads every open record, page by page.
const BASE = 'https://api.vaultlens.studio/v1';
const auth = { Authorization: `Bearer ${process.env.VAULTLENS_API_KEY}` };

async function* records(appId, table, params) {
  let cursor;
  do {
    const url = new URL(`${BASE}/apps/${appId}/tables/${table}/records`);
    for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
    if (cursor) url.searchParams.set('cursor', cursor);
    const res = await fetch(url, { headers: auth });
    const page = await res.json();
    if (!res.ok) throw new Error(`${page.error.code}: ${page.error.message}`);
    yield* page.data;
    cursor = page.nextCursor;
  } while (cursor);
}

let n = 0;
for await (const row of records('<appId>', 'object_1', {
  filter: JSON.stringify([{ column: 'status', op: 'eq', value: 'Open' }]),
  limit: '1000',
})) {
  n++;
}
console.log(`${n} open records`);

Python

import json
import os

import requests

BASE = "https://api.vaultlens.studio/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['VAULTLENS_API_KEY']}"


def records(app_id, table, **params):
    """Yields every row matching params, following nextCursor."""
    cursor = None
    while True:
        query = dict(params, cursor=cursor) if cursor else params
        res = session.get(f"{BASE}/apps/{app_id}/tables/{table}/records", params=query, timeout=60)
        page = res.json()
        if not res.ok:
            raise RuntimeError(f"{page['error']['code']}: {page['error']['message']}")
        yield from page["data"]
        cursor = page["nextCursor"]
        if not cursor:
            return


rows = records(
    "<appId>",
    "object_1",
    filter=json.dumps([{"column": "status", "op": "eq", "value": "Open"}]),
    limit=1000,
)
print(sum(1 for _ in rows), "open records")

Pull only what changed

To keep your own copy or warehouse up to date without reading whole tables, pass updatedSince:

  1. The first time, read the whole table sorted by _synced_at (sort=_synced_at), so the last row you get is the most recently written one. Upsert each row by id.
  2. Keep the last row’s _synced_at.
  3. Next time, pass that value as updatedSince. You get rows VaultLens wrote at or after it, oldest first by _synced_at (sort is ignored), paged with cursor as usual. Upsert them and keep the last row’s _synced_at again.

Because the comparison is “at or after”, the rows at the boundary come back again on the next run. Upserting by id makes that harmless.

Things an incremental pull doesn’t show:

  • Deletions. Records deleted in Knack drop out of the results rather than coming back with a marker. To catch them, compare ids with a full read now and then.
  • Archiving. Archiving a record sets _archived_at but doesn’t change _synced_at, so a record archived after your last pull isn’t returned again. A periodic full read picks up the new _archived_at values.

curl

curl -s -G "https://api.vaultlens.studio/v1/apps/<appId>/tables/object_1/records" \
  -H "Authorization: Bearer $VAULTLENS_API_KEY" \
  --data-urlencode "updatedSince=2026-12-01T16:58:12.000Z" \
  --data-urlencode "limit=1000" | jq '{rows: (.data | length), last: .data[-1]._synced_at, nextCursor}'

Node

import { readFile, writeFile } from 'node:fs/promises';

const BASE = 'https://api.vaultlens.studio/v1';
const auth = { Authorization: `Bearer ${process.env.VAULTLENS_API_KEY}` };
const STATE = 'last-synced-at.txt';

const since = (await readFile(STATE, 'utf8').catch(() => '')).trim();
let cursor = null;
let last = since;
do {
  const url = new URL(`${BASE}/apps/<appId>/tables/object_1/records`);
  url.searchParams.set('limit', '1000');
  // First run: everything, oldest write first. Later runs: only what changed.
  if (since) url.searchParams.set('updatedSince', since);
  else url.searchParams.set('sort', '_synced_at');
  if (cursor) url.searchParams.set('cursor', cursor);
  const res = await fetch(url, { headers: auth });
  const page = await res.json();
  if (!res.ok) throw new Error(`${page.error.code}: ${page.error.message}`);
  for (const row of page.data) {
    // upsert row by row.id into your store here
    last = row._synced_at;
  }
  cursor = page.nextCursor;
} while (cursor);
if (last) await writeFile(STATE, last);

Python

import os
import pathlib

import requests

BASE = "https://api.vaultlens.studio/v1"
AUTH = {"Authorization": f"Bearer {os.environ['VAULTLENS_API_KEY']}"}
state = pathlib.Path("last-synced-at.txt")

since = state.read_text().strip() if state.exists() else ""
last = since
cursor = None
while True:
    # First run: everything, oldest write first. Later runs: only what changed.
    params = {"limit": 1000, **({"updatedSince": since} if since else {"sort": "_synced_at"})}
    if cursor:
        params["cursor"] = cursor
    res = requests.get(
        f"{BASE}/apps/<appId>/tables/object_1/records", params=params, headers=AUTH, timeout=60
    )
    page = res.json()
    if not res.ok:
        raise RuntimeError(f"{page['error']['code']}: {page['error']['message']}")
    for row in page["data"]:
        # upsert row by row["id"] into your store here
        last = row["_synced_at"]
    cursor = page["nextCursor"]
    if not cursor:
        break
if last:
    state.write_text(last)

For SQL access to the same data, connect to the database directly or use VaultLens for AI. The API reference lists every field of this endpoint.