Skip to main content
Work through your own connected mailbox in code: find unread supplier emails, pull order numbers out of message bodies, or draft replies for review. The endpoints read the same Gmail and Outlook accounts as the assistant’s email tools, connected under Account → Email. Nothing is ever sent through the API. Drafts are saved in your mailbox; review and send them from Gmail or Outlook, or ask the assistant to send in chat, where you approve each email.

Authentication

A mailbox belongs to one person, so these endpoints need a credential that acts for you:
  • CLI login. omni auth login creates a key bound to your user. Logins made before these scopes existed must run omni auth login again.
  • Your own chat sandbox. Code you run in an assistant chat receives a read-only OMNI_API_KEY for your mailboxes during that run. Saving a draft through the API requires a signed-in session or CLI login.
  • A signed-in session, with organizationId in the query or JSON body.
Organization API keys act for no person and get 403, as do Applications and Computer previews, which serve other viewers. You also need the integration permission the assistant’s email tools require in your organization role.

Choose an account

Returns each connected account’s connectionId, emailAddress, provider (gmail or outlook), isDefault and status. Pass connectionId to the other endpoints to use an account other than your default. A connectionId that is not one of your own accounts is refused.

Search and page through a mailbox

Keep query, readState, maxResults and connectionId the same while you pass each nextPageToken back as pageToken, until it is null. A page can be empty while more pages remain. A token used with different search arguments is refused.

Read a message

Returns the headers, the plain-text body (at most 12,000 characters) and attachment metadata. Use an id from search results, encoded as one path segment; the SDKs encode it for you. Outlook ids can contain /.

Read a conversation

Use a threadId from Search Emails and the same connectionId. Call client.email.getThread({ threadId, connectionId }) in TypeScript or client.email.get_thread(thread_id=thread_id, connection_id=connection_id) in Python. The conversation includes each message’s headers, plain-text body and read and draft state.

Save a draft

Pass replyToMessageId (and threadId for Gmail) to draft the reply in its conversation. When the provider saved a draft whose threading could not be verified, the request fails and data.unverifiedDraftId names the draft so you can find or discard it.

Inspect saved drafts

Call client.email.getDrafts({ connectionId, draftIds }) in TypeScript or client.email.get_drafts(connection_id=connection_id, draft_ids=draft_ids) in Python. Supply the original mailbox connection ID and up to 20 exact draft IDs. Inspect data.results for each distinct draft, including drafts that were already sent, moved or discarded.