Messages — K8 HQ Content API
Messages operations for K8 HQ Content API. Requests, permissions and responses.
Version 1OpenAPI description (JSON)
Before making requests, read the authentication and request requirements.
List, search and read messages in an inbox, change their flags, and move or label them.
Base URL
| Base URL | For |
https://api.k8hq.com/v1 | API tokens and the K8 HQ web app |
Endpoints
Messages
List a label's messages
GET/inboxes/{inbox}/labels/{label}/messages
Newest first, one page at a time. Where date order is available, messages sort by receivedAt descending, then message ID descending, including imported mail. Otherwise they sort by folder UID descending. Cursors are opaque: pass them back unchanged. Date positions use d1: and UID positions use u1: inside their base64 encoding. A UID cursor restarts at the first page when date order is enabled. A date cursor returns 400 (invalid cursor) when date order is unavailable; discard it and request the first page. Pass the page's oldest as before for older messages and its newest as after for newer ones: anchors are message positions, so pages stay exact as mail arrives or is removed. When fewer than a page are newer, after answers the first page; when nothing is left older than before, it answers the oldest page. cursor is the older form of before (nextCursor, absent on the last page).
For API tokens with messages:read and the web app.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
label (path) required | string | Label ID (lbl_…). |
limit (query) | integer | Page size, 1 to 100. |
cursor (query) | string | An opaque nextCursor from this label. The older form of before; pass it back unchanged. A UID cursor restarts at the top when date order is enabled; a date cursor returns 400 when date order is unavailable. Not with before or after. |
before (query) | string | A page's oldest: the messages older than it. Not with after or cursor. |
after (query) | string | A page's newest: the page of messages just newer than it (the first page when fewer remain). Not with before or cursor. With date order, this compares received dates. Mail that arrives later with an older received date, such as imported mail, mail restored by Recover or released held mail, is not included. To find it, load the folder again. The web app adds arrivals from its event stream and sorts them by received date. |
snoozed (query) | hide | Use hide for Inbox to leave out your active snoozes before paging. Applies to both date and UID order. Reads up to three extra membership pages to fill the page; a wholly hidden page still advances its cursors. Other folders and other people are unchanged. |
Response body (JSON)
| Field | Type | Description |
messages required | MessageSummary[] | |
hasNewer | boolean | |
hasOlder | boolean | |
newest | string | The page's newest message as an anchor for after; absent on an empty page. |
nextCursor | string | |
oldest | string | The page's oldest message as an anchor for before; absent on an empty page. |
Responses
| Status | Body | Meaning |
| 200 | JSON | One page of messages. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Get a message
GET/inboxes/{inbox}/messages/{msg}
Metadata plus the message's data key, wrapped to the inbox epoch key. The body comes from /raw. The response carries an ETag (it changes with any change to the message, including data added later) and Cache-Control: private, no-cache: send If-None-Match to get 304 when nothing changed.
For API tokens with messages:read and the web app.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
msg (path) required | string | Message ID (msg_…). |
If-None-Match (header) | string | The ETag of a copy you have. |
Response body (JSON)
| Field | Type | Description |
keyEpoch required | integer | The inbox epoch the message was encrypted under. |
message required | MessageSummary | |
wrappedDek required | string | The message's data key, sealed to the epoch key. |
email | object | Email only. |
Responses
| Status | Body | Meaning |
| 200 | JSON | The message. |
| 304 | | Not modified: your copy is current. |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | A form's response that came past its daily limit (held): release it to open it. |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Teach the spam filter about a message
POST/inboxes/{inbox}/messages/{msg}/feedback
A person's own Spam or Not spam teaches their organization's spam statistics (never another organization's, nor the shared ones). Send the message as your app decrypted it from raw; K8 HQ learns from it only if it matches the message as received over SMTP, and keeps none of it. The same verdict again learns nothing (learned is false); the opposite verdict relearns. People signed in to K8 HQ only: tokens and assistants get 403. Free: K8 HQ's cost, never billed to the organization (the upload included). Off (404) until the organization's spam statistics are set up. You need permission to edit the inbox.
For the web app.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
msg (path) required | string | Message ID (msg_…). |
verdict (query) required | spam | ham | spam, or ham for Not spam. |
Idempotency-Key (header) | string | Up to 255 characters; a retry with the same key gets the first response. |
Response body (JSON)
| Field | Type | Description |
learned required | boolean | False: it already knew this verdict, so nothing changed. |
verdict required | spam | ham | |
Responses
| Status | Body | Meaning |
| 200 | JSON | What the filter now knows about the message. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 402 | application/problem+json | The organization is read-only (read_only, design note 0024): it has been out of credit for 60 days, so nothing can be changed until an owner adds credit. |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | Someone else marked the message meanwhile: try again. |
| 413 | application/problem+json | Over 40 MB. |
| 422 | application/problem+json | The message wasn't received over SMTP (sent, imported, a form's response, a notice), or the body isn't the message as received. |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Change a message's flags
PATCH/inboxes/{inbox}/messages/{msg}/flags
Adds and removes flags by their neutral names. Mail apps connected over IMAP, and other open web app tabs, see the change right away. Other flags (draft, junk, ...) are set by mail apps. With If-Match (the message's ETag), the change applies only to that version. The response's ETag is the new version. Idempotency keys are scoped to caller, method and path; POST and PATCH do not share replay records. Changing flags requires edit access to the inbox or form.
For API tokens with messages:write and the web app.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
msg (path) required | string | Message ID (msg_…). |
If-Match (header) | string | The ETag of the version you read. |
Idempotency-Key (header) | string | Up to 255 characters; a retry with the same key gets the first response. |
Request body (JSON)
| Field | Type | Description |
add | WebFlag[] | |
remove | WebFlag[] | |
{"add":["seen"]}
Response body (JSON)
| Field | Type | Description |
flags required | Flag[] | |
Responses
| Status | Body | Meaning |
| 200 | Flags | The message's flags after the change. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 402 | application/problem+json | The organization is read-only (read_only, design note 0024): it has been out of credit for 60 days, so nothing can be changed until an owner adds credit. |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | Access changed while saving (conflict). Reload and try again. A request with the same Idempotency-Key may also still be running (in_progress). |
| 412 | application/problem+json | If-Match named an older version (version_mismatch). |
| 422 | application/problem+json | The message is in too many folders to change its flags at once (rejected). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Move or label a message
PATCH/inboxes/{inbox}/messages/{msg}/labels
Adds the message to labels and removes it from others, by label ID or role (inbox, archive, spam, trash, sent, drafts). One add with one remove is a move. Adds and removes are applied together, with their events. Removing a message from its last label moves it to Trash. A draft a mail app or K8 HQ saved, removed from Drafts with no other label, is deleted for good. If the draft changed during the request, try again after reloading (409). If a removal targets Trash as the last label, the request returns 422 and keeps any preceding label changes. A mail app can expunge a message from Trash to delete it for good. Adding a label it's already in, or removing one it isn't in, changes nothing. If-Match is not enforced. Surviving messages return their resulting ETag. Purged drafts return empty labels without an ETag. Idempotency keys are scoped to caller, method and path. POST and PATCH have separate replay records. Changing labels requires edit access to the inbox or form.
For API tokens with messages:write and the web app.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
msg (path) required | string | Message ID (msg_…). |
Idempotency-Key (header) | string | Up to 255 characters; a retry with the same key gets the first response. |
Request body (JSON)
| Field | Type | Description |
add | string[] | |
remove | string[] | |
{"add":["archive"],"remove":["inbox"]}
Response body (JSON)
| Field | Type | Description |
labels required | string[] | |
Responses
| Status | Body | Meaning |
| 200 | JSON | The resulting labels. Surviving messages carry an ETag; purged drafts return an empty labels array without an ETag. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 402 | application/problem+json | The organization is read-only (read_only, design note 0024): it has been out of credit for 60 days, so nothing can be changed until an owner adds credit. |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | Access changed while saving (conflict). Reload and try again. A request with the same Idempotency-Key may also still be running (in_progress). |
| 422 | application/problem+json | No such label in this inbox, an attempt to add a response to Forms Held, or an attempt to remove Trash as the last label (rejected). If Trash is the last label, any preceding label changes are saved together. |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Get a message's encrypted content
GET/inboxes/{inbox}/messages/{msg}/raw
The encrypted RFC 5322 message exactly as stored. Decrypt it with the data key from GET /inboxes/{inbox}/messages/{msg}. Messages never change, so the response may be kept by the browser indefinitely (Cache-Control: private, max-age=31536000, immutable).
For API tokens with messages:read and the web app.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
msg (path) required | string | Message ID (msg_…). |
Responses
| Status | Body | Meaning |
| 200 | application/octet-stream | Ciphertext. |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | A form's response that came past its daily limit (held): release it to open it. |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Snooze a message
PUT/inboxes/{inbox}/messages/{msg}/snooze
Only your own reminder changes. Folders and shared read state stay as they are. Requires a signed-in person or a member token with messages:read; assistants and credentials without a member are refused. A read-only inbox grant can use this route. Snoozes one message in Inbox. A new time replaces its old snooze or pin and counts as one messages.snoozes at $0.00002. The time must be at least a minute ahead and no more than 366 days ahead. At most 1,000 active snoozes per person in this inbox. A due message still in Inbox returns with a private pin for 14 days. The message becomes unread if you are the only reader, you can edit the inbox, and the organization can still make changes. No shared snooze event or notification is sent.
For API tokens with messages:read and the web app.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
msg (path) required | string | Message ID (msg_…). |
Idempotency-Key (header) | string | Up to 255 characters; a retry with the same key gets the first response. |
Request body (JSON)
| Field | Type | Description |
until required | string | |
Response body (JSON)
| Field | Type | Description |
createdAt required | string | When you first snoozed the message. Changing an active snooze's return time keeps this original time. |
state required | snoozed | |
until required | string | |
Responses
| Status | Body | Meaning |
| 200 | JSON | The message is snoozed. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 402 | application/problem+json | The organization is read-only. |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | The message is outside Inbox (snooze_not_in_inbox), you already have 1,000 active snoozes (snooze_limit), or inbox access changed (conflict). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Unsnooze a message
DELETE/inboxes/{inbox}/messages/{msg}/snooze
Only your own reminder changes. Folders and shared read state stay as they are. Requires a signed-in person or a member token with messages:read; assistants and credentials without a member are refused. A read-only inbox grant can use this route. Removes a snooze or returned pin. Safe to repeat, including after the message was deleted. Does not pin the message or mark it unread. Allowed while the organization is read-only.
For API tokens with messages:read and the web app.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
msg (path) required | string | Message ID (msg_…). |
Idempotency-Key (header) | string | Up to 255 characters; a retry with the same key gets the first response. |
Responses
| Status | Body | Meaning |
| 204 | | The reminder or pin is removed. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | Inbox access changed while you were removing the reminder (conflict). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Read a K8 Messages summary
GET/inboxes/{inbox}/messages/{msg}/summary
Read or make a summary of one message. Requires a person signed in to K8 HQ, or their live K8 Messages session, current inbox access, permission to use K8, and consent from the organization and inbox. Personal notice and zero-access inboxes are refused. Access and consent are checked again before the result is returned, including for a stored summary. K8 reads at most 32 KiB of one text body, with no attachments or tools. Automated mail is skipped unless includeAutomated is true. A read is recorded as access.content.read and counted once as k8.messages.reads; model tokens are counted separately. Stored summaries are available only through this route, never IMAP or /content.
For the web app.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
msg (path) required | string | Message ID (msg_…). |
org (query) required | string | |
includeAutomated (query) | boolean | Choose true to let K8 read automated mail. Only true and false are accepted. |
Response body (JSON)
| Field | Type | Description |
inboxId required | string | |
messageId required | string | |
producerVersion required | string | null | |
reason required | automated | no_text | | |
schemaVersion required | 1 | |
status required | ready | skipped | |
summary required | any | |
truncated required | boolean | |
labelIds | string[] | The message's folder IDs, including Spam and Trash. |
snooze | Snooze | |
Responses
| Status | Body | Meaning |
| 200 | K8SummaryResponse | A summary, or the reason the message was skipped. Never cached. |
| 400 | application/problem+json | invalid: malformed IDs or query, unknown query keys, or a body. |
| 401 | application/problem+json | unauthenticated: sign in again. |
| 402 | application/problem+json | out_of_credit or read_only. |
| 403 | application/problem+json | needs_person for API tokens or apps; forbidden for a wrong assistant or organization; service_disabled or k8_unavailable; k8_notice_inbox; zero_access; k8_messages_disabled or k8_inbox_disabled. |
| 404 | application/problem+json | not_found: unavailable here, or an inbox or live message the person cannot read. |
| 409 | application/problem+json | in_progress: another request is making this summary. Retry-After is 1 second. |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | rate_limited, k8_cap_reached or k8_member_cap_reached. |
| 502 | application/problem+json | k8_output_invalid: K8 could not make a valid summary. |
| 503 | application/problem+json | unavailable for a failed admission, storage, key or audit check; k8_model_unavailable for an unavailable model. |
Ask a question about one message
POST/inboxes/{inbox}/messages/{msg}/summary/question
Read one message with the person’s exact question using their K8 Messages token. K8 HQ checks current access and consent on every read. Answers are kept sealed for that member and exact question for at most 24 hours. No attachments, tools or other messages enter the call. Each answer made or read counts once as k8.messages.reads; model tokens count separately.
For the web app.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
msg (path) required | string | Message ID (msg_…). |
org (query) required | string | |
Request body (JSON)
| Field | Type | Description |
includeAutomated required | boolean | |
question required | string | |
schemaVersion required | 1 | |
Response body (JSON)
| Field | Type | Description |
inboxId required | string | |
messageId required | string | |
producerVersion required | string | null | |
questionResult required | any | |
reason required | automated | no_text | | |
schemaVersion required | 1 | |
status required | ready | skipped | |
truncated required | boolean | |
Responses
| Status | Body | Meaning |
| 200 | K8QuestionResponse | A summary, or the reason the message was skipped. Never cached. |
| 400 | application/problem+json | invalid: malformed IDs, query or question body, or a body over 8 KiB. |
| 401 | application/problem+json | unauthenticated: sign in again. |
| 402 | application/problem+json | out_of_credit or read_only. |
| 403 | application/problem+json | needs_person for API tokens or apps; forbidden for a wrong assistant or organization; service_disabled or k8_unavailable; k8_notice_inbox; zero_access; k8_messages_disabled or k8_inbox_disabled. |
| 404 | application/problem+json | not_found: unavailable here, or an inbox or live message the person cannot read. |
| 409 | application/problem+json | in_progress: another request is making this summary. Retry-After is 1 second. |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | rate_limited, k8_cap_reached or k8_member_cap_reached. |
| 502 | application/problem+json | k8_output_invalid: K8 could not make a valid summary. |
| 503 | application/problem+json | unavailable for a failed admission, storage, key or audit check; k8_model_unavailable for an unavailable model. |
Get a message's conversation
GET/inboxes/{inbox}/messages/{msg}/thread
Resolves the message's conversation and lists it across this inbox's folders. Uses the same order, paging and access rules as listThreadMessages. A message without a conversation ID returns itself alone, with count 1 and an empty threadId. If the opened message is missing from the conversation index, it is added to the first page when it is newer than that page's cursor, or when there is no cursor. Otherwise it is added to the last page. That page may contain one extra summary, and count is at least 1.
For API tokens with messages:read and the web app.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
msg (path) required | string | Message ID (msg_…). |
limit (query) | integer | Page size, 1 to 100. |
cursor (query) | string | An opaque cursor returned for this conversation. Pass it back unchanged. |
Response body (JSON)
| Field | Type | Description |
count required | integer | Messages stored in the thread, including ones not listed (held or recoverable). |
messages required | any[] | |
threadId required | string | The conversation ID; empty for a message with no conversation ID. |
cursor | string | Pass back unchanged to load older messages. Absent at the end. |
Responses
| Status | Body | Meaning |
| 200 | ThreadMessages | One page of the conversation. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Search an inbox's messages
POST/inboxes/{inbox}/search
Finds messages by their text and by what K8 HQ stores for each one: sender, recipients, subject, date, folder, flags, size and attachments. Newest first, one page at a time: pass nextCursor back as cursor. A POST so your search never appears in a URL; K8 HQ never logs it.
The query follows Gmail's words. Plain words match the subject or the sender (as substrings) or the message text, attachment names and recipients as words; the last word, if it ends the query, also matches as the start of a word (search as you type: negot finds "negotiation"). Every word must match; "quote" a phrase. Message text is searched with the content:read scope (people in the web app always), in inboxes that aren't zero-access, from an index K8 HQ keeps encrypted with the inbox's key; a phrase's candidates are checked against their text a page at a time, so a page may hold fewer than limit messages with a nextCursor to go on. Mail arrived in the last moments, or not yet indexed after it was imported, may be missing: complete is false and pending about how many messages aren't indexed yet. from:, to: (To or Cc), cc:, subject: match those headers. in:inbox, in:sent, in:drafts, in:archive, in:trash, in:spam or in:<folder name>; in:anywhere. is:unread, is:read, is:flagged, is:answered, is:draft. has:attachment. after:2024-03-01 (on or after), before:2024-04-01, in tzOffset's zone. larger:10M, smaller:500K. - before any term excludes it. Organization tags filter in their own tags parameter, by ID. At most 10 terms.
Without label every folder is searched except Trash and Spam, unless the query names them (scope.excluded lists them). Header terms match case-insensitively by substring, as IMAP SEARCH's FROM, TO, CC and SUBJECT do; text matches whole words ("voice" doesn't find "invoice"), case and accents ignored. searchable says what was searched: for a zero-access inbox, message text never is. Mail stored before K8 HQ counted attachments has no count yet: has:attachment leaves it out and searchable.attachmentsUnknown says how many. Assistants (K8) can't search yet. With an access token, one search runs at a time (429 while one is running). A mailbox not searched lately is loaded first; if that takes too long the answer is 503: try again in a moment.
With "semantic": true, the words are also searched by meaning in a mailbox that's searchable by meaning (GET /inboxes/{inbox}/semantic): the semantic part lists up to 20 more messages after the exact matches, best first, filtered by the query's other terms and folders. Each such search is billed to the organization (search.semantic.queries).
For API tokens with messages:read and the web app.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
Request body (JSON)
| Field | Type | Description |
q required | string | The search, as a person types it. |
cursor | string | nextCursor from the previous page. |
label | string | Search this folder only (a label ID). Absent: all folders but Trash and Spam. |
limit | integer | Page size. |
semantic | boolean | Also search the words by meaning (first page only, mailboxes that are searchable by meaning): the response's semantic part, after the exact matches. Needs the same access as message text. |
tags | string[] | Only messages with every one of these organization tags (Tags: tag_ IDs). Tag names are sealed, so they never go in q. With tags, q may be empty. |
tzOffset | integer | Your time zone, in minutes east of UTC, for before: and after: dates. |
{"limit":50,"q":"from:smith has:attachment after:2024-01-01"}
Response body (JSON)
| Field | Type | Description |
complete required | boolean | Whether every message in the inbox was searched. False while its text index is still being built (or catches up with new mail): results may be incomplete. |
messages required | any[] | |
pending required | integer | About how many messages aren't in the text index yet (0 when complete). |
scope required | object | |
searchable required | object | |
total required | integer | How many messages matched in the search index (all pages). Each returned message is checked again on its stored record, so a page may hold fewer than this count suggests when messages changed meanwhile. |
totalExact required | boolean | False when total counts a phrase's candidates not yet checked against their text (an upper bound). |
nextCursor | string | |
semantic | object | With semantic: up to 20 more messages found by meaning, best first, none of them among the exact matches; IDs and list summaries only. |
Responses
| Status | Body | Meaning |
| 200 | JSON | One page of matching messages. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | In the web app: a newer search from the same session replaced this one (it was cancelled). |
| 422 | application/problem+json | A tag filter isn't a live tag in this organization (it may have been deleted). Refused before searching. |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Send mail through a connected app
POST/inboxes/{inbox}/send
Requires an app access token with content.send, current access to the inbox, and consent to sending without asking each time. The inbox must be in compatible mode. Send one Idempotency-Key and no Prefer header. K8 HQ holds the expected charge against both monthly spending limits before sending. Retry with the same key to check a pending or unknown result; a new key could send the mail twice.
For API tokens.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
Idempotency-Key (header) | string | Up to 255 characters; a retry with the same key gets the first response. |
Request body (JSON)
| Field | Type | Description |
channel required | "email" | |
email required | object | |
from required | string | |
to required | string[] | |
Response body (JSON)
| Field | Type | Description |
action required | string | |
id required | string | |
resources required | object | |
state required | pending | unknown | committed | failed | |
Responses
| Status | Body | Meaning |
| 200 | JSON | The send result. |
| 202 | JSON | The send is pending or its result is unknown. |
| 400 | application/problem+json | Invalid send input or headers. |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 402 | application/problem+json | The organization or app monthly spending limit is missing or used up (monthly_budget). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | This Idempotency-Key was used for a different send, or someone else is handling the conversation. |
| 422 | application/problem+json | Choose an address of this inbox as the sender. |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
List your snoozed messages
GET/inboxes/{inbox}/snoozes
Only your own reminder changes. Folders and shared read state stay as they are. Requires a signed-in person or a member token with messages:read; assistants and credentials without a member are refused. A read-only inbox grant can use this route. Snoozed messages are ordered by return time, soonest first. Returned pins are ordered newest first. Expired pins and deleted messages are omitted. Summaries have the same content boundary as folder lists. No other person can see your reminders.
For API tokens with messages:read and the web app.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
Response body (JSON)
| Field | Type | Description |
returned required | ReturnedMessage[] | |
snoozed required | SnoozedMessage[] | |
Responses
| Status | Body | Meaning |
| 200 | Snoozes | Your snoozed messages and returned pins. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
List a conversation's messages
GET/inboxes/{inbox}/threads/{thread}/messages
Messages from all folders in this inbox, including shared drafts, Spam and Trash, newest message ID first. Messages in no folder are excluded. Each summary includes labelIds, draft facts and an optional parent message ID. Pages contain at most 100 summaries; use cursor for older messages. An empty page with a cursor means more messages remain to be checked. Returns 404 only on the first page when no messages can be read and no cursor remains. A continuation with no readable messages returns 200 with an empty messages array; follow its cursor if present. Older messages may be missing until they have been added to the conversation index.
For API tokens with messages:read and the web app.
Parameters
| Name | Type | Description |
inbox (path) required | string | Inbox ID (ibx_…). |
thread (path) required | string | |
limit (query) | integer | Page size, 1 to 100. |
cursor (query) | string | An opaque cursor returned for this conversation. Pass it back unchanged. |
Response body (JSON)
| Field | Type | Description |
count required | integer | Messages stored in the thread, including ones not listed (held or recoverable). |
messages required | any[] | |
threadId required | string | The conversation ID; empty for a message with no conversation ID. |
cursor | string | Pass back unchanged to load older messages. Absent at the end. |
Responses
| Status | Body | Meaning |
| 200 | ThreadMessages | One page of the conversation. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Select message IDs for K8 Messages
POST/k8/messages/select
Execute one fixed message plan using the person’s K8 Messages token. K8 HQ checks every inbox’s current access and consent before searching. Results contain only IDs and received times. Filters combine with AND. Keywords use exact indexed words, with no phrase checks or search operators. At most 500 candidates are checked in pages of 100; at most 50 messages are returned across all inboxes, newest first. A stopped search sets limited to true.
For the web app.
Parameters
| Name | Type | Description |
org (query) required | string | |
Request body (JSON)
| Field | Type | Description |
filter required | object | |
inboxes required | string[] | |
includeAutomated required | boolean | |
schemaVersion required | 1 | |
window required | object | |
maxMessages | integer | |
Response body (JSON)
| Field | Type | Description |
limited required | boolean | |
messages required | object[] | |
schemaVersion required | 1 | |
Responses
| Status | Body | Meaning |
| 200 | JSON | Only matching message IDs and received times. Never cached. |
| 400 | application/problem+json | invalid: malformed IDs, query or plan body, or a body over 8 KiB. |
| 401 | application/problem+json | unauthenticated: sign in again. |
| 402 | application/problem+json | out_of_credit or read_only. |
| 403 | application/problem+json | needs_person for API tokens or apps; forbidden for a wrong assistant or organization; service_disabled or k8_unavailable; k8_notice_inbox; zero_access; k8_messages_disabled or k8_inbox_disabled. |
| 404 | application/problem+json | not_found: unavailable here, or an inbox or live message the person cannot read. |
| 409 | application/problem+json | in_progress: another request is making this summary. Retry-After is 1 second. |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | rate_limited, k8_cap_reached or k8_member_cap_reached. |
| 502 | application/problem+json | k8_plan_invalid: the keyword has no indexed words. |
| 503 | application/problem+json | unavailable for a failed admission, storage, key or audit check; k8_model_unavailable for an unavailable model. |