openemail.threads
この名前空間のすべてのメソッドの、シグネチャ、パラメーター、戻り値、例。
メソッド
Read, search, label, trash and snooze conversations in the mailbox.
threads.list()threads.listAll()threads.iterate()threads.get()threads.update()threads.trash()threads.snooze()threads.unsnooze()threads.listAttachments()threads.listNotes()threads.createNote()threads.updateNote()threads.deleteNote()threads.reorderNotes()threads.counts()threads.summary()threads.restore()threads.delete()threads.unsubscribe()threads.getEvent()
threads.list()
List one page of threads in a folder
list(options?: ThreadListOptions): Promise<Page<ThreadSummaryResource>>Returns one page of threads from the mailbox index, ordered by each thread's latest message with the newest first unless sort says otherwise. A row is only object and id, so call get for the messages, labels and unread state.
sort, dateFrom, dateTo and fromContacts are the thread list's own controls: the four orders, a date range read against the newest message on each thread, and a filter to mail from saved contacts. Every order pages to the end, and a cursor carries on in the order it was handed out in, so send the same filters with it.
folder defaults to inbox and is matched against label ids after being upper cased, so sent, archive, spam, trash, draft, snoozed, starred and unread all work, bin is read as trash, and a user label id works as a folder too. A name that matches nothing returns an empty page rather than an error. labelIds narrows the folder further: a thread must carry the folder label and every id you pass.
query takes the mailbox search syntax. Plain words must all appear, and each matches loosely: case, accents and separators are ignored and part of a longer word counts, so min finds "Benjamin". A quoted phrase is matched as written apart from case and accents, so "ben jamin" does not find "Ben-Jamin" while "quarterly invoice" finds "Quarterly invoice". When nothing matches exactly, close spellings are returned instead, so benjimin finds "Benjamin": a plain word, or the value of from:, to:, cc:, subject:, body:, filename: or label:, may differ from the start of a word by one typo when it has four to seven letters and by two when it has eight or more, while a quoted phrase, a word containing a digit, a shorter word and an excluded word still match exactly, and the pages that follow keep matching the same way. Filler words such as the, about or emails are dropped from a list of plain words when something else is left to search for, so emails from john searches for john alone. Operators such as from:, to:, subject:, label:, is:unread, has:pdf, after:2026/01/31 and newer_than:7d narrow it, and OR, parentheses and a leading - combine them. Recipients are stored as one list without roles and never hold a Bcc, so cc: reads the same field as to: and bcc: matches nothing of its own. from:me is mail you sent, and to:me is mail carrying one of your own addresses, aliases included, among its recipients or as the address it was delivered to.
Words and the from:, to:, cc:, subject: and body: operators read only the newest message on each thread: its sender, its recipients, its subject and the first 4,000 characters of its body with markup stripped. filename: and has: read every attachment on the whole conversation, and label:, in: and is: read the whole conversation. A plain word also matches the name of any attachment on the conversation, whichever message carried it. A sealed message has no body text to match. The search stays inside folder unless the query names a folder itself, with in: or a folder is: such as is:sent, and in:anywhere searches every folder, on its own as well as beside other terms. A drafts listing is the exception and stays in drafts whatever the query names.
Dates read the newest activity on the thread, in UTC. after: includes the day it names and before: excludes it, and a date can be written YYYY/MM/DD, YYYY-MM-DD, YYYYMMDD, as a bare year, or as epoch seconds or milliseconds. A short date reads day first (16/09/2026), unless the second number cannot be a month (09/16/2026), and a number above 12 settles it either way. The API pages with an opaque pageToken, which the SDK hands back as nextCursor and accepts as options.cursor.
パラメーター
options.folderstringLabel the threads must carry, case insensitive. Defaults to
inbox, andbinis read astrash.options.querystringMailbox search. Plain words must all appear and match loosely, a quoted phrase has to appear as written, filler words are dropped when something else is left to search for, and operators such as
from:ada,has:pdfandin:anywherenarrow it.options.labelIdsstring | Array<string>Label ids a thread must all carry on top of
folder, matched exactly. An array is sent comma separated.options.sortThreadSortnewest(the default),oldest,senderorsubject, the four orders of the thread list in the app.senderandsubjectare alphabetical, newest first within one sender or subject.options.dateFromDate | stringKeeps threads whose newest message arrived at or after this instant. A
Dateor an ISO 8601 string with a time and an offset.options.dateToDate | stringKeeps threads whose newest message arrived at or before this instant. Both ends are included, and
dateFromafterdateTois a 422.options.fromContactsbooleanWhen true, keeps only threads whose newest message came from a saved contact. A key limited to some addresses reads the contacts its owner saved.
options.limitnumberThreads per page, a whole number from 1 to 100. Defaults to 25.
options.cursorstringThe
nextCursorof the previous page, passed back unchanged.options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
Page<ThreadSummaryResource> with items, hasMore and nextCursor. Each item is { object: 'thread', id }.
例
const page = await openemail.threads.list({ folder: 'inbox', query: 'from:ada has:pdf', limit: 50 }) const lastWeek = await openemail.threads.list({ sort: 'oldest', dateFrom: new Date(Date.now() - 7 * 864e5), fromContacts: true })console.log(lastWeek.items.length) console.log(page.items.map((thread) => thread.id)) if (page.nextCursor) { const next = await openemail.threads.list({ folder: 'inbox', query: 'from:ada has:pdf', limit: 50, cursor: page.nextCursor }) console.log(next.items.length)}注意事項
The server offers a cursor whenever a page comes back full, so
hasMorecan be true on what turns out to be the last page, and the next call then returns no items.Threads that arrived in the same instant are ordered by id, so a page boundary between two of them never skips or repeats one.
A thread that receives mail while you page moves ahead of the cursor and is not returned by later pages.
A value
querycannot use is ignored rather than narrowing, so a typo in a value widens the result instead of emptying it. That coverscategory:,larger:,smaller:,size:,messagesize:,list:,rfc822msgid:,received:andsent:, the category words such asis:promotions, ahas:word naming no kind of attachment, animportance:other thanhighorlow, an unreadable date and a duration whose unit is noth,d,w,mory. An operator name it does not know,project:for instance, is searched as plain text.A narrowed key only sees threads delivered to the addresses it covers, every address on a whole domain it holds included. A thread still has to carry the folder and every one of
labelIds, the same as for any other key.
ほかの提供先
threads.listAll()
Collect every thread in a folder into one array
listAll(options?: ThreadListOptions): Promise<Array<ThreadSummaryResource>>Walks every page with the same filters as list and resolves once the last page is in, so the whole result sits in memory at once. That suits a label view or a small folder. For a large inbox, iterate lets you stop as soon as you have what you need.
Each request asks for options.limit threads, 25 when you leave it out, so raising it to 100 needs a quarter of the round trips. Passing options.cursor starts the walk from that page instead of the first. The walk ends at the first empty page or when the server stops offering a cursor.
A failure on any page rejects the promise and discards everything collected so far.
パラメーター
options.folderstringLabel the threads must carry, case insensitive. Defaults to
inbox.options.querystringMailbox search, as in
list. Plain words must all appear and match loosely, a quoted phrase has to appear as written, filler words are dropped when something else is left to search for, and operators such asfrom:ada,has:pdfandin:anywherenarrow it.options.labelIdsstring | Array<string>Label ids a thread must all carry on top of
folder, matched exactly.options.sortThreadSortnewest(the default),oldest,senderorsubject, the four orders of the thread list in the app.senderandsubjectare alphabetical, newest first within one sender or subject.options.dateFromDate | stringKeeps threads whose newest message arrived at or after this instant. A
Dateor an ISO 8601 string with a time and an offset.options.dateToDate | stringKeeps threads whose newest message arrived at or before this instant. Both ends are included, and
dateFromafterdateTois a 422.options.fromContactsbooleanWhen true, keeps only threads whose newest message came from a saved contact. A key limited to some addresses reads the contacts its owner saved.
options.limitnumberPage size for each request, a whole number from 1 to 100. Defaults to 25.
options.cursorstringA
nextCursorto start the walk from instead of the first page.options.signalAbortSignalCancels the request in flight and rejects the whole walk.
options.apiKeystringOverrides the client's API key for every page of this walk.
戻り値
Array<ThreadSummaryResource>, every matching thread as { object: 'thread', id }, newest first.
例
const snoozed = await openemail.threads.listAll({ folder: 'snoozed', limit: 100 }) console.log(`${snoozed.length} threads are waiting to wake`)注意事項
Each page is its own request with its own retries, so a network blip on page five does not restart the walk from page one.
Rows are ids only. Reading the threads afterwards is one
getper id.
ほかの提供先
- API
GET /threads
threads.iterate()
Stream threads one at a time across pages
iterate(options?: ThreadListOptions): AsyncGenerator<ThreadSummaryResource, void, undefined>Returns an async generator that yields threads one by one and requests the next page only when the current one is used up. Nothing is fetched until the loop starts, and breaking out of it stops further requests, so this is the way to scan a large folder for the first match.
Filters behave as in list, and each request asks for options.limit threads, 25 by default. The cursor marks a position in time rather than a row count, so trashing, archiving or relabelling threads inside the loop does not make the walk skip the ones after them. A thread that receives new mail during the walk moves ahead of the cursor and is not yielded again.
パラメーター
options.folderstringLabel the threads must carry, case insensitive. Defaults to
inbox.options.querystringMailbox search, as in
list. Plain words must all appear and match loosely, a quoted phrase has to appear as written, filler words are dropped when something else is left to search for, and operators such asfrom:ada,has:pdfandin:anywherenarrow it.options.labelIdsstring | Array<string>Label ids a thread must all carry on top of
folder, matched exactly.options.sortThreadSortnewest(the default),oldest,senderorsubject, the four orders of the thread list in the app.senderandsubjectare alphabetical, newest first within one sender or subject.options.dateFromDate | stringKeeps threads whose newest message arrived at or after this instant. A
Dateor an ISO 8601 string with a time and an offset.options.dateToDate | stringKeeps threads whose newest message arrived at or before this instant. Both ends are included, and
dateFromafterdateTois a 422.options.fromContactsbooleanWhen true, keeps only threads whose newest message came from a saved contact. A key limited to some addresses reads the contacts its owner saved.
options.limitnumberPage size for each request, a whole number from 1 to 100. Defaults to 25.
options.cursorstringA
nextCursorto start from instead of the first page.options.signalAbortSignalCancels the request in flight and ends the iteration with that error.
options.apiKeystringOverrides the client's API key for every page of this walk.
戻り値
AsyncGenerator<ThreadSummaryResource, void, undefined> yielding { object: 'thread', id } per step.
例
for await (const summary of openemail.threads.iterate({ folder: 'inbox', query: 'receipt newer_than:30d', limit: 100 })) { const thread = await openemail.threads.get(summary.id) if (thread.hasUnread) { await openemail.threads.update(summary.id, { read: true }) }}注意事項
The generator is lazy, so an abandoned loop costs only the pages it consumed.
An aborted
options.signalthrowsOpenEmailNetworkErrorout of the loop rather than ending it quietly.
ほかの提供先
- API
GET /threads
threads.get()
Read a thread with every message on it
get(id: string, options?: RequestScope): Promise<ThreadResource>Returns the whole conversation, oldest message first, with the labels the thread sits in and its unread state. Unsent draft replies are included in messages with isDraft: true, which is why messageCount, the length of messages, can be higher than totalReplies, which counts only real messages.
Messages are passed through as the mailbox stored them, so MessageResource is an open record rather than a fixed field list. The one field the API commits to is encryption. When encryption.format is pgp-mime, pgp-inline or smime-encrypted, the message is sealed and its body is empty or holds armour. pgp-signed and smime-signed are ordinary readable mail. A message with no encryption at all was stored before detection existed, so its absence says nothing about whether it was plaintext.
Each message's tags and unread are overwritten on read with the thread's current labels and unread flag, so they describe the thread and not that one message.
パラメーター
idstring必須Thread id, as returned by
listor carried on a message.options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
ThreadResource with id echoed from the request, messages, labels as { id, name, color }, messageCount, hasUnread, totalReplies and deliveredTo, the workspace address the thread belongs to (null when none was recorded).
例
const thread = await openemail.threads.get('CAHk7pQ2x9LmZ4-mail.example.com')const sealedFormats = ['pgp-mime', 'pgp-inline', 'smime-encrypted'] for (const message of thread.messages) { const sealed = sealedFormats.includes(String(message.encryption?.format)) console.log(message.id, message.subject, sealed ? 'sealed' : 'readable')} console.log(thread.labels.map((label) => label.id))注意事項
A thread delivered to no address the key covers is a 404, exactly like one that does not exist.
hasUnreadmirrors theUNREADlabel, andupdatewithreadis how you change it.Draft ids from
drafts.listopen here too, because a draft is stored as a thread labelledDRAFT.
ほかの提供先
threads.update()
Mark a thread read or unread and change its labels
update(id: string, patch: ThreadPatch, options?: RequestScope): Promise<UpdatedThreadResource>Adds and removes labels on a thread in one call. read is shorthand for the UNREAD label: true removes it and false adds it. At least one of read, a non empty addLabelIds or a non empty removeLabelIds is required, each list takes at most 50 ids, and any other key is a 422 because the body is strict.
Folders are labels too, so archiving is addLabelIds: ['ARCHIVE'] with removeLabelIds: ['INBOX'], the same pair the app uses. TRASH, SNOOZED and DRAFT are refused in either list with 422 label_not_directly_settable, because each needs a step this route cannot take. Use trash and snooze for those.
User label ids come from labels.list, and the system ids such as ARCHIVE, STARRED and UNREAD are taken in any case. An id in addLabelIds that names no label is refused with 422 label_not_found and nothing on the thread changes, so create the label with labels.create first. An unknown id in removeLabelIds is not an error, since the thread cannot carry it. Removals are applied before additions, so an id in both lists ends up on the thread.
パラメーター
idstring必須Thread id.
patch.readbooleantrueremovesUNREAD,falseadds it.patch.addLabelIdsArray<string>Label ids to put on the thread, at most 50, each naming a label, never
TRASH,SNOOZEDorDRAFT.patch.removeLabelIdsArray<string>Label ids to take off the thread, at most 50, never
TRASH,SNOOZEDorDRAFT.options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
UpdatedThreadResource with id, addedLabelIds and removedLabelIds. Both lists echo the request, with system ids upper cased, plus the UNREAD change that read implies, not what actually changed.
例
const updated = await openemail.threads.update('CAHk7pQ2x9LmZ4-mail.example.com', { read: true, addLabelIds: ['ARCHIVE', 'USER_RECEIPTS'], removeLabelIds: ['INBOX']}) console.log(updated.addedLabelIds, updated.removedLabelIds)注意事項
The SDK retries this call after a network failure or a retryable status, which is safe because adding a label already present or removing one already gone changes nothing.
The thread is looked up before the body is validated, so a wrong id is a 404 even when the patch is also invalid.
User label ids look like
USER_RECEIPTS. Take them fromlabels.listrather than building them.
ほかの提供先
threads.trash()
Move a thread to the Bin
trash(id: string, options?: RequestScope): Promise<TrashedThreadResource>Adds TRASH and removes INBOX, SPAM, SNOOZED and ARCHIVE in one step, which is what the app's delete does. Doing half of that through update would leave the thread listed in both the Bin and its old folder, which is why update refuses TRASH.
Nothing is deleted. The thread stays readable with get and lists under folder: 'trash'. Calling this on a thread that is already in the Bin changes nothing and returns the same body, which is why the SDK retries it.
パラメーター
idstring必須Thread id.
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
TrashedThreadResource, { object: 'thread', id, trashed: true }.
例
const result = await openemail.threads.trash('CAHk7pQ2x9LmZ4-mail.example.com') console.log(result.id, result.trashed)注意事項
restoretakes a thread back out of the Bin.updaterefusesTRASHinremoveLabelIdsas well as inaddLabelIds.Trashing a snoozed thread also cancels its scheduled wake, so it does not reappear in the inbox later.
A thread delivered to no address the key covers is a 404.
ほかの提供先
threads.snooze()
Hide a thread until a set time
snooze(id: string, wakeAt: Date | string, options?: RequestScope): Promise<SnoozedThreadResource>Adds SNOOZED, removes INBOX and stores a wake time, all in one call. Both halves matter: the label hides the thread and the stored wake time is what brings it back. A thread labelled SNOOZED any other way would never return, which is why update refuses that label.
wakeAt takes a Date or an ISO 8601 string. The SDK converts a Date with toISOString(), and the server answers 422 invalid_parameter on wakeAt when the value does not parse or is not in the future. Snoozing a thread that is already snoozed replaces its wake time.
Threads are woken by an hourly sweep, so one comes back at the first sweep after wakeAt, up to about an hour late. Opening the Snoozed folder in the app wakes overdue threads straight away. A thread always wakes into the inbox.
パラメーター
idstring必須Thread id.
wakeAtDate | string必須When the thread should return, a future instant.
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
SnoozedThreadResource with id and snoozedUntil, the wake time normalised to a UTC ISO string.
例
const wakeAt = new Date()wakeAt.setUTCDate(wakeAt.getUTCDate() + 1)wakeAt.setUTCHours(9, 0, 0, 0) const snoozed = await openemail.threads.snooze('CAHk7pQ2x9LmZ4-mail.example.com', wakeAt) console.log(snoozed.snoozedUntil)注意事項
Only
INBOXis removed, so a thread snoozed from another folder keeps that folder's label while it sleeps and wakes carrying both.A string with no zone offset is read in the server's local zone, so send
Zor an explicit offset.The SDK retries this call, which is safe because a repeat stores the same wake time.
ほかの提供先
threads.unsnooze()
Bring a snoozed thread back now
unsnooze(id: string, options?: RequestScope): Promise<SnoozedThreadResource>Adds INBOX, removes SNOOZED and deletes the stored wake time, so the thread returns immediately and the hourly sweep leaves it alone afterwards.
A thread that is not snoozed is left where it is, so an archived thread stays archived, and the response still reports snoozedUntil: null.
パラメーター
idstring必須Thread id.
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
SnoozedThreadResource with id and snoozedUntil set to null.
例
const thread = await openemail.threads.get('CAHk7pQ2x9LmZ4-mail.example.com') if (thread.labels.some((label) => label.id === 'SNOOZED')) { const result = await openemail.threads.unsnooze(thread.id) console.log(result.snoozedUntil)}注意事項
Removing
SNOOZEDthroughupdateis refused with 422label_not_directly_settable, because it would leave the wake time scheduled.Safe to retry, and the SDK does: a second call applies the same labels and deletes a wake time that is already gone.
ほかの提供先
threads.listAttachments()
List a message's attachments with their content
listAttachments(id: string, messageId: string, options?: RequestScope): Promise<Array<AttachmentResource>>Returns the attachments of one message with each file's bytes inlined as base64 in content. The thread is checked first and then the message, so a messageId that is not on that thread is a 404 even when it exists elsewhere in the mailbox. Take message ids from the messages of threads.get.
This is the display list. The ciphertext of an encrypted envelope is in it and downloads like any other file, named encrypted-message.asc when it arrived without a name. The PGP/MIME version part and any detached signature are held out on purpose. Every part keeps its id in the message's encryption.parts, and for those two the id is a correlation key only: no route returns their bytes.
Every file comes back whole in a single response, with no size cap and no range reads, so a message carrying large files makes a large response.
パラメーター
idstring必須Thread id the message belongs to.
messageIdstring必須Message id from that thread's
messages.options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
Array<AttachmentResource>, each with attachmentId, filename, contentType, size and base64 content.
例
const thread = await openemail.threads.get('CAHk7pQ2x9LmZ4-mail.example.com')const latest = thread.messages[thread.messages.length - 1]const files = await openemail.threads.listAttachments(thread.id, String(latest.id)) for (const file of files) { const bytes = Buffer.from(file.content ?? '', 'base64') console.log(file.filename, file.contentType, bytes.byteLength)}注意事項
When the stored bytes for a file cannot be found,
contentis an empty string rather than null, so check its length before decoding.Both ids must match: a real message id paired with the wrong thread id is a 404
resource_not_found.A thread delivered to no address the key covers is a 404 before the message is looked at.
ほかの提供先
threads.listNotes()
List the notes on a thread
listNotes(id: string, options?: RequestScope): Promise<Array<ThreadNoteResource>>Resolves every note on one thread, the Notes panel of the reading pane: pinned notes first, then the rest in the order they were arranged.
Notes are private to a person. A key reads and writes the notes of the workspace owner, and an app those of the person who connected it. A key limited to particular addresses reaches only the notes on threads that arrived at them.
パラメーター
idstring必須Thread id.
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
Array<ThreadNoteResource>, each with id, threadId, content, color, pinned, order, createdAt and updatedAt.
例
const notes = await openemail.threads.listNotes('CAHk7pQ2x9LmZ4-mail.example.com') for (const note of notes) console.log(note.pinned ? 'pinned' : '', note.content)注意事項
A thread delivered to no address the key covers is a 404.
ほかの提供先
threads.createNote()
Add a note to a thread
createNote(id: string, body: ThreadNoteCreate, options?: RequestScope): Promise<ThreadNoteResource>Pins a private note to a thread, as the Notes panel does. A new note goes after the others, and pinned keeps it at the top.
Notes are private to a person. A key reads and writes the notes of the workspace owner, and an app those of the person who connected it. A key limited to particular addresses reaches only the notes on threads that arrived at them.
パラメーター
idstring必須Thread id.
body.contentstring必須The text of the note, up to 20,000 characters. Leading and trailing spaces are trimmed.
body.colorThreadNoteColorOne of the eight the app offers:
default,red,orange,yellow,green,blue,purpleorpink. Defaults todefault.body.pinnedbooleanKeeps the note above the others. Defaults to false.
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
ThreadNoteResource for the new note.
例
const note = await openemail.threads.createNote('CAHk7pQ2x9LmZ4-mail.example.com', { content: 'Waiting on the signed contract before replying.', color: 'yellow', pinned: true}) console.log(note.id)注意事項
The SDK does not retry it, because a second call would add a second note.
ほかの提供先
threads.updateNote()
Change a note
updateNote(id: string, noteId: string, patch: ThreadNoteUpdate, options?: RequestScope): Promise<ThreadNoteResource>Changes the text of a note, its colour or whether it is pinned. Give at least one of the three. A note id that is not on this thread is a 404, even when the note exists on another thread.
パラメーター
idstring必須Thread id.
noteIdstring必須The note's id, from
listNotes.patch.contentstringThe new text, up to 20,000 characters.
patch.colorThreadNoteColorThe new colour.
patch.pinnedbooleanPins or unpins it.
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
ThreadNoteResource as it is now.
例
const note = await openemail.threads.updateNote('CAHk7pQ2x9LmZ4-mail.example.com', 'b3d1f0c2-7a4e-4f7b-9c1d-2e8f6a5b4c3d', { pinned: false }) console.log(note.pinned)注意事項
Safe to repeat: setting the same values twice leaves the note as it was.
ほかの提供先
threads.deleteNote()
Delete a note
deleteNote(id: string, noteId: string, options?: RequestScope): Promise<DeletedThreadNoteResource>Deletes a note for good. There is no bin for notes.
パラメーター
idstring必須Thread id.
noteIdstring必須The note's id, from
listNotes.options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
DeletedThreadNoteResource, { object: 'note', id, threadId, deleted: true }.
例
await openemail.threads.deleteNote('CAHk7pQ2x9LmZ4-mail.example.com', 'b3d1f0c2-7a4e-4f7b-9c1d-2e8f6a5b4c3d')注意事項
The SDK does not retry a delete. A 404 on your own second attempt after a lost response means the first one worked.
ほかの提供先
threads.reorderNotes()
Arrange the notes on a thread
reorderNotes(id: string, ids: Array<string>, options?: RequestScope): Promise<Array<ThreadNoteResource>>Sets the order of every note on a thread at once, first to last, as dragging them in the Notes panel does. Pinned notes still come first.
ids has to name every note on the thread exactly once. Anything else is a 422 invalid_parameter on ids, and nothing moves.
パラメーター
idstring必須Thread id.
idsArray<string>必須Every note id on the thread, in the order you want them.
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
Array<ThreadNoteResource> in the new order.
例
const notes = await openemail.threads.listNotes('CAHk7pQ2x9LmZ4-mail.example.com')const reversed = notes.map((note) => note.id).reverse() await openemail.threads.reorderNotes('CAHk7pQ2x9LmZ4-mail.example.com', reversed)注意事項
Safe to repeat: the same order twice leaves the notes as they were.
ほかの提供先
threads.counts()
Count the mail in each folder
counts(options?: ThreadCountsOptions): Promise<MailboxCountsResource>Resolves what the sidebar of the app shows: how many conversations each folder holds and how many of them are unread, and how many inbox conversations arrived at each address of the workspace.
folders has one row per folder, named by its label id in lower case: inbox, sent, spam, archive, trash and snoozed, then unread, whose count is the unread conversations in the inbox. addresses counts the inbox per address the mail was delivered to, with null for mail that recorded none.
A key limited to particular addresses counts only the mail that arrived at them. address narrows every count to one address, and one the key does not reach counts nothing rather than failing.
パラメーター
options.addressstringCount only the mail delivered to this address.
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
MailboxCountsResource, { object: 'mailbox_counts', folders, addresses }, each folder { label, count, unread } and each address { address, count }.
例
const counts = await openemail.threads.counts() const inbox = counts.folders.find((folder) => folder.label === 'inbox') console.log(`${inbox?.unread ?? 0} unread of ${inbox?.count ?? 0}`) for (const row of counts.addresses) console.log(row.address ?? '(none)', row.count)注意事項
Read only, so the SDK retries it after a network failure like any other read.
ほかの提供先
threads.summary()
Read the summary of a thread
summary(id: string, options?: RequestScope): Promise<ThreadAiSummaryResource>Resolves the short AI summary the reading pane shows above a thread. A summary is written once and kept, and written again when a new message arrives, so reading one is cheap.
state is ready with the text in summary, pending while one is being written, or none when there is nothing to summarise, such as a thread holding a message that arrived encrypted, whose body OpenEmail never reads. A pending answer starts the writing, so ask again a few seconds later.
パラメーター
idstring必須Thread id.
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
ThreadAiSummaryResource, { object: 'thread_summary', threadId, state, summary }, with summary null unless state is ready.
例
let result = await openemail.threads.summary('CAHk7pQ2x9LmZ4-mail.example.com') if (result.state === 'pending') { await new Promise((resolve) => setTimeout(resolve, 5000)) result = await openemail.threads.summary('CAHk7pQ2x9LmZ4-mail.example.com')} console.log(result.summary ?? result.state)注意事項
Writing a summary spends one of the workspace's AI actions. Reading one that is already written spends nothing.
A thread delivered to no address the key covers is a 404.
ほかの提供先
threads.restore()
Take a thread out of the Bin
restore(id: string, options?: RequestScope): Promise<RestoredThreadResource>Puts a thread back in the inbox, out of the Bin and out of Spam, which is what Restore from Bin and Move to inbox do in the app. It is the undo of trash.
Calling it on a thread that is already in the inbox changes nothing and returns the same body, which is why the SDK retries it.
パラメーター
idstring必須Thread id.
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
RestoredThreadResource, { object: 'thread', id, restored: true }.
例
await openemail.threads.trash('CAHk7pQ2x9LmZ4-mail.example.com') const restored = await openemail.threads.restore('CAHk7pQ2x9LmZ4-mail.example.com') console.log(restored.restored)注意事項
A thread that was archived before it went to the Bin comes back to the inbox, not to the archive.
A thread delivered to no address the key covers is a 404.
ほかの提供先
threads.delete()
Delete a thread for good
delete(id: string, options?: RequestScope): Promise<DeletedThreadResource>Deletes every message in a thread, with its attachments, which is what Delete from Bin does in the app. It cannot be undone.
It works on a thread in any folder, so call trash instead when you only mean to throw the thread away: a trashed thread stays readable and restore brings it back.
パラメーター
idstring必須Thread id.
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
DeletedThreadResource, { object: 'thread', id, deleted: true }.
例
await openemail.threads.delete('CAHk7pQ2x9LmZ4-mail.example.com')注意事項
The SDK does not retry a delete. A 404 on your own second attempt after a lost response means the first one worked.
A 500
thread_delete_failedmeans nothing was removed, so the call is safe to repeat.A thread delivered to no address the key covers is a 404.
ほかの提供先
threads.unsubscribe()
Unsubscribe from the sender of a thread
unsubscribe(id: string, options?: RequestScope): Promise<UnsubscribeResultResource>Does what the Unsubscribe button of the reading pane does: finds the subscription behind the newest message of the thread that carries a List-Unsubscribe header and unsubscribes from it the way the sender asks for, with a one-click request or an unsubscribe email. A sender that only offers a page cannot be unsubscribed by a program, so method is link and url is the page a person has to open.
A thread with no unsubscribe header is a 422 unsubscribe_unsupported, and a thread delivered to no address the key covers is a 404.
パラメーター
idstring必須Thread id.
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
UnsubscribeResultResource, { object: 'unsubscribe', threadId, subscriptionId, method, url, binned }.
例
const result = await openemail.threads.unsubscribe('CAHk7pQ2x9LmZ4-mail.example.com') console.log(result.method)注意事項
The SDK does not retry it, because a second call can send a second unsubscribe email.
ほかの提供先
threads.getEvent()
Read the event a thread carries
getEvent(id: string, options?: RequestScope): Promise<CalendarEventResource>Returns the calendar event that came with an invitation in the thread, as the invitation card of the reading pane shows it. Answer it with calendar.respondToEvent.
パラメーター
idstring必須Thread id, as
threads.listreturns it.options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
戻り値
CalendarEventResource, as calendar.getEvent returns it.
例
const event = await openemail.threads.getEvent('thr_6d1a9c4e2b7f30d85e1c4a92') console.log(event.summary, event.start)注意事項
A thread with no event, or one the key does not reach, is a 404.