Skip to main content
All examples assume a configured client:

End-to-End Redaction

Upload a document, detect sensitive data, review, then redact:
A detection moves through pending → executing → complete or failed. Redaction is a separate step that leaves that status alone — nothing is modified until you call createRedaction, and each call produces a new redaction.

Redacting With Reviewer Edits

Omit edits to redact with the policy decisions exactly as detected, or supply an EditSet to layer a reviewer’s corrections over the analysis first — suppress a false positive, retag a finding, or add one the analysis missed. An EditSet holds one list per modality — text, tabular, image, and audio — and every entry is tagged with an op:

Downloading the Redacted Document

A redaction’s outputDocumentId points at a normal workspace document, so it downloads through the documents service:

Ad-Hoc Detection Without a Pipeline

Name the policies directly when you do not want a saved pipeline:

Reporting Live Progress

Each event is a DetectionStatusEvent — { detectionId, status } — so the same stream can drive a progress indicator. Break out of the loop to close it early:
The stream closes on its own once the detection settles, so the loop terminates without a timeout. If the connection drops early, re-read the detection with getDetection — the detection row is the source of truth.
For full control over the text/event-stream body, events returns the raw Response instead:

Batch Uploads

uploadDocuments accepts an array and returns metadata for each document:

Skipping Duplicate Uploads

Documents carry a SHA-256 of their plaintext content, and the list query can filter on it — so you can check whether identical content is already in the workspace before uploading it again:

Bulk Deletion

deleteDocuments is idempotent and reports what it could not remove:
An id lands in skipped when it is unknown, already deleted, in another workspace, or held by an in-progress detection that still needs the document.

Paginating Results

List endpoints are cursor-based. Follow nextCursor until it is absent:
Pass includeCount: true when you need the total in page.total. It costs an extra query, so it is off by default.

Creating a Policy and Pipeline

A policy defines what counts as sensitive; a pipeline defines how documents are processed. Inspect the deployment’s capabilities to see what is available:
Refer to the API Reference for the exact CreateWorkspacePolicy and CreateWorkspacePipeline shapes — they are generated from the OpenAPI specification and stay in sync with the server.

Exporting an Audit Trail

A detection’s audit downloads as a file, csv by default or json on request:
The csv export is a zip of entities.csv, provenance.csv, and reviews.csv. The json export is a single pretty-printed file.
The workspace activity log exports the same way:

Running a Human Review

Open a review on a document, assign a reviewer, discuss, then verify it:
assignReviewer, linkDetection, and linkRedaction are idempotent, so they are safe to repeat. Use reopenReview to move a resolved review back into review.
Find work assigned to an account with the list query:

Workspace Analytics

Receiving Webhooks

Create a webhook, store its secret, and verify each delivery:
On the receiving side, verify the signature before trusting the payload:
constructEventFromRequest reads the raw body for you. If you verify manually with constructEvent, pass the raw bytes — a re-serialized JSON body will not match the signature.

Error Handling

Wrap only reads in an automatic retry. A POST that uploads a document or creates a redaction may have already succeeded when the response failed, so retrying it blindly duplicates work.
Retrying a write is different: re-read first and check whether the earlier attempt landed. Redactions are repeatable, so a blind retry mints a second redaction rather than failing.
This resumes one uncertain createRedaction call. It returns the detection’s most recent redaction without checking which edits produced it, so do not use it when you intend to create an additional redaction with different edits — it would return the earlier one instead.

Managing API Tokens

Escaping to the Raw Client

client.api is the underlying typed openapi-fetch client, for anything the service classes do not wrap — extra headers on a single call, for instance:
Repeating a detection request with the same Idempotency-Key returns the existing detection rather than starting a second one. Generate one key per logical detection and reuse it across every retry of that detection — generating a fresh key inside the retry loop defeats the purpose.