Rovenue SDKBeta
Guides

Self-Service DSAR API

Let your own backend fulfil GDPR/KVKK subject-access and erasure requests for your end users, without a support ticket to Rovenue — five secret-key endpoints, what each one actually does, and what it doesn't.

A data-subject access request (export) or right-to-erasure request (erasure) is something your backend asks Rovenue on behalf of one of your own end users. Rovenue never authenticates that end user itself — your backend already did that, however your own auth works, before it ever calls this API.

Every route below requires your secret key (Authorization: Bearer <rov_sk_live_…>), never the public key. These are server-to-server calls only. A public key reaching /v1/dsar/erasure would let anyone holding your client bundle erase someone else's subscriber — the secret-key requirement is the whole reason this is safe to expose.

The five endpoints

Method & pathWhat it does
POST /v1/dsar/exportStarts (or returns the already-running) export for one subscriber.
POST /v1/dsar/erasureStarts (or returns the already-running) erasure for one subscriber.
GET /v1/dsar/:idPolls the status of a request you started.
GET /v1/dsar/:id/downloadStreams a completed export's artifact.
POST /v1/dsar/:id/retryRuns a FAILED request again, under the same id.

Starting a request

POST /v1/dsar/export
Authorization: Bearer <rov_sk_live_…>
Content-Type: application/json

{
  "appUserId": "rov_01h...",
  "requestedBy": "support-ticket-4821"
}

POST /v1/dsar/erasure takes the identical body shape.

appUserId accepts either identifier you hold for the subscriber: the rovenueId your SDK already has on hand (user.rovenueId from identifying users), or the app user id you passed to identify() — the one your own backend knows. The rovenueId is tried first. When that app user was later merged into another subscriber (a transfer, or an identify() on a second device), the request lands on the surviving subscriber, which is where their data now lives. A value that was never sent to Rovenue as either identifier resolves to nothing: 404 with error.code SUBSCRIBER_NOT_FOUND, the same answer every secret-key subscriber lookup gives.

requestedBy is a free-text string your backend supplies to record who or what asked (a ticket id, an admin's email, an internal case number). Rovenue doesn't validate it against anything — it exists purely so the audit trail says who initiated the request, not just that one happened.

The subscriber is always resolved inside your own project — there is no projectId field to fill in, and none would be trusted if you sent one. The secret key itself determines which project's subscribers you can reach.

Both calls respond with the request record:

{
  "data": {
    "request": {
      "id": "dsr_01h...",
      "type": "EXPORT",
      "status": "PENDING",
      "requestedBy": "support-ticket-4821",
      "createdAt": "2026-09-06T12:00:00.000Z",
      "updatedAt": "2026-09-06T12:00:00.000Z",
      "completedAt": null,
      "expiresAt": null,
      "error": null,
      "downloadReady": false
    }
  }
}

status moves PENDING → RUNNING → COMPLETED | FAILED. The actual work runs on a background queue — this call only enqueues it and returns immediately; poll GET /v1/dsar/:id for the outcome. An erasure whose attempt fails goes back to PENDING, with that attempt's failure in error, and runs again on its own (see When an erasure fails); error is cleared when it completes.

Retrying is safe — it never starts a second job

If your backend calls POST /v1/dsar/export again for the same subscriber while an export is still PENDING or RUNNING, you get back the same request record, not a new one — same id, same status. No second export runs, and no second job is enqueued. This holds whether the retry is deliberate (your backend re-asking) or accidental (a timeout that makes you unsure the first call landed): it is always safe to call POST /v1/dsar/export or POST /v1/dsar/erasure again for a subscriber you're not sure already has an open request.

This retry is also what makes a request recoverable if your very FIRST call returned a 5xx instead of 200: the request record may still have been created even though the response failed. Calling the identical endpoint again finds that record and makes sure its background job actually got scheduled — creating it if the very first attempt never reached the queue — before handing back the same record. You never need a separate "did my request actually get picked up" check; the same retry you'd make anyway does that healing for you.

Once a request reaches COMPLETED or FAILED, the next call for that subscriber and type starts a genuinely new one — export is a point-in-time snapshot, not a subscription. Asking again after a completed export runs a fresh export and produces a new artifact; it does not "refresh" the old one or extend its download window.

That new call needs the subscriber to resolve, and an erased subscriber does not: once the erasure's first step has run, its app user id and rovenueId are gone, so POST /v1/dsar/erasure for it answers 404. A FAILED erasure is therefore run again by its own id, with POST /v1/dsar/:id/retry — see When an erasure fails.

Checking status and downloading

GET /v1/dsar/:id
Authorization: Bearer <rov_sk_live_…>

Returns the same request shape as above. downloadReady is true only once status is COMPLETED, an artifact exists, and it hasn't expired yet — check it before calling the download route rather than parsing status yourself.

GET /v1/dsar/:id/download
Authorization: Bearer <rov_sk_live_…>

There is no shareable download link. This route streams the artifact directly, authenticated by your secret key on every call — there is no signed URL, no token you can hand to someone else, nothing to copy into an email. If your own product needs to hand the export to the end user, your backend fetches it from this route and relays it onward itself.

The response is a raw stream (Content-Type: application/octet-stream) — not a JSON envelope. A request that isn't COMPLETED, has no artifact, or whose export has expired returns 404, checked before any bytes are sent.

Both GET routes 404 identically for "no such request" and "that request belongs to another project" — a probing caller can't tell the difference between an id that doesn't exist and one that belongs to somebody else.

Rate limits

POST /v1/dsar/export and POST /v1/dsar/erasure share one budget of 5 requests per minute, keyed to your API key — not 5 each. An export runs a multi-table read across a subscriber's full history, so this budget is deliberately tighter than other secret-key endpoints. GET /v1/dsar/:id and GET /v1/dsar/:id/download aren't separately throttled; they fall under the ordinary per-key envelope every /v1 call already shares (500 requests/minute).

What an export contains, and how long it lasts

An export is a point-in-time JSON snapshot of everything Rovenue holds on that subscriber — not a subscription, and not something that stays in sync with later activity. It covers every record merged into the subscriber too (an anonymous install later identified, a transfer): mergedSubscribers lists those records, and the purchases, entitlements, credit ledger and credit lots include their rows — a merge leaves the earlier record's credit-ledger entries, including its TRANSFER_OUT, where they were. Once you have it, it reflects that moment; a subscriber's next purchase or attribute change isn't reflected until you request a new export.

The completed artifact is downloadable for 30 days from completion (expiresAt on the request record); after that, GET /v1/dsar/:id/download refuses it, but the object itself stays in storage — access is gated by the timestamp, not by removal. No scheduled sweep deletes it: the artifact stays until the subscriber it belongs to is erased (which deletes it outright, regardless of how much of the 30 days is left — see below) or the project is deleted (which purges the project's whole dsar-exports/<projectId>/ prefix).

If a subscriber is erased while their own export is still PENDING or RUNNING (queued before the erasure, or picked back up after it), that export fails instead of completing, and the request record never gains a downloadable artifact. Requesting a NEW export for a subscriber who has already been erased fails the same way, immediately, at the POST /v1/dsar/export call itself. Either way, no export can hand back data for a subject who has been erased.

One nuance, because "fails" hides it: if the erasure lands in the narrow window after the export has already read the subject's data, the artifact has been written to storage by then. Rovenue deletes it before failing the request, and the two operations take a database row lock on the subscriber so they cannot interleave — whichever finishes first, the other sees it. The residual case is a storage error during that delete: the request still fails and the artifact is unreachable through this API, but the object itself can survive in the bucket, and no sweep will remove it.

What erasure actually does

Erasure anonymises the subscriber row — it does not delete it. The row's own id survives, its appUserId is replaced with a deterministic, non-reversible token, its attributes are cleared, and it's stamped deletedAt. Keeping the row (rather than deleting it outright) is what lets the append-only credit_ledger keep its guarantee: every ledger entry that ever referenced this subscriber still resolves to a real row, just one that no longer identifies anyone.

Erasure also retires the device id: the erased subscriber's rovenueId (and the rovenueId of every record merged into it) is replaced with a reserved erased_... value, so it can never be presented again. A device that keeps using the app after erasure is treated like a new install: its next request creates a new, empty subscriber with no link to the erased one. Records erased before this behaviour existed heal the same way, on the device's first request of any kind.

Erasure does not cancel the customer's App Store or Play subscription: neither store lets anyone but the customer cancel it, so the store keeps billing them until they cancel it in their own App Store or Google Play subscription settings. Tell the customer so when you confirm the erasure. If the same customer presents the receipt of that subscription again (a purchase, a restore or a sync), Rovenue re-attaches it to whoever presents it, whatever the project's Handling multiple app user IDs setting says, because the erased subscriber has no account left to protect. The purchase, its access and its later renewals, expiries and refunds then belong to the new subscriber. Until a receipt claims it, store notifications for that purchase stay quarantined and are not recorded. Your webhook sees the move as a subscriber.purchase_transferred event with fromSubscriberId and behavior set to null and reason set to previous_owner_erased, so the event never names the erased subscriber. One exception: if part of the same purchase sits on a live customer and the setting refuses moving it from them (Keep with original app user ID, or Transfer if there are no active subscriptions while it is active), the receipt is refused with 409 and nothing moves — the live customer keeps its part and the erased subscriber's part stays where it is. Stripe purchases are different: erasure cancels the subscriber's Stripe subscriptions (see Stripe subscriptions).

Erasure also deletes every artifact from any of the subscriber's OWN prior exports — every dsar-exports/... object this subscriber's completed POST /v1/dsar/export calls ever produced, not just the most recent one. Postgres anonymisation alone would not be enough: it never touches purchases, entitlements, or the credit ledger, and an already-downloaded export snapshot still has all of that under the subscriber's real, pre-erasure identity. After erasure, GET /v1/dsar/:id/download for any of that subscriber's own past export requests returns 404 — the request record itself still shows COMPLETED (the export genuinely did complete, at the time), but it no longer has anything to serve.

Erasure also purges the subscriber's rows (and those of every record merged into it) from every ClickHouse table that stores a plain, queryable subscriber id at rest:

  • raw_exposures
  • raw_revenue_events
  • raw_credit_ledger
  • raw_sdk_session_events
  • raw_funnel_events
  • subscriber_alias

Because of this, ClickHouse-backed figures (revenue charts, top products, LTV) stop counting an erased customer's revenue, while Postgres-backed ones (MRR, active subscriptions, recent activity) keep it under the anonymised record. See Revenue metrics → Erased customers.

A request is only marked COMPLETED once every part is done — the Postgres anonymisation, the Stripe cancellations below, the export-artifact deletion above, and every ClickHouse delete confirmed finished (not merely submitted; ClickHouse deletes run asynchronously in the background, and the worker waits for each one to actually complete before reporting success). A record that claims erasure happened while rows, an old export or a billing subscription are still there would be worse than no record at all.

Stripe subscriptions

Erasure cancels every Stripe subscription of the subscriber that can still bill — active, trialing, past due, unpaid or paused — including those of every record merged into it, each on the Stripe connection (live or test) it was sold through. It does so on every run of the erasure, so a retry confirms what an earlier attempt cancelled; a subscription Stripe reports as already cancelled or unknown counts as done. If Stripe refuses a cancellation (a permission error, a disconnected account, no active connection for that mode), the rest of the erasure still runs, but the attempt fails and the request is not COMPLETED: its error names Stripe and each subscription it could not cancel.

If a renewal is still paid on an erased subscriber anyway (an invoice already in flight, or a subscription an erasure from before this behaviour left running), Rovenue records the payment and then cancels that subscription on the connection the payment arrived on, and the audit log shows subscriber.erased_subscription_cancelled. A subscription whose owner was merged into another customer rather than erased is never cancelled this way.

When an erasure fails

An erasure that fails is retried automatically: the request goes back to PENDING with the failure in error and runs again — five attempts in all, about 30 seconds, 1, 2 and 4 minutes apart. Every part is safe to run again: the Postgres step on an already-anonymised subscriber changes nothing new, a Stripe subscription already cancelled counts as done, deleting an artifact that's already gone matches nothing, and the ClickHouse deletes match nothing once the rows are gone. Only after the last attempt is the request FAILED.

A FAILED erasure is run again with its own id:

POST /v1/dsar/:id/retry
Authorization: Bearer <rov_sk_live_…>

It returns the same request, back to PENDING, and starts it again with a fresh set of attempts. Fix what the error names first (reconnect Stripe, or cancel the named subscription in the Stripe dashboard yourself — a subscription Stripe reports as cancelled counts as done). The route is safe to repeat: a request that is PENDING or RUNNING comes back unchanged (its job is re-queued if it was lost), a COMPLETED one comes back unchanged, and if another erasure of the same subscriber is already open you get that one. It shares the POST routes' rate limit. A request belonging to another project answers 404, like GET /v1/dsar/:id. In the dashboard, Anonymize on an erased customer opens a new erasure request when none is open, which runs the same way.

Erasure reaches everything Rovenue stores. It cannot reach a copy of that subscriber's data your own backend already exported and kept — from a prior GET /v1/dsar/:id/download, your own database, your logs, or anywhere else outside Rovenue. Fulfilling erasure for copies you hold yourself is your responsibility.

Limits worth stating plainly

  • Only an erasure of the subscriber the export belongs to deletes the artifact from storage. The 30-day expiresAt gate is a download-access cutoff, not a deletion trigger: once it passes, GET /v1/dsar/:id/download refuses the request, but nothing sweeps the object out of the bucket on that schedule — or on any schedule. An artifact whose 30 days haven't passed yet, for a subscriber who is never erased, keeps physically existing in storage indefinitely; the same is true, indefinitely, once the 30 days HAVE passed. This isn't something a separate retention job happens to cover either — the file-retention sweeper that runs against uploaded import files only ever deletes storage keys it reads off import_jobs rows, never a dsar_requests one, so the dsar-exports/ object is outside its scope entirely. Short of erasing the subject or deleting the project, an export artifact simply stays in storage.
  • Erased subscribers staying erased is enforced by each write route individually (every route that can write to a subscriber checks whether it's soft-deleted before touching it, so an end user's next SDK call can't silently resurrect a forgotten identity: no customer data is ever written back or restored onto an erased subscriber, and nothing un-erases it — only its device id is replaced and its access deactivated. A device that writes after erasure gets a new, unlinked subscriber instead of a refusal). A build-time check now fails if a route reaches a subscriber without consulting that signal, so a newly added write route can't quietly skip it — though the check proves a route consults the signal, not that it acts on it correctly, so per-route behaviour still carries its own tests.
  • This is a read-side guarantee too, not only a write-side one: a POST /v1/dsar/export in flight when the same subscriber is erased fails rather than completing, and never leaves a downloadable artifact behind — see the callout above for the one storage-error case where the object itself can outlive the request.

Building this into your own flow

A typical integration: your backend receives a subject-access or erasure request through whatever channel you already use (a support form, an account-settings page, a compliance inbox), authenticates that it's really from the account holder, then calls the matching endpoint here with that subscriber's rovenueId and something identifying the request internally. Poll GET /v1/dsar/:id until status leaves RUNNING, and for exports, fetch and relay the artifact via GET /v1/dsar/:id/download before its 30-day window closes.

On this page