Developer API
Webhooks: send records and document updates to Slack, Make, Zapier, n8n or your system
Receive approved records and document status changes on your own server as signed POST requests, verify the signature, handle retries safely and check recent deliveries.
A webhook tells a server of yours when something happens to your documents: a record is approved, a document is read and waits for review, or processing fails. Your system does not have to keep asking: D2Transform posts to you, signed with a secret only you and D2Transform know.
Use a webhook when approved records should flow straight into another system, such as an accounting tool or a database, or when your own app shows people the results and runs its own review. To send documents in, or to read records on demand, use the public API.
Events
Choose the events each endpoint receives when you add it.
| Event | When it is sent | What it carries |
|---|---|---|
gold.approved | A record is approved, automatically or by a reviewer | The whole record, as in the JSON export |
document.needs_review | A document has been read and its records wait for review | Ids, status and record counts |
document.rejected | A reviewer rejected a document's records | Ids, status and record counts |
document.failed | Processing a document failed | Ids, status and the error message |
document.awaiting_setup | A document waits because its document type is not set up yet | Ids and status |
document.* events are deliberately small: they never contain field values or the file name. When you need the data, read it with GET /v1/documents/{id}/results using the public API. Steps inside processing (reading, structuring, mapping) are not sent as events; check GET /v1/jobs/{id} if you show progress.
Before you start
- Plan. Webhooks are included in Business and Enterprise plans. If your organization moves to a plan without webhooks, deliveries stop.
- Permission. You need the permission to Manage webhook endpoints and secrets. Owners have it by default, and it can be added to other roles.
- Two-factor authentication. If you use an authenticator app, adding or removing an endpoint asks for a recent confirmation from it.
- Your endpoint. An
https://address on your server that accepts POST requests with a JSON body. Addresses on private or local networks are refused, and redirects are not followed.
Add an endpoint
Open Webhooks
Open Webhooks in the side menu (under Configuration) and choose Add endpoint.
Choose the destination
Pick Slack, Make, Zapier, n8n or Your endpoint, give the endpoint a name, and paste the Endpoint URL (see destinations for where to find it). An address that is not
https://, or that points to a private or local network, is refused.Choose the events
Tick the events this endpoint should receive.
Set the body
Keep the Standard body, or choose Custom and shape the JSON yourself (see custom body). Each destination starts with a ready-made body you can change.
Create it and copy the signing secret
Choose Create endpoint. When signing is on, the Signing secret is shown once: choose Copy secret, store it in your secret store, then choose Done. It is stored encrypted and cannot be shown again.
To change an endpoint, choose Edit next to it. You can change everything; the URL, the headers and the signing secret are replaced, never shown again: choose Replace URL, Replace headers or Issue a new signing secret when I save. Replacing one asks for a recent confirmation from your authenticator app, if you use one.
Destinations
D2Transform sends an HTTPS POST with a JSON body to the URL you paste. It does not sign in to these services: you set up what happens next in the service itself.
| Destination | Where the URL comes from | Notes |
|---|---|---|
| Slack | A Slack app with Incoming Webhooks turned on: add a webhook to a channel and copy its URL | The URL posts to that one channel. The body must have a text value, so Slack always uses a custom body. Requests are not signed and carry no custom headers: the URL itself is the secret |
| Make | A Webhooks › Custom webhook module as the first step of a scenario | Make receives the JSON and can pass its fields to the next modules |
| Zapier | A Webhooks by Zapier trigger with the Catch Hook event | Zapier receives the JSON and offers its fields to later steps |
| n8n | A Webhook node with the POST method: use its production URL | n8n receives the JSON; the test URL only works while n8n is listening for a test event |
| Your endpoint | Any https:// address on your own server | Uses the standard body by default |
Make, Zapier and n8n usually need to receive one request before they show its fields in their editor. Put the service in its "listen" or "test" mode, then use Send test on the endpoint's page.
Custom body
With Custom, the body is JSON you write. Put a field in any text value with double braces, for example {{document.fileName}}. Everything else stays exactly as written: numbers, true/false, null, objects and lists.
{
"event_id": "{{event.id}}",
"event_type": "{{event.type}}",
"document": { "id": "{{document.id}}", "file_name": "{{document.fileName}}", "status": "{{document.status | upper}}" },
"waiting": "{{records.pendingReview}}"
}- Fields. The page lists the fields of each event and inserts one where your cursor is. Every event has
event.id,event.type,event.createdAt,event.test,organization.idanddocument.id,externalId,fileName,status,documentTypeId,documentTypeName,createdAtandresultUrl(the document's page in D2Transform, which needs sign-in).document.needs_reviewanddocument.rejectedaddrecords.pendingReview,records.approved,records.rejectedandrecords.minConfidence;document.failedaddsdocument.error;gold.approvedaddsrecord.id,record.index,record.minConfidence,record.autoApproved,record.approvedAt,record.data(all fields, as in the JSON export),record.data.followed by a field key of your target schema (for examplerecord.data.total) for one field, andapproval.source. - Types. A text value that is only one field, such as
"{{records.pendingReview}}", keeps the field's type: a number stays a number and a missing value becomesnull. Inside longer text a missing value is left empty. - Filters.
upper,lower,trim,date(keeps theYYYY-MM-DDpart) andtruncate:40(at most 40 characters), one after another:{{document.fileName | truncate:30}}. Nothing else can run inside the braces. - Escaping. Values are put into the JSON safely: quotes, backslashes and line breaks in a file name can never break the body. For Slack,
&,<and>in values are also escaped, so a file name cannot create a mention or a link. - Checks. The page shows a preview with sample data and refuses to save JSON that is not valid, a field that does not exist for the chosen events, or an unknown filter. It warns when a field is empty for one of the chosen events.
Authentication and headers
- Signing. For Make, Zapier, n8n and your own endpoint, Sign each request adds
X-D2Transform-Signature(see verify the signature), computed over the body exactly as sent. You can turn it off for a destination that cannot check it. - Custom headers. Up to 10, for example
Authorization: Bearer …orX-Api-Key, for a receiver that expects them. Values are stored encrypted and never shown again; the page shows the names only. Headers that D2Transform or HTTP set themselves (Content-Type,Host,User-Agent,X-D2Transform-…and similar) cannot be used. - Slack has neither: its URL is the secret.
What D2Transform sends
For each event, D2Transform sends one POST request to every endpoint of your organization that receives that event. The request carries these headers:
| Header | Value |
|---|---|
Content-Type | application/json |
User-Agent | D2Transform-Webhooks/1.0 |
X-D2Transform-Event | The event name, such as gold.approved or document.needs_review; ping for a test ping |
X-D2Transform-Event-Id | The id of the event: the same on every retry of it |
X-D2Transform-Delivery | A unique id for this delivery attempt |
X-D2Transform-Signature | t=TIMESTAMP,v1=SIGNATURE (see below) |
gold.approved
The body has the same shape as a record in the JSON export: each value as written in the document, plus a FIELD_converted value next to dates, numbers, amounts and yes/no values. An example, with invented values:
{
"id": "7c1d9e2a-3b4f-4a5c-8d6e-9f0a1b2c3d4e",
"event": "gold.approved",
"source": "review",
"org_id": "5f0c1a2e-8d4b-4c3e-9a71-2b6d0e4f8c19",
"document": {
"id": "a3e9b7c1-4f2d-4e8a-b5c6-1d7f9e0a2b34",
"external_id": "order-1042",
"file_name": "invoice-0042.pdf",
"document_type_id": "c8d2e4f6-1a3b-4c5d-8e9f-0a1b2c3d4e5f",
"created_at": "2026-11-04T09:12:44.512Z"
},
"record": {
"id": "e1f2a3b4-c5d6-4e7f-8a9b-0c1d2e3f4a5b",
"record_index": 0,
"status": "approved",
"min_confidence": 1,
"auto_approved": false,
"approved_at": "2026-11-04T09:20:03.118Z",
"target_schema_id": "f0e1d2c3-b4a5-4968-8776-655443322110",
"data": {
"invoice_number": "INV-0042",
"vendor_name": "हिमालय ट्रेडर्स",
"total": "रु. १२,५००",
"total_converted": 12500
}
},
"sent_at": "2026-11-04T09:20:04.207Z"
}idis the event id, the same value as theX-D2Transform-Event-Idheader.eventis the event name, the same value as theX-D2Transform-Eventheader:gold.approvedwhen a record is approved.document.external_idis the reference you sent asexternalIdwhen you created the upload, ornull.sourceisautowhen the record was approved automatically andreviewwhen a reviewer approved it.record.dataholds the fields of your target schema. Text is kept exactly as written, in any script.min_confidenceis how sure D2Transform was of the least certain value in the record, from 0 to 1.
document.* events
An example of document.needs_review, with invented values:
{
"id": "0b8f6c2d-1e3a-4f5b-9c7d-2e4f6a8b0c1d",
"event": "document.needs_review",
"org_id": "5f0c1a2e-8d4b-4c3e-9a71-2b6d0e4f8c19",
"document": {
"id": "a3e9b7c1-4f2d-4e8a-b5c6-1d7f9e0a2b34",
"external_id": "order-1042",
"document_type_id": "c8d2e4f6-1a3b-4c5d-8e9f-0a1b2c3d4e5f",
"status": "needs_review",
"created_at": "2026-11-04T09:12:44.512Z"
},
"data": {
"records": { "pending_review": 1, "approved": 0, "rejected": 0 },
"min_confidence": 1
},
"occurred_at": "2026-11-04T09:13:30.004Z",
"sent_at": "2026-11-04T09:13:31.207Z"
}document.statusis the status the event reports. By the time you read the document it may have moved on, for example after a review, so readGET /v1/jobs/{id}when the current status matters.datadepends on the event:records(how many records wait for review, are approved or rejected) andmin_confidence(the least certain value across those records, from 0 to 1, ornullwhen there are none) fordocument.needs_reviewanddocument.rejected,errorfordocument.failed(the same message asGET /v1/jobs/{id}), and nothing fordocument.awaiting_setup.occurred_atis when the status changed. Events can arrive out of order; compareoccurred_atif the order matters to you.- A
document.*event is usually sent within seconds. If a send is missed, D2Transform sends it within five minutes.
Verify the signature
Check the X-D2Transform-Signature header on every request before you trust the body. It looks like t=1762247404,v1=5d41…:
tis the time the request was signed, in Unix seconds;v1is an HMAC-SHA256, in hexadecimal, of the timestamp, a dot and the raw request body, made with your signing secret.
To verify it, compute the same HMAC over t, a dot and the body exactly as you received it, compare it with v1 in constant time, and refuse requests whose timestamp is too old. We suggest accepting a timestamp at most five minutes away from your server's clock. Use the whole secret as shown, including its whsec_ start.
A Node.js example with no extra packages:
import { createHmac, timingSafeEqual } from "node:crypto";
import { createServer } from "node:http";
const SECRET = process.env.D2T_WEBHOOK_SECRET; // the signing secret, whsec_…
const TOLERANCE_SECONDS = 300; // five minutes
function verifySignature(rawBody, header) {
const parts = Object.fromEntries(
String(header ?? "")
.split(",")
.map((part) => {
const i = part.indexOf("=");
return [part.slice(0, i), part.slice(i + 1)];
}),
);
const t = Number(parts.t);
if (!Number.isInteger(t) || !parts.v1) return false;
if (Math.abs(Math.floor(Date.now() / 1000) - t) > TOLERANCE_SECONDS) return false;
const expected = createHmac("sha256", SECRET).update(`${t}.${rawBody}`).digest();
const received = Buffer.from(parts.v1, "hex");
return received.length === expected.length && timingSafeEqual(received, expected);
}
createServer((req, res) => {
const chunks = [];
req.on("data", (chunk) => chunks.push(chunk));
req.on("end", () => {
const rawBody = Buffer.concat(chunks).toString("utf8");
if (!verifySignature(rawBody, req.headers["x-d2transform-signature"])) {
res.writeHead(401).end();
return;
}
const payload = JSON.parse(rawBody);
// Save or queue the record here, then answer quickly.
console.log(payload.event, payload.record?.id);
res.writeHead(200).end();
});
}).listen(3000);Retries and duplicates
A delivery succeeds when your endpoint answers with a 2xx status within 10 seconds. Any other status, a redirect, a timeout or a connection error counts as a failure, and the delivery is retried up to four more times.
Every attempt is a new delivery with its own X-D2Transform-Delivery id, and the same record can reach you more than once, for example when your server saved it but answered too slowly. Make your endpoint safe to call twice:
- use the event
id(or theX-D2Transform-Event-Idheader) to recognize an event you have already received, and skip it; - for
gold.approved,record.idalso identifies the record if it is approved again, for example after its mapping changed; - answer with a
2xxstatus as soon as the request is verified and saved, and do slow work afterwards.
Send a test
On an endpoint's page, pick a Test event and choose Send test. D2Transform sends one request with sample data (never a real document), using the saved URL, signing and headers and the body as it is on the page, so you can try a change before saving it. The request carries X-D2Transform-Test: true, and a standard body has "test": true. With the standard body you can also send ping:
{ "event": "ping", "test": true, "org_id": "5f0c1a2e-8d4b-4c3e-9a71-2b6d0e4f8c19", "sent_at": "2026-11-04T09:30:00.000Z" }The page then shows "Delivered: HTTP 200", or why it was not delivered, such as no answer within 10 seconds. A test updates the endpoint's Last delivery and Last status, but it is not listed under Recent deliveries and is never retried. Reply to a test with a 2xx status and do nothing else with it.
Recent deliveries
The endpoints table shows each endpoint's name and destination, its Address (start and last four characters only), Events, Body, Last delivery (or Never) and Last status, the HTTP status of its last answer. Each endpoint's page lists its own delivery history.
Below it, Recent deliveries lists your organization's latest delivery attempts with When, Endpoint, Event, Status, HTTP and Error:
| Status | Meaning |
|---|---|
| Pending | The request is being sent |
| Delivered | Your endpoint answered with a 2xx status |
| Failed | Your endpoint answered with another status, or could not be reached |
The Error column shows, for example, http_500 for a status your endpoint returned, or invalid_url when the address no longer points to a public server. D2Transform never stores the request body or what your server sends back.
Remove an endpoint
Open the endpoint, choose Delete endpoint and confirm. Deliveries stop immediately, and its URL, headers and signing secret are deleted. If you use an authenticator app, you are asked for a recent confirmation from it.
Was this article helpful?
Your answer stays in this browser; nothing is sent unless you email us.
Related articles
- Public API overview and quick startCreate API credentials, exchange them for a short-lived access token, upload a document straight from a browser or server, and read the structured results back.
- Public API referenceEvery endpoint of the public API with its scope, request fields, responses, error codes, rate limits and pagination.
- Export dataDownload your records as CSV, Excel or JSON, choose which records and columns to include, or send records and document updates by webhook to your system, Slack, Make, Zapier or n8n.
- Review and correct dataCheck values against the original page, correct them, fix table rows such as line items, then approve or reject the record.