Thread Docs

Agent feed

One key, three calls. What an agent gets from Thread, including the message text.

The agent feed is how an AI agent reads a person's email through Thread. The person creates an agent key in their dashboard, chooses which categories of mail it may see and how much of each email (subject only, text with personal details masked, or full text), and hands the key to their agent. The key alone resolves the grant. There is nothing to configure on the agent side and nothing to ask permission for at call time: mail outside the grant is simply absent.

The text is included

If the person granted message text, every email in the feed carries it in body. Agents that print only the subject are dropping a field they were sent. Call GET /me first and read bodyGrade; it tells you exactly what to expect.

Quickest path

export THREAD_API_KEY=thread_sk_...   # from the person's dashboard, Agent keys
npx @jointhread/mail me               # what this key can read
npx @jointhread/mail new              # everything new, one JSON object per line, text included
npx @jointhread/mail read <id>        # one email with its full text

The CLI is a thin wrapper over the three calls below. Use it or call them directly.

The calls

All calls take Authorization: Bearer <key>. Base URL: https://gw.thread.xyz.

GET /me: what this key can read

Call this first. It describes the grant and discloses no mail. It is free: it never counts against the key's daily limit.

{
  "mailbox": "you@example.com",
  "provider": "gmail",
  "keyName": "claude-code",
  "categories": ["financial", "travel", "work"],
  "narrowedBy": [],
  "bodyGrade": "masked",
  "attachments": true,
  "dailyLimit": null,
  "expiresAt": "2027-02-17T00:00:00.000Z",
  "calendar": [],
  "feed": {
    "endpoint": "/emails",
    "singleEmail": "/emails/{id}",
    "attachment": "/emails/{id}/attachments/{attachmentId}",
    "firstCall": "GET /emails returns the 50 most recent in-scope emails on the first call ..."
  }
}
FieldMeaning
categoriesCatalog slugs the key may read, or the string "all" for a whole-inbox grant.
narrowedByNon-empty when the grant is further narrowed by sender, subject or an advanced rule.
bodyGradesubject_only, masked or full. What body will hold on every email.
attachmentsWhether attachment metadata and downloads are granted.
dailyLimitAllowed calls per UTC day, or null. Discover it here instead of by hitting 429.
expiresAtWhen the grant ends. Grants default to 90 days.

GET /emails: the feed

A bare call returns everything new since your last bare call, newest first, then moves your position forward. The first call after a mailbox is connected returns the 50 most recent in-scope emails, read or unread. Save each batch before you act on it: the same emails will not come back.

Add ?limit=20 to peek at the last 20 in-scope emails without moving your position. ?since= (ISO 8601) and ?cursor= are peeks too.

{
  "emails": [
    {
      "id": "1a1c6f2da569fa4d",
      "from": "billing@vendor.com",
      "to": ["you@example.com"],
      "subject": "Invoice INV-2041 due Dec 1",
      "receivedAt": "2026-11-19T09:30:00.000Z",
      "labels": ["financial", "invoice"],
      "mailboxLabels": ["INBOX", "UNREAD"],
      "isUnread": true,
      "threadId": "1a1c6f2da569fa4d",
      "hasAttachment": true,
      "body": "Hi, your invoice for card [redacted-card] is attached. Pay by Dec 1.",
      "masked": true,
      "bodyGrade": "masked",
      "attachments": [{ "id": "0.1", "name": "INV-2041.pdf", "type": "application/pdf", "size": 84213 }]
    }
  ],
  "cursor": null
}

Three states of body, each distinguishable without guessing:

bodybodyGradeMeaning
a stringmasked or fullThe text, at the granted grade. masked: true means personal details were redacted.
nullsubject_onlyThis key was never granted text. Work from subject, from and labels.
absentabsentThe key has text access, but this one email is outside its text scope.

labels are Thread's labels, what the grant is written against. mailboxLabels are the mailbox's own (Gmail INBOX, UNREAD, Outlook categories, IMAP flags). Reason about inbox state with the second, about what an email is with the first.

GET /emails/{id}: one email

The same object, for one email, by the id from the feed. Returns 404 when the email does not exist or is outside the grant; the two are indistinguishable by design.

GET /emails/{id}/attachments/{attachmentId}: the bytes

Raw bytes with Content-Type and Content-Disposition. The handle comes from the email's attachments array. 404 means not granted or gone.

Errors you will actually meet

StatusWhat it meansWhat to do
401Key invalid, revoked, or no active grantStop. Ask the person to check the key in their dashboard.
404Out of scope or nonexistentTreat as "not available to me".
429Daily limit reachedWait until 00:00 UTC. Retrying sooner spends nothing and gains nothing.
503Thread or the provider had a temporary problemRetry in a few minutes.

An empty emails array is not an error. It means nothing new is in scope.

Cadence

Thread polls the mailbox about once a minute, so polling faster gets you nothing. Every successful call, including an empty one, counts against the daily limit if the person set one; GET /me does not. If dailyLimit is set, poll no faster than every 86400 / dailyLimit seconds and leave room for the single-email reads you make between polls.

What Thread keeps

Three facts per email: its id, the sender's address, and the labels Thread assigned. Subject, text and attachments are fetched live from the mailbox when your key asks and are never stored. Every call is listed on the person's Activity page: which key, which action, allowed or denied.