Version 1.1 of the ExportFlow API: 18 operations and 41 schemas. This page is generated from the API's own OpenAPI contract, so it cannot fall behind it.
Every POST, PUT, PATCH and DELETE needs an Idempotency-Key header. See Idempotency.
Version
Every response carries ExportFlow-Api-Version. See Versioning.
Errors
{"error": {"code": "...", "message": "..."}}. See Errors.
Format
JSON in and out, UTF-8. Timestamps are ISO 8601 in UTC. Identifiers are UUIDs.
From the contract
Document processing and verification for trade documents, for integration into your own ERP, accounting or procurement software.
Authentication. Send your API key as a bearer token: Authorization: Bearer exfk_live_.... Keys are created in the developer console. A key beginning exfk_test_ works in the sandbox environment, one beginning exfk_live_ in production; the two never see each other's data.
Idempotency. Every POST, PUT, PATCH and DELETE needs an Idempotency-Key header. Repeating a request with the same key and the same body returns the original response and does the work once. The SDKs set it for you and reuse it when they retry.
Asynchronous work. Uploading a document and starting a verification both return at once. Poll the resource, or register a webhook endpoint and be told.
Versioning. This is version 1. Within it, fields and endpoints are only added, never removed or changed in meaning. Every response carries ExportFlow-Api-Version. A deprecated endpoint is announced at least six months ahead and answers with Deprecation and Sunset headers until it goes.
Errors. Every error is {"error": {"code": "...", "message": "..."}}. Branch on code; message is for people.
Rate limits. Every response carries RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset (seconds). A request over the limit is answered 429 with Retry-After.
Billing. Requests are not charged. Usage is recorded when work completes: a document accepted, a document processed, a verification completed. Each is recorded once however many times it is requested, retried or read. Sandbox usage is measured and never charged. GET /usage shows your month so far.
Queues classification and reading for a document that failed.
A document is processed automatically when it is uploaded, so this is the recovery route. Calling it for a document that is being processed or has been read changes nothing and answers queued: false; it never buys the same reading twice.
Needs an Idempotency-Key header.
Parameters
Parameters of Process a document again
Parameter
In
Type
Description
document_idRequired
path
string (uuid)
No further detail.
Idempotency-KeyRequired
header
string
Any string of 1 to 255 characters, unique per operation you intend. Repeating a request with the same key and the same body returns the first response; the same key with a different body is refused with idempotency_key_reused. Keys do not expire. 1 to 255 characters.
Any string of 1 to 255 characters, unique per operation you intend. Repeating a request with the same key and the same body returns the first response; the same key with a different body is refused with idempotency_key_reused. Keys do not expire. 1 to 255 characters.
Scans, stores and queues the document for processing.
Processing is asynchronous. Poll GET /documents/{id} or subscribe to document.processing.completed. Uploading the same file to the same shipment twice returns the first document with duplicate: true.
A file that holds several documents is split: the upload's status becomes split and each part appears in GET /shipments/{id}/documents as a document of its own, with parent_document_id naming the upload. Read and confirm the parts; the split upload itself has no reading.
Accepted: PDF, PNG, JPEG, TIFF and WebP, one file per request. Refusals are 400 with a code beginning upload_.
Needs an Idempotency-Key header.
Parameters
Parameters of Upload a document
Parameter
In
Type
Description
shipment_idRequired
path
string (uuid)
No further detail.
document_typeOptional
query
string
What you say the document is. At most 64 characters.
Idempotency-KeyRequired
header
string
Any string of 1 to 255 characters, unique per operation you intend. Repeating a request with the same key and the same body returns the first response; the same key with a different body is refused with idempotency_key_reused. Keys do not expire. 1 to 255 characters.
Confirm the values a person has checked against the documents.
Verification will not start until the record is confirmed, and that is deliberate: if a field was misread, every finding computed from it would be wrong. Confirm what the document says, not what it should say; the verification is what finds the error.
Needs an Idempotency-Key header.
Parameters
Parameters of Confirm what the documents say
Parameter
In
Type
Description
shipment_idRequired
path
string (uuid)
No further detail.
Idempotency-KeyRequired
header
string
Any string of 1 to 255 characters, unique per operation you intend. Repeating a request with the same key and the same body returns the first response; the same key with a different body is refused with idempotency_key_reused. Keys do not expire. 1 to 255 characters.
Checks the confirmed record against the published rule set.
Asynchronous: poll GET /verifications/{id} or subscribe to verification.completed. Answers 409 not_confirmed until the record has been confirmed.
Needs an Idempotency-Key header.
Parameters
Parameters of Verify a shipment's documents
Parameter
In
Type
Description
shipment_idRequired
path
string (uuid)
No further detail.
Idempotency-KeyRequired
header
string
Any string of 1 to 255 characters, unique per operation you intend. Repeating a request with the same key and the same body returns the first response; the same key with a different body is refused with idempotency_key_reused. Keys do not expire. 1 to 255 characters.
Any string of 1 to 255 characters, unique per operation you intend. Repeating a request with the same key and the same body returns the first response; the same key with a different body is refused with idempotency_key_reused. Keys do not expire. 1 to 255 characters.
Any string of 1 to 255 characters, unique per operation you intend. Repeating a request with the same key and the same body returns the first response; the same key with a different body is refused with idempotency_key_reused. Keys do not expire. 1 to 255 characters.
Responses
Responses of Remove a webhook endpoint
Status
Meaning
Body
204
Successful Response
No body
400
The request is malformed, or the upload was refused.
The events a webhook endpoint can receive, from the contract. The webhooks guide covers the payload, signatures and retries. Deliveries are signed in the ExportFlow-Signature header.
Webhook event types
Event
When it is sent
Billable meter
document.uploaded
A document was accepted, scanned and stored.
document.upload
document.processing.started
Classification began.
Not billable
document.processing.completed
The document was classified and read. Fetch its extraction.
document.processing
document.processing.failed
Processing stopped. Fetch the document for the reason.
Not billable
verification.completed
A verification finished. Fetch it for the findings.
verification.run
verification.failed
A verification could not run. Fetch it for the reason.
Not billable
usage.threshold.reached
The account reached 80% or 100% of a monthly allowance. Sent once for each threshold in a period.
Not billable
billing.invoice.generated
An invoice was issued to your organisation.
Not billable
webhook.test
You sent a test event from the console. Never sent for any other reason.
Every object the API accepts or returns. For an object you send, each field is marked required or optional. A response always carries every field listed; a field that has no value is null.
Supply a value or an absence reason, never both and never neither.
Returned on the record as confirmed_absence. illegible added in 1.1.
nameRequired
string
1 to 120 characters.
source_extraction_idOptional
string (uuid) | null
The extraction_id of the reading you confirmed, to keep the
machine's reading beside the person's answer.
valueOptional
string | null
At most 2000 characters.
Document
Fields of Document
Field
Type
Description
declared_type
string | null
The type you sent with the upload, if any.
detected_type
string | null
The type ExportFlow detected.
document_type
string | null
The type in use: the one you declared, otherwise the one detected.
Open text, not a closed list. Types with rules today are
bill_of_lading, commercial_invoice, packing_list,
certificate_of_origin, phytosanitary_certificate and
fpis_certificate; any other type is still read and cross-checked
against the shipment's other documents, and reported as
cross_checked_only in a verification's coverage. Null until
classified, or when the type could not be identified.
duplicate
boolean
True when this exact file was already on the shipment: the existing
document is returned, nothing new is stored and nothing is charged. Default false.
error
string | null
Why processing failed, when status is failed.
filename
string | null
No further detail.
id
string (uuid)
No further detail.
media_type
string
No further detail.
page_count
integer | null
No further detail.
parent_document_id
string (uuid) | null
Set on a document split out of a larger file. When an upload holds
several documents (for example a bill of lading and an invoice scanned
into one PDF), the upload becomes split and each part becomes its own
document on the same shipment, with this field naming the upload. The
parts are processed, listed and verified like any other document; the
split upload itself is not read.
Stable and machine-readable. Branch on this, never on the message.
Every code, its HTTP status and what to do about it are listed under
x-exportflow.error_codes in this document. New codes may be added.
Cite this when confirming the field, to keep the reading it came from.
method
string
How the value was read, for example text_layer or vision.
name
string
No further detail.
page
integer | null
The page the value was read from, counting from 1.
unavailable_reason
string | null
Why there is no value, when there is none: not_present,
illegible or provider_failed. A field is never returned as an
empty string: it has a value or a reason.
critical: will cause rejection. verify: inconsistent, and may
be intentional; a person should look. clean: a rule ran and passed.
uncovered: no rule covers this. unavailable: a value the rule
needed could not be read. uncovered and unavailable are not
passes: show them differently from clean.
When a person confirmed the field has no value: why. It is the
absence_reason sent to PUT /shipments/{id}/record: one of
not_applicable, missing_from_documents or illegible.
confirmed_at
string (date-time) | null
When the field was confirmed. Null means not confirmed yet.
confirmed_value
string | null
The value a person confirmed. Null when not confirmed, or confirmed absent.
What was checked and what was not. Evidence of inconsistency is
reported; a specification is never certified as met. Null until the
verification completes. Keys: rule_set_version, engine_version,
rules_effective_on (a date) and effective_date_source;
documents, a list of {document_id, type, validation,
rules_applied, reason?} where validation is checked (rules for
its type ran) or cross_checked_only (its type has no rules: it was
only compared with the other documents, which is not a pass);
fields_unavailable, a list of {field, reason, document_id}; and,
when no shipped-on-board date was confirmed, effective_date_note.
The body of every delivery, signed with ExportFlow-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of '<t>.<raw body>'>. Deliveries are at least once: de-duplicate on id. Answer 2xx within 10 seconds. There are no shipment events: a shipment changes only through its documents and verifications.