ExportFlowDevelopers
Sign inGet API keys

Guides

Webhooks

Uploads and verifications finish in the background. Instead of polling, register an endpoint and ExportFlow will send it a signed request when something happens.

Registering an endpoint#

An endpoint is an https URL on your side, registered against one application, with the list of events it wants. Register it in the console or through the API. An endpoint registered with no event types receives every event.

endpoint = client.webhook_endpoints.create(
    "https://erp.example.com/hooks/exportflow",
    event_types=["document.processing.completed", "verification.completed"],
)
print(endpoint.signing_secret)   # whsec_...  store this

Registering returns the endpoint’s signing secret, which begins whsec_. Store it as you would an API key. An owner can see it again, or replace it, in the console.

The URL must be reachable from the internet. A URL that is not https, that carries a user name or password, or that points at a private or loopback address is refused with invalid_webhook_url, and the address is checked again each time an event is delivered. Redirects are not followed.

Events#

An event about a document or a verification is sent to the endpoints of the application that created the shipment. An account-level event, such as an invoice, is sent to every endpoint of the organisation that subscribes to it.

Webhook events
EventWhen it is sentWhat data holds
document.uploadedA document was accepted, scanned and stored.document.id, shipment.id, status, document_type
document.processing.startedClassification began.document.id, shipment.id, status, document_type
document.processing.completedThe document was classified and read. Fetch its extraction.document.id, shipment.id, status, document_type, pages, fields_read
document.processing.failedProcessing stopped. Fetch the document for the reason.document.id, shipment.id, status, document_type, stage
verification.completedA verification finished. Fetch it for the findings.verification.id, shipment.id, status, findings (a count for each severity)
verification.failedA verification could not run. Fetch it for the reason.verification.id, shipment.id, status
usage.threshold.reachedThe account reached 80% or 100% of a monthly allowance. Sent once for each threshold in a period.organisation.id, meter, environment, threshold_percent, used, limit, period, resets_at
billing.invoice.generatedAn invoice was issued to your organisation.invoice.id, number, period_start, period_end, currency, total_micro

One more event exists, webhook.test. It is sent only when you press Send test event in the console, and only to that one endpoint. It is signed and delivered exactly as a real event is, so it exercises your verification code. It reaches the endpoint whichever event types the endpoint subscribes to.

Events carry identifiers, not documents

An event tells you what happened and to what. It never contains document content or extracted values. Fetch the document, the extraction or the verification with your API key to read it. New fields can be added to data within version 1, so ignore the ones you do not use.

The payload#

Every delivery is a POST with a JSON body in the same envelope. Only type and data differ between events.

Payload
{
  "id": "<event id>",
  "type": "document.processing.completed",
  "created_at": "2026-11-11T09:30:00Z",
  "api_version": "1.1",
  "environment": "sandbox",
  "application_id": "<application id>",
  "data": {
    "document": { "id": "<document id>" },
    "shipment": { "id": "<shipment id>" },
    "status": "processed",
    "document_type": "bill_of_lading"
  }
}
The event envelope
FieldMeaning
idThe event's identifier. The same on every delivery of this event. Use it to discard repeats.
typeThe event type.
created_atWhen the event happened, in UTC.
api_versionThe API version that produced the event.
environmentsandbox or production.
application_idThe application the event belongs to. Null for an account-level event.
dataThe subject's identifier under its own name, and the event's details.

The request also carries three headers:

Header
ExportFlow-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256>
ExportFlow-Event: document.processing.completed
ExportFlow-Event-Id: <event id>

Verifying the signature#

Verify every delivery before you trust it. The URL of an endpoint is not a secret, and anybody who learns it can post to it.

The ExportFlow-Signature header is t=<timestamp>,v1=<signature>. The signature is the HMAC-SHA256, in hexadecimal, of the timestamp, a full stop and the raw request body, keyed with the endpoint’s signing secret:

  1. Split the header on commas and read t and every v1. There can be more than one v1, for example while a secret is being rotated: the delivery is genuine if any one of them matches. The SDKs (1.1 and later) do this.
  2. Refuse the delivery if t is more than 5 minutes from your own clock. This stops a captured delivery being replayed later.
  3. Compute HMAC-SHA256 over "<t>.<raw body>" with the signing secret as the key.
  4. Compare the result with v1 using a constant-time comparison.

Both SDKs do this in one call. The last two tabs show it with nothing but a standard library.

from exportflow import webhooks, SignatureVerificationError

def handle(request):
    try:
        event = webhooks.construct_event(
            payload=request.body,                               # raw bytes
            signature=request.headers["ExportFlow-Signature"],
            secret=WEBHOOK_SECRET,
        )
    except SignatureVerificationError:
        return 400
    if already_handled(event.id):          # deliveries are at-least-once
        return 200
    if event.type == "document.processing.completed":
        document_id = event.data["document"]["id"]
        ...
    return 200
Use the raw body

The signature is over the exact bytes ExportFlow sent. If your framework parses the JSON and you serialise it again, the bytes will differ and the signature will not verify. Read the raw body first, verify it, then parse it.

Delivery, retries and duplicates#

Answer with any 2xx status within 10 seconds. Do the real work after you have answered: put the event on a queue of your own and return.

Anything else (another status, a timeout, a connection failure) is retried with increasing delays, starting at a few seconds and doubling up to an hour, for about two and a half hours in total. After that the delivery is marked failed. The event itself is kept, and every attempt is shown in the console.

Delivery is at least once. If your endpoint did the work but answered too slowly, the same event arrives again with the same id. Record the ids you have handled and answer 2xx to a repeat without doing the work twice. Events can also arrive out of order; use the resource’s own status as the truth, not the order of arrival.

An endpoint that fails 20 deliveries in a row is disabled automatically, and the console says why. Fix the endpoint and enable it again in the console; one successful delivery resets the count.

Testing an endpoint#

In the console, open Webhooks, choose an endpoint and press Send test event. A signed webhook.test event is queued for that endpoint, and its outcome appears in the endpoint’s deliveries with the status your server answered, the number of attempts and any error.

Rotating the signing secret takes effect at once, with no overlap. Give your receiver the new secret straight away. A delivery it refuses in between is retried, and each attempt is signed afresh with the current secret and the current time.