Integrate in an afternoon

Two calls carry the whole product: one when you hand a copy to someone, one when a copy turns up where it shouldn't. This guide takes you from a pilot key to production, in the language you already use.

Plan your ids

Before writing code, decide two ids. They are all we ever learn about your users and content.

  • recipient_id — your stable, opaque id for the person, such as a user table key (usr_8f2c41). Never an email, name or phone number. The same person should always get the same id.
  • content_id — your id for the item, such as board-pack-2026-q3. It comes back in every scan result, so make it something your team recognises.

Keep the mapping from usr_8f2c41 to a real person inside your own system. When a scan names a recipient, you look them up; we never can.

Issue a marked copy

Call embed on your server, with your key in an environment variable, and deliver what comes back to that one recipient.

# Send a document, get back this recipient's own copy.
curl -X POST https://api.tracereceipt.com/sdk/v1/document/embed \
  -H "x-api-key: $TRACERECEIPT_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "document_b64": "'"$(base64 -w0 board-pack.pdf)"'",
    "filename": "board-pack.pdf",
    "recipient_id": "usr_8f2c41",
    "content_id": "board-pack-2026-q3"
  }' | jq -r .document_b64 | base64 -d > board-pack.usr_8f2c41.pdf

Images use /sdk/v1/watermark/embed with image_b64 instead of document_b64, and return watermarked_image_b64. Everything else is the same.

Where to call it

Mark copies at the moment content leaves your control for a named person. The usual places:

  • On download. When a signed-in user clicks download, call embed with their id and stream the result instead of the original.
  • On send. Before an email, portal share or data-room invite goes out, issue one copy per recipient.
  • On publish to a closed group. For a board pack or screener list, issue every copy up front in a background job.

Store the issued copy against (recipient_id, content_id) and reuse it if the same person downloads again. Issuing again works, but each call uses units.

Video and audio

Upload as multipart and ask for the file straight back. Use /sdk/v1/audio/embed for audio.

curl -H "x-api-key: $TRACERECEIPT_API_KEY" \
  -F [email protected] -F recipient_id=usr_8f2c41 -F content_id=ep-12 \
  -F response=binary -o ep-12.usr_8f2c41.mp4 \
  https://api.tracereceipt.com/sdk/v1/video/embed

Web app screens

For content that only lives on screen. Your server mints a short-lived viewer token; your page starts the script with it. Your API key never reaches the browser.

// Server: an endpoint your page calls to get a short-lived viewer token.
app.get("/viewer-token", requireLogin, async (req, res) => {
  const r = await fetch("https://api.tracereceipt.com/sdk/v1/protect/token", {
    method: "POST",
    headers: { "x-api-key": process.env.TRACERECEIPT_API_KEY, "content-type": "application/json" },
    body: JSON.stringify({ recipient_id: req.user.opaqueId, content_id: "revenue-dashboard", ttl_seconds: 900 }),
  });
  if (!r.ok) return res.sendStatus(502);
  res.type("text").send((await r.json()).token);
});
In your page
TraceReceiptProtect.start({
  endpoint: "https://api.tracereceipt.com",
  token: initialToken,
  getToken: () => fetch("/viewer-token").then((r) => r.text()),
  onError: (err) => console.warn(err.code),
});

The browser script is supplied with your pilot key.

Scan a leak

Send whatever surfaced: the file, pasted text, a screenshot or a clip. Treat every status explicitly; a timeout is never a clean result.

curl -X POST https://api.tracereceipt.com/sdk/v1/document/extract \
  -H "x-api-key: $TRACERECEIPT_API_KEY" \
  -H "content-type: application/json" \
  -d '{"image_b64": "'"$(base64 -w0 leaked-screenshot.png)"'"}'

Images and screen screenshots use /sdk/v1/watermark/extract; video and audio use their own /extract endpoints with the same statuses.

Verify a receipt

A detected result carries a signed receipt. Keep it with the case. Anyone can check it, online or offline, without your key, so it holds up when you hand it to counsel, auditors or HR.

import crypto from "node:crypto";

// Canonical JSON: keys sorted at every level, no whitespace.
const canonical = (v) =>
  Array.isArray(v) ? `[${v.map(canonical).join(",")}]`
  : v && typeof v === "object"
    ? `{${Object.keys(v).sort().map((k) => `${JSON.stringify(k)}:${canonical(v[k])}`).join(",")}}`
    : JSON.stringify(v);

export async function verifyReceipt(receipt) {
  // Fetch once and pin it in your config; it doesn't change.
  const { public_key } = await (await fetch("https://api.tracereceipt.com/sdk/v1/evidence/public-key")).json();
  const key = crypto.createPublicKey({ key: { kty: "OKP", crv: "Ed25519", x: public_key }, format: "jwk" });
  return crypto.verify(null, Buffer.from(canonical(receipt.payload)),
                       key, Buffer.from(receipt.signature, "base64url"));
}

Handling data properly

  • Send ids, not people. Opaque recipient ids only. If you would not print it on a public screen, it should not be a recipient id.
  • Keys stay on servers. Load the key from a secret store or environment variable. Never ship it in a browser bundle or mobile app.
  • We don't keep your files, so keep your own originals and issued copies under your normal retention rules. What we keep, and why.
  • Tell your users. Say in your terms or notice that shared content carries a recipient mark to trace leaks. It deters leaks and keeps you transparent.
  • A match starts an investigation. It names the copy, not the person who shared it. Check device sharing and access logs before acting on it.
  • Watch your own usage. Every call made with your key appears in the dashboard within 15 seconds.

Go-live checklist

  1. Key stored in a secret manager, not in code or the repo
  2. recipient_id is opaque and stable for each person
  3. Issued copies are cached per recipient and content
  4. 502, 503 and 504 are retried with backoff; 504 is never treated as clean
  5. inconclusive and unrecognised are shown to investigators, not hidden
  6. Receipts from detected results are stored with the case
  7. Your privacy notice mentions recipient marking
  8. Someone on your team watches the dashboard during the first week

Stuck on any step? Pilot customers get a named engineer. Apply for a pilot or read the API reference.