Threads (conversations): list and search, get with every message, label changes, trash and untrash.

Scopes. Listing and get-thread use gmail.readonly; label changes, trash and untrash gmail.modify.

Functions

get-thread

fn (id: Str): Map
fn (id: Str, opts: Map): Map

GET /users/me/threads/{id} - a thread with its messages (oldest first). Options: format (full default, metadata with metadataHeaders, minimal). Scope: gmail.readonly.

list-all-threads

fn (opts: Any): Vec
fn (opts: Any, limit: Int?): Vec

Every matching thread (all pages), or at most limit. Same opts as list-threads (a Str is a search). Scope: gmail.readonly.

list-threads

fn (): Map
fn (query: Str): Map
fn (opts: Map): Map

GET /users/me/threads - one page of threads: {threads: [{id, snippet, historyId}], nextPageToken?, resultSizeEstimate}. A Str argument is a Gmail search. Options: q, maxResults (max 500), pageToken, labelIds (Vec), includeSpamTrash. Scope: gmail.readonly.

modify-thread

fn (id: Str, add-label-ids: Vec, remove-label-ids: Vec): Map
fn (id: Str, add-label-ids: Vec, remove-label-ids: Vec, opts: Map): Map

POST /users/me/threads/{id}/modify - add and remove label ids on every message in a thread. Returns the thread. Scope: gmail.modify.

thread-emails

fn (id: Str): Vec
fn (id: Str, opts: Map): Vec

A thread's messages as Email records, oldest first (get-thread + ::google::gmail::parse/to-email). Scope: gmail.readonly.

trash-thread

fn (id: Str): Map
fn (id: Str, opts: Map): Map

POST /users/me/threads/{id}/trash - move a whole thread to the trash (recoverable for 30 days). Scope: gmail.modify.

untrash-thread

fn (id: Str): Map
fn (id: Str, opts: Map): Map

POST /users/me/threads/{id}/untrash - restore a thread from the trash. Scope: gmail.modify.