K8 HQ

Messages — K8 HQ Content API

Messages operations for K8 HQ Content API. Requests, permissions and responses.

Version 1OpenAPI description (JSON)

Browse operation groups

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 URLFor
https://api.k8hq.com/v1API 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).
label (path) requiredstringLabel ID (lbl_…).
limit (query)integerPage size, 1 to 100.
cursor (query)stringAn 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)stringA page's oldest: the messages older than it. Not with after or cursor.
after (query)stringA 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)hideUse 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)

FieldTypeDescription
messages requiredMessageSummary[]
hasNewerboolean
hasOlderboolean
neweststringThe page's newest message as an anchor for after; absent on an empty page.
nextCursorstring
oldeststringThe page's oldest message as an anchor for before; absent on an empty page.

Responses

StatusBodyMeaning
200JSONOne page of messages.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo 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.
503application/problem+jsonTemporary 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).
msg (path) requiredstringMessage ID (msg_…).
If-None-Match (header)stringThe ETag of a copy you have.

Response body (JSON)

FieldTypeDescription
keyEpoch requiredintegerThe inbox epoch the message was encrypted under.
message requiredMessageSummary
wrappedDek requiredstringThe message's data key, sealed to the epoch key.
emailobjectEmail only.

Responses

StatusBodyMeaning
200JSONThe message.
304Not modified: your copy is current.
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonA form's response that came past its daily limit (held): release it to open it.
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo 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.
503application/problem+jsonTemporary 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).
msg (path) requiredstringMessage ID (msg_…).
verdict (query) requiredspam | hamspam, or ham for Not spam.
Idempotency-Key (header)stringUp to 255 characters; a retry with the same key gets the first response.

Response body (JSON)

FieldTypeDescription
learned requiredbooleanFalse: it already knew this verdict, so nothing changed.
verdict requiredspam | ham

Responses

StatusBodyMeaning
200JSONWhat the filter now knows about the message.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
402application/problem+jsonThe 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.
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonSomeone else marked the message meanwhile: try again.
413application/problem+jsonOver 40 MB.
422application/problem+jsonThe message wasn't received over SMTP (sent, imported, a form's response, a notice), or the body isn't the message as received.
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo 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.
503application/problem+jsonTemporary 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).
msg (path) requiredstringMessage ID (msg_…).
If-Match (header)stringThe ETag of the version you read.
Idempotency-Key (header)stringUp to 255 characters; a retry with the same key gets the first response.

Request body (JSON)

FieldTypeDescription
addWebFlag[]
removeWebFlag[]
{"add":["seen"]}

Response body (JSON)

FieldTypeDescription
flags requiredFlag[]

Responses

StatusBodyMeaning
200FlagsThe message's flags after the change.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
402application/problem+jsonThe 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.
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonAccess changed while saving (conflict). Reload and try again. A request with the same Idempotency-Key may also still be running (in_progress).
412application/problem+jsonIf-Match named an older version (version_mismatch).
422application/problem+jsonThe message is in too many folders to change its flags at once (rejected).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo 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.
503application/problem+jsonTemporary 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).
msg (path) requiredstringMessage ID (msg_…).
Idempotency-Key (header)stringUp to 255 characters; a retry with the same key gets the first response.

Request body (JSON)

FieldTypeDescription
addstring[]
removestring[]
{"add":["archive"],"remove":["inbox"]}

Response body (JSON)

FieldTypeDescription
labels requiredstring[]

Responses

StatusBodyMeaning
200JSONThe resulting labels. Surviving messages carry an ETag; purged drafts return an empty labels array without an ETag.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
402application/problem+jsonThe 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.
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonAccess changed while saving (conflict). Reload and try again. A request with the same Idempotency-Key may also still be running (in_progress).
422application/problem+jsonNo 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.
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo 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.
503application/problem+jsonTemporary 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).
msg (path) requiredstringMessage ID (msg_…).

Responses

StatusBodyMeaning
200application/octet-streamCiphertext.
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonA form's response that came past its daily limit (held): release it to open it.
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo 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.
503application/problem+jsonTemporary 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).
msg (path) requiredstringMessage ID (msg_…).
Idempotency-Key (header)stringUp to 255 characters; a retry with the same key gets the first response.

Request body (JSON)

FieldTypeDescription
until requiredstring

Response body (JSON)

FieldTypeDescription
createdAt requiredstringWhen you first snoozed the message. Changing an active snooze's return time keeps this original time.
state requiredsnoozed
until requiredstring

Responses

StatusBodyMeaning
200JSONThe message is snoozed.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
402application/problem+jsonThe organization is read-only.
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonThe message is outside Inbox (snooze_not_in_inbox), you already have 1,000 active snoozes (snooze_limit), or inbox access changed (conflict).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo 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.
503application/problem+jsonTemporary 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).
msg (path) requiredstringMessage ID (msg_…).
Idempotency-Key (header)stringUp to 255 characters; a retry with the same key gets the first response.

Responses

StatusBodyMeaning
204The reminder or pin is removed.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonInbox access changed while you were removing the reminder (conflict).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo 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.
503application/problem+jsonTemporary 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).
msg (path) requiredstringMessage ID (msg_…).
org (query) requiredstring
includeAutomated (query)booleanChoose true to let K8 read automated mail. Only true and false are accepted.

Response body (JSON)

FieldTypeDescription
inboxId requiredstring
messageId requiredstring
producerVersion requiredstring | null
reason requiredautomated | no_text |
schemaVersion required1
status requiredready | skipped
summary requiredany
truncated requiredboolean
labelIdsstring[]The message's folder IDs, including Spam and Trash.
snoozeSnooze

Responses

StatusBodyMeaning
200K8SummaryResponseA summary, or the reason the message was skipped. Never cached.
400application/problem+jsoninvalid: malformed IDs or query, unknown query keys, or a body.
401application/problem+jsonunauthenticated: sign in again.
402application/problem+jsonout_of_credit or read_only.
403application/problem+jsonneeds_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.
404application/problem+jsonnot_found: unavailable here, or an inbox or live message the person cannot read.
409application/problem+jsonin_progress: another request is making this summary. Retry-After is 1 second.
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonrate_limited, k8_cap_reached or k8_member_cap_reached.
502application/problem+jsonk8_output_invalid: K8 could not make a valid summary.
503application/problem+jsonunavailable 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).
msg (path) requiredstringMessage ID (msg_…).
org (query) requiredstring

Request body (JSON)

FieldTypeDescription
includeAutomated requiredboolean
question requiredstring
schemaVersion required1

Response body (JSON)

FieldTypeDescription
inboxId requiredstring
messageId requiredstring
producerVersion requiredstring | null
questionResult requiredany
reason requiredautomated | no_text |
schemaVersion required1
status requiredready | skipped
truncated requiredboolean

Responses

StatusBodyMeaning
200K8QuestionResponseA summary, or the reason the message was skipped. Never cached.
400application/problem+jsoninvalid: malformed IDs, query or question body, or a body over 8 KiB.
401application/problem+jsonunauthenticated: sign in again.
402application/problem+jsonout_of_credit or read_only.
403application/problem+jsonneeds_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.
404application/problem+jsonnot_found: unavailable here, or an inbox or live message the person cannot read.
409application/problem+jsonin_progress: another request is making this summary. Retry-After is 1 second.
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonrate_limited, k8_cap_reached or k8_member_cap_reached.
502application/problem+jsonk8_output_invalid: K8 could not make a valid summary.
503application/problem+jsonunavailable 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).
msg (path) requiredstringMessage ID (msg_…).
limit (query)integerPage size, 1 to 100.
cursor (query)stringAn opaque cursor returned for this conversation. Pass it back unchanged.

Response body (JSON)

FieldTypeDescription
count requiredintegerMessages stored in the thread, including ones not listed (held or recoverable).
messages requiredany[]
threadId requiredstringThe conversation ID; empty for a message with no conversation ID.
cursorstringPass back unchanged to load older messages. Absent at the end.

Responses

StatusBodyMeaning
200ThreadMessagesOne page of the conversation.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo 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.
503application/problem+jsonTemporary 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).

Request body (JSON)

FieldTypeDescription
q requiredstringThe search, as a person types it.
cursorstringnextCursor from the previous page.
labelstringSearch this folder only (a label ID). Absent: all folders but Trash and Spam.
limitintegerPage size.
semanticbooleanAlso 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.
tagsstring[]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.
tzOffsetintegerYour 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)

FieldTypeDescription
complete requiredbooleanWhether 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 requiredany[]
pending requiredintegerAbout how many messages aren't in the text index yet (0 when complete).
scope requiredobject
searchable requiredobject
total requiredintegerHow 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 requiredbooleanFalse when total counts a phrase's candidates not yet checked against their text (an upper bound).
nextCursorstring
semanticobjectWith semantic: up to 20 more messages found by meaning, best first, none of them among the exact matches; IDs and list summaries only.

Responses

StatusBodyMeaning
200JSONOne page of matching messages.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonIn the web app: a newer search from the same session replaced this one (it was cancelled).
422application/problem+jsonA tag filter isn't a live tag in this organization (it may have been deleted). Refused before searching.
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo 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.
503application/problem+jsonTemporary 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).
Idempotency-Key (header)stringUp to 255 characters; a retry with the same key gets the first response.

Request body (JSON)

FieldTypeDescription
channel required"email"
email requiredobject
from requiredstring
to requiredstring[]

Response body (JSON)

FieldTypeDescription
action requiredstring
id requiredstring
resources requiredobject
state requiredpending | unknown | committed | failed

Responses

StatusBodyMeaning
200JSONThe send result.
202JSONThe send is pending or its result is unknown.
400application/problem+jsonInvalid send input or headers.
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
402application/problem+jsonThe organization or app monthly spending limit is missing or used up (monthly_budget).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonThis Idempotency-Key was used for a different send, or someone else is handling the conversation.
422application/problem+jsonChoose an address of this inbox as the sender.
426application/problem+jsonK8 HQ has been updated. Reload this page.
503application/problem+jsonTemporary 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).

Response body (JSON)

FieldTypeDescription
returned requiredReturnedMessage[]
snoozed requiredSnoozedMessage[]

Responses

StatusBodyMeaning
200SnoozesYour snoozed messages and returned pins.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo 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.
503application/problem+jsonTemporary 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

NameTypeDescription
inbox (path) requiredstringInbox ID (ibx_…).
thread (path) requiredstring
limit (query)integerPage size, 1 to 100.
cursor (query)stringAn opaque cursor returned for this conversation. Pass it back unchanged.

Response body (JSON)

FieldTypeDescription
count requiredintegerMessages stored in the thread, including ones not listed (held or recoverable).
messages requiredany[]
threadId requiredstringThe conversation ID; empty for a message with no conversation ID.
cursorstringPass back unchanged to load older messages. Absent at the end.

Responses

StatusBodyMeaning
200ThreadMessagesOne page of the conversation.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo 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.
503application/problem+jsonTemporary 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

NameTypeDescription
org (query) requiredstring

Request body (JSON)

FieldTypeDescription
filter requiredobject
inboxes requiredstring[]
includeAutomated requiredboolean
schemaVersion required1
window requiredobject
maxMessagesinteger

Response body (JSON)

FieldTypeDescription
limited requiredboolean
messages requiredobject[]
schemaVersion required1

Responses

StatusBodyMeaning
200JSONOnly matching message IDs and received times. Never cached.
400application/problem+jsoninvalid: malformed IDs, query or plan body, or a body over 8 KiB.
401application/problem+jsonunauthenticated: sign in again.
402application/problem+jsonout_of_credit or read_only.
403application/problem+jsonneeds_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.
404application/problem+jsonnot_found: unavailable here, or an inbox or live message the person cannot read.
409application/problem+jsonin_progress: another request is making this summary. Retry-After is 1 second.
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonrate_limited, k8_cap_reached or k8_member_cap_reached.
502application/problem+jsonk8_plan_invalid: the keyword has no indexed words.
503application/problem+jsonunavailable for a failed admission, storage, key or audit check; k8_model_unavailable for an unavailable model.