Skip to content
VaultLens Studio

HIPAA workspaces

In a HIPAA workspace, record values are treated as protected health information (PHI). The API is the same, with three extra controls on keys: they must expire, reading record values needs a separate scope, and every call is audited. See HIPAA for how VaultLens handles HIPAA workspaces in general.

To check whether a workspace is a HIPAA workspace, call GET /me and read workspace.hipaa:

{
  "workspace": { "id": "Wk7dQ2mFz9LpT4xR8bN1", "name": "Clinic", "hipaa": true },
  "key": {
    "id": "k7",
    "name": "Nightly export",
    "prefix": "vls_Hq7Xk2Pa",
    "scopes": ["read", "data:query", "phi:read"],
    "appIds": ["6b05a32b031b09796ccc7d52"],
    "expiresAt": "2027-03-01T18:00:00.000Z"
  },
  "plan": { "id": "business", "standing": "ok", "analytics": true, "archive": true },
  "rateLimitPerMinute": 300
}

Keys must expire

New keys in a HIPAA workspace must expire within 365 days. In Settings → API keys → Create key, the Expires list offers In 30 days, In 90 days (the default) and In 1 year, with no Never. After the expiry date the key returns 401 UNAUTHENTICATED (“This API key has expired.”).

Plan for renewal: watch key.expiresAt from GET /me, and before it passes either create a new key or click Rotate. Rotating issues a new key with the same scopes, apps, IP addresses and expiry period (counted from the rotation), and the old key stops working at once.

Also recommended for HIPAA workspaces:

  • Limit each key to the apps it needs (Apps).
  • Limit it to your servers’ addresses (Only from these IP addresses). Calls from elsewhere get 403 PERMISSION_DENIED.
  • Give each integration its own key, so you can revoke one without affecting the others, and so the audit log shows which integration made each call.

The phi:read scope

Endpoints that return record values, or that find records by their values, need phi:read on top of their usual scope:

Endpoint Scopes in a HIPAA workspace
GET /apps/<appId>/tables/<table>/records data:query and phi:read
GET /archive-runs/<runId>/files/<fileId>/download data:query and phi:read
GET /apps/<appId>/archive/lookup read and phi:read

Without it, these return 403 PERMISSION_DENIED with “This is a HIPAA workspace: reading record values needs the “phi:read” scope.” Every other endpoint (apps, schema, jobs, sync status, archive settings and runs) returns ids, names, counts and times only, and works without phi:read.

Read PHI (phi:read) is only offered when creating keys in HIPAA workspaces. Outside one, a key can’t be given it.

HIPAA workspaces can’t save archive files in the Knack app or in Google Drive or OneDrive, only in your own cloud bucket (Google Cloud Storage, Amazon S3 or Azure). VaultLens can write to a bucket but not read from it, so for those runs the files show downloadable: false and the download endpoint returns 409 UPLOAD_REQUIRED with the file’s location. Fetch archive files from your bucket directly. See archive via the API.

curl

# A HIPAA-workspace key with data:query and phi:read.
curl -s -G "https://api.vaultlens.studio/v1/apps/<appId>/tables/object_1/records" \
  -H "Authorization: Bearer $VAULTLENS_API_KEY" \
  --data-urlencode "limit=100"

Node

// Check the key before a job that reads PHI, so a missing scope or a near expiry fails early.
const BASE = 'https://api.vaultlens.studio/v1';
const headers = { Authorization: `Bearer ${process.env.VAULTLENS_API_KEY}` };

const me = await (await fetch(`${BASE}/me`, { headers })).json();
if (me.workspace.hipaa) {
  for (const scope of ['data:query', 'phi:read'])
    if (!me.key.scopes.includes(scope)) throw new Error(`This key needs the ${scope} scope.`);
  const daysLeft = (Date.parse(me.key.expiresAt) - Date.now()) / 86_400_000;
  if (daysLeft < 14)
    console.warn(`API key ${me.key.prefix} expires in ${Math.floor(daysLeft)} days.`);
}

const res = await fetch(`${BASE}/apps/<appId>/tables/object_1/records?limit=100`, { headers });
const page = await res.json();
if (!res.ok) throw new Error(`${page.error.code}: ${page.error.message} (${page.error.requestId})`);
console.log(`${page.data.length} rows`);

Python

import datetime
import os

import requests

BASE = "https://api.vaultlens.studio/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['VAULTLENS_API_KEY']}"}

me = requests.get(f"{BASE}/me", headers=HEADERS, timeout=30).json()
if me["workspace"]["hipaa"]:
    missing = {"data:query", "phi:read"} - set(me["key"]["scopes"])
    if missing:
        raise RuntimeError(f"This key needs: {', '.join(sorted(missing))}")
    expires = datetime.datetime.fromisoformat(me["key"]["expiresAt"].replace("Z", "+00:00"))
    days_left = (expires - datetime.datetime.now(datetime.timezone.utc)).days
    if days_left < 14:
        print(f"API key {me['key']['prefix']} expires in {days_left} days")

res = requests.get(
    f"{BASE}/apps/<appId>/tables/object_1/records",
    params={"limit": 100},
    headers=HEADERS,
    timeout=60,
)
page = res.json()
if not res.ok:
    raise RuntimeError(f"{page['error']['code']}: {page['error']['message']} ({page['error']['requestId']})")
print(len(page["data"]), "rows")

Every call is audited

In a HIPAA workspace, every API call made with a valid key is written to the workspace’s audit log as an API call entry, whether the call succeeded or not. (Requests refused before the key is recognised, such as a wrong key or a disallowed IP address, have no key to record.) Each entry records:

  • the key (by name and id) as the actor;
  • the method and path, for example GET /v1/apps/6b05a32b031b09796ccc7d52/tables/object_1/records;
  • the response status and the request id.

Query strings aren’t recorded, because filter values can be PHI. Send your own X-Request-Id (see errors and rate limits) to match audit entries to your logs.

In every workspace, HIPAA or not, reading records and downloading archive files add their own audit entries too (the table and row count, or the file; never the values). Key creation, rotation and revocation are audited as well.

Owners and admins see the log in Settings → Audit log, can filter it and use Export CSV. Entries can’t be edited or deleted and are kept for at least 6 years.

Webhooks

Webhook payloads contain ids and event types only, never record values, so they carry no PHI. Verify them as described in webhooks.