Get started
Authentication
Every request carries an API key. The key decides which organisation and application the request belongs to, which environment it works in, and what it is allowed to do.
API keys#
Send the key in the Authorization header as a bearer token, on every request:
from exportflow import ExportFlow
client = ExportFlow(api_key="exfk_test_...") # or set EXPORTFLOW_API_KEY
identity = client.me()
print(identity.organisation_name, identity.environment) # ... sandboxKeys are created in the console, under an application. A key belongs to exactly one application and one environment. Only an owner of the organisation can issue, rotate or revoke a key.
ExportFlow stores a hash of the key, never the key. The full secret appears once, when the key is created or rotated, and nobody can show it again, including MeerTech. If it is lost, rotate the key. Afterwards a key is identified by its prefix, which is safe to show.
Treat a key like a password. Keep it in an environment variable or a secret store. Do not commit it, do not put it in a mobile app or in code that runs in a browser, and do not send it in a URL.
Environments#
There are two environments, and the key’s prefix says which one it works in. The address and the calls are identical.
| Environment | Key prefix | What it is for |
|---|---|---|
| Sandbox | exfk_test_ | Building and testing. The same pipeline on separate data. Usage is measured and never charged. |
| Production | exfk_live_ | Real documents. Usage is recorded and charged according to your plan. |
The two never see each other’s data. A shipment belongs to the environment of the key that created it, and every call that names a shipment, a document or a verification from the other environment is answered 404, exactly as if it did not exist. Webhook events say which environment they came from.
Scopes#
A key can be limited to some of what the API does. A key issued with no scopes holds all of them. A call that needs a scope the key lacks is answered 403 with the code insufficient_scope, and the message names the scope.
| Scope | Allows |
|---|---|
shipments:read | List and fetch shipments |
shipments:write | Create shipments |
documents:read | Fetch documents, extractions and the shipment record |
documents:write | Upload documents, process them again, confirm the record |
verifications:read | List and fetch verifications |
verifications:write | Start a verification |
usage:read | Read usage and estimated charges |
webhooks:read | List webhook endpoints |
webhooks:write | Register and remove webhook endpoints |
Give each deployment the narrowest key that works. A service that only uploads needs shipments:write and documents:write; a reporting job that only reads usage needs usage:read.
Rotation#
Rotating a key issues a new secret with the same application, environment, scopes and limits. The old key keeps working for 24 hours, so you can deploy the new one without an outage, and then stops. If the old key has leaked, revoke it instead of waiting.
A key can also be given an expiry when it is created. An expired key is refused like any other invalid key.
Revocation#
Revoking a key takes effect at once: the next request with it is answered 401. It cannot be undone. Issue a new key if you revoked the wrong one.
A revoked, expired, unknown or malformed key all receive the same answer, invalid_api_key. The API does not say which, because that would tell somebody guessing keys that one of their guesses was once real.
IP allowlists#
An account can be restricted to a list of network addresses, so that a stolen key is useless from anywhere else. The allowlist is set by MeerTech on request; it cannot be edited in the console. A request from an address outside it is answered 403 with the code ip_not_allowed.
Other reasons a valid key is refused#
| Code | Status | Why |
|---|---|---|
account_suspended | 403 | The organisation's account is suspended. |
application_disabled | 403 | The key's application is disabled in the console. |
application_owner_unavailable | 403 | The member who owns the application is no longer active. An owner assigns it to somebody else. |
sdk_version_unsupported | 426 | The request came from an SDK older than the oldest supported version. |
The full list, with what to do about each, is in Errors.