Going headless
What you get
Everything you do in the Talonic app has an API counterpart: bring documents in, define and run Specs, read results, review, deliver and administer. This page shows how to know when work is done, how to get files in from anywhere, and which few steps still need a person in a browser, with the link to hand them. It is for developers and agent builders who want Talonic without the app.
Before you start
- An API key with
extract,readandoperationsfor the examples below;events:readorreadfor the event feed;write(orevents:write) to create webhooks. See Authentication. - For upload links: an OAuth token from the hosted connector sign-in. API keys are refused on that route by design.
Do it in the app
Nothing to do in the app beyond creating your key under Settings → API Keys and, once, connecting any mailbox or drive that needs a provider sign-in (see What stays in the browser). Everything you then do from code shows up in the app as usual, so people can still look in on Runs, review and results.
Do it with the API
Know when work is done: poll, webhooks or the event feed
- Poll when you started the work and will wait for it. Every asynchronous call returns a
poll_url(for exampleGET /v1/documents/{id}after an extraction,GET /v1/run/{id}after a Run). Start at 2 seconds and back off to 30. - Webhooks when you have a public HTTPS endpoint and want to be told. Register it with
POST /v1/webhooks; Talonic signs each delivery with HMAC-SHA256 and retries failures. See Webhooks and events. - The event feed when you cannot receive inbound calls or want to catch up after downtime.
GET /v1/eventslists every event in your workspace. Passafter=<next_cursor>to read oldest-first from where you stopped, so nothing is missed; filter withevent_typeandsince.
curl "https://api.talonic.com/v1/events?after=$LAST_CURSOR&event_type=document.extracted,result.flagged&limit=100" \
-H "Authorization: Bearer $TALONIC_API_KEY"let cursor = await loadCursor() // your own storage; undefined on first start
while (true) {
const url = new URL('https://api.talonic.com/v1/events')
if (cursor) url.searchParams.set('after', cursor)
url.searchParams.set('limit', '100')
const res = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.TALONIC_API_KEY}` },
})
const page = await res.json()
for (const event of page.data) await handle(event)
if (page.next_cursor) { cursor = page.next_cursor; await saveCursor(cursor) }
if (page.data.length === 0) await new Promise((r) => setTimeout(r, 10_000))
}{
"data": [
{
"id": "48211",
"event_type": "document.extracted",
"payload": { "document_id": "f0e1d2c3-b4a5-9687-8765-432109876543" },
"created_at": "2026-11-25T10:02:11.000Z"
}
],
"total": 1,
"limit": 100,
"offset": 0,
"next_cursor": "48211"
}Get files in: by URL or with an upload link
Your code holds the file or its address. Send the bytes as file, or send file_url with a public or pre-signed URL and Talonic fetches it: POST /v1/extract with -F "file_url=https://...". Use a source's upload route or /v1/run for many files at once; see Bring documents in.
The file is on a person's computer, not yours. Create an upload link: POST /v1/documents/upload-session with a filename returns a document_id and an upload_url. Give the person the link; they pick the file in their browser and it is posted straight to Talonic, so your agent never handles the bytes. Then poll the document_id or drive it with POST /v1/extract. The link is single-use and expires after 15 minutes. The MCP tool talonic_request_upload does exactly this.
{
"document_id": "f0e1d2c3-b4a5-9687-8765-432109876543",
"upload_url": "https://app.talonic.com/u/1f2e3d4c-5b6a-7980-abcd-ef0123456789",
"expires_at": "2026-11-25T12:15:00.000Z"
}What stays in the browser
A few steps need a person on purpose, because a provider or a payment requires their own consent. Your code fetches or names the link, a person completes it, and your code carries on.
Browser handoffs
| Parameter | Type | Description |
|---|---|---|
| Buy credits or change plan | GET /v1/billing/upgrade-link | Returns `url` (a hosted checkout for the chosen `pack`, or the billing page in the app) and `requires_human: true`. Credits land seconds after payment. Agent tool: `talonic_get_billing_upgrade_link`. |
| Upload a file from a person's computer | POST /v1/documents/upload-session | Returns a single-use `upload_url`, valid 15 minutes. |
| Connect a mailbox or drive | app: Sources | Gmail, Outlook, Google Drive, OneDrive, SharePoint and similar sources need the provider's consent screen. A person connects them once in **Sources**; after that, documents sync and the source is usable from the API. No API endpoint returns this consent link today. |
| Connect an OAuth destination | app: Delivery | Google Drive, OneDrive and Google Sheets destinations also need the provider sign-in, done once under **Delivery**. |
| Approve an agent | OAuth consent | The hosted MCP connector opens a Talonic sign-in and consent page the first time it connects. |
Do it with an agent
Agents get the same building blocks as tools: talonic_list_events for the feed, talonic_create_webhook and talonic_list_webhook_event_types for push, talonic_request_upload for upload links and talonic_get_billing_upgrade_link when credits run out. Ask, for example: "Tell me which documents finished since this morning and give me a link to upload the missing invoice."
Limits and costs
- Polling, the event feed and webhooks cost no credits; they count against your daily request quota (
X-RateLimit-*headers). GET /v1/eventsreturns up to 200 events per page (default 50).- Upload links: one file each, 500 MB default cap, valid 15 minutes, single-use. An unused link expires and its placeholder document is removed; nothing is billed.
- Processing the documents costs the usual credits; see Billing, credits and usage.
Errors
Common errors
| Parameter | Type | Description |
|---|---|---|
| 401 on upload-session | by design | The route accepts only an OAuth token. If your code holds the file, upload it directly instead. |
| 404 on /v1/upload/{token} | new link | The link expired or was already used. Create a new upload session. |
| 402 insufficient_credits | handoff | Fetch the upgrade link and hand it to a person, or let auto top-up refill the balance. |
| 429 rate_limited | slow down | Back off until `X-RateLimit-Reset`; prefer webhooks or the cursor feed over tight polling. |
Next
- Webhooks and events: signing, retries and the event catalog.
- Run a Spec and get results: start a Run and read its table.
- Event feed reference and upload session reference.