Deleting a person's data

When someone asks you to delete their data, or to see it, do it in datacub too: from their profile in the dashboard, or from your backend.

You decide when a request is valid; datacub does the work. Only owners and admins, signed in as themselves, can do it from the dashboard.

From the dashboard

Open the person on the Users page and choose Delete this person's data, then Delete for good. It works for a Registered user and for a Guest.

From your backend

Call datacub from your server when your own account deletion runs, so both happen together. Use a read key (rk_) of the workspace that an owner has allowed to handle person requests; the project ID is in Settings, General. Make one with New read key under Read keys in Settings, Integrations; it is shown once.

A read key reads reports by default. To let it delete and export people, an owner turns on Can delete and export a person's data for that key, under Read keys in Settings, Integrations. Without it every call below answers 403 capability_required.

delete-from-x.ts
// on your server only: a read key opens your dashboard, never ship it to a browser or app
export async function deleteFromX(userId: string) {
  const url = `https://YOUR_DATACUB_HOST/api/backend/projects/${process.env.DATACUB_PROJECT_ID}/persons/user/${encodeURIComponent(userId)}`
  const res = await fetch(url, {
    method: 'DELETE',
    headers: { Authorization: `Bearer ${process.env.DATACUB_READ_KEY}` },
  })
  if (res.status !== 202) throw new Error(`datacub deletion failed: ${res.status}`)
  return (await res.json()) as { id: string; status: 'deleted' | 'held' }
}
PathDeletes
DELETE /api/backend/projects/:id/persons/user/:userIda Registered user, by the ID you pass to identify, and every browser and phone linked to them
DELETE /api/backend/projects/:id/persons/browser/:anonIda Guest, by the ID in the datacub_id_<key> cookie

The answer is 202 with { "id": "...", "status": "deleted" }, or "held" during a legal hold.

ErrorMeans
401 unauthenticatedthe key is wrong or revoked, or not of this project's workspace
403 capability_requiredan owner has not allowed this key to handle person requests
400 invalid_personthe ID is not one datacub can hold
429 rate_limitedover 60 calls a minute for this key; wait a minute

Exporting a person's data

When someone asks what you hold about them, get everything datacub holds in one JSON file:

export-from-x.ts
export async function exportFromX(userId: string) {
  const url = `https://YOUR_DATACUB_HOST/api/backend/projects/${process.env.DATACUB_PROJECT_ID}/persons/user/${encodeURIComponent(userId)}/export`
  const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.DATACUB_READ_KEY}` } })
  if (!res.ok) throw new Error(`datacub export failed: ${res.status}`)
  return (await res.json()) as { format: 'datacub.person_export.v1'; traits: Record<string, unknown>; events: unknown[] }
}

The file holds their user ID and linked browsers, their latest traits (name, email, phone and others), their consent events, every event with its properties, their feedback answers, and how many notes your team keeps about them (not the notes' words). Each export is recorded in your workspace's audit log, without the person's ID. The same works for a Guest: persons/browser/:anonId/export.

If a user withdraws consent somewhere your backend sees (an account setting, a support request), report it. datacub deletes what it collected, the same way:

revoke-in-x.ts
// anon_id is the Guest ID from the datacub_id_<key> cookie (<key>: 8 characters of your pk_ key after pk_live_) your own server receives; or send user_id
export async function revokeInX(who: { user_id: string } | { anon_id: string }) {
  const url = `https://YOUR_DATACUB_HOST/api/backend/projects/${process.env.DATACUB_PROJECT_ID}/consent/revoke`
  const res = await fetch(url, {
    method: 'POST',
    headers: { Authorization: `Bearer ${process.env.DATACUB_READ_KEY}`, 'Content-Type': 'application/json' },
    body: JSON.stringify(who),
  })
  if (res.status !== 202) throw new Error(`datacub revoke failed: ${res.status}`)
}

In the browser, also call datacub.consent.revoke() so the SDK stops and clears its cookies (consent).

What is deleted, and when

At once: the person's events and traits, the links between their browsers, phones and user ID, your notes about them, their feedback answers and the records of who viewed their profile. They leave every report, funnel and profile immediately.

48 hours later: datacub deletes again, to catch events that were still on their way, and removes the rows from storage for good. Backups that held them expire within 35 days. After that datacub keeps only a one-way hash of the ID, to prove the request was done and to repeat it if a backup is ever restored.

datacub's own limits for every request: unlinked within 1 hour, out of every answer within 7 days, removed from storage within 30 days.

If datacub is required by law to keep a project's data, for example by a court order, the project is under a legal hold. Requests are still accepted and recorded, answered held, and carried out as soon as the hold is lifted.

New events after a deletion

datacub stops accepting events for a deleted user ID, so a page left open cannot bring the person back. A deleted Guest ID is refused for 30 days.

If the same person signs up again and you want to track them, allow their user ID again:

curl -X DELETE "https://YOUR_DATACUB_HOST/api/backend/projects/$DATACUB_PROJECT_ID/tombstones/user/user_8f3a2c" \
  -H "Authorization: Bearer $DATACUB_READ_KEY"

Only what they do from then on is collected; nothing deleted comes back.