Skip to main content

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, read and operations for the examples below; events:read or read for the event feed; write (or events: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 example GET /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/events lists every event in your workspace. Pass after=<next_cursor> to read oldest-first from where you stopped, so nothing is missed; filter with event_type and since.
curl: read new events since the last cursor
curl "https://api.talonic.com/v1/events?after=$LAST_CURSOR&event_type=document.extracted,result.flagged&limit=100" \
  -H "Authorization: Bearer $TALONIC_API_KEY"
Node: a cursor loop that survives restarts
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))
}
Response (GET /v1/events)
{
  "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.

Response (POST /v1/documents/upload-session)
{
  "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

ParameterTypeDescription
Buy credits or change planGET /v1/billing/upgrade-linkReturns `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 computerPOST /v1/documents/upload-sessionReturns a single-use `upload_url`, valid 15 minutes.
Connect a mailbox or driveapp: SourcesGmail, 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 destinationapp: DeliveryGoogle Drive, OneDrive and Google Sheets destinations also need the provider sign-in, done once under **Delivery**.
Approve an agentOAuth consentThe 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/events returns 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

ParameterTypeDescription
401 on upload-sessionby designThe route accepts only an OAuth token. If your code holds the file, upload it directly instead.
404 on /v1/upload/{token}new linkThe link expired or was already used. Create a new upload session.
402 insufficient_creditshandoffFetch the upgrade link and hand it to a person, or let auto top-up refill the balance.
429 rate_limitedslow downBack off until `X-RateLimit-Reset`; prefer webhooks or the cursor feed over tight polling.

Next

Frequently asked questions

Should I poll, use webhooks or read the event feed?+
Poll when you started the work and will wait for it. Use webhooks when you have a public endpoint and want to be told. Use the event feed with a cursor when you cannot receive inbound calls or need to catch up after downtime.
How does an agent upload a file that is on my laptop?+
It creates an upload link with POST /v1/documents/upload-session (or the talonic_request_upload tool). You open the link and pick the file; it goes straight to Talonic. The link is single-use and lasts 15 minutes.
Can I connect Gmail or Google Drive purely from the API?+
Not yet. Those providers require a person to approve their consent screen, which happens once in Sources in the app. After that the source syncs and everything else works from the API.