TypeScript SDK: Sending
The methods of the TypeScript client under Sending. New messages and replies from an inbox, with idempotent retries.
client.inboxes.send
client.inboxes.send(inboxId: string, body: SendMessageInput, options: SendOptions = {}): Promise<SendResult>Sends inboxes.send: POST /v1/inboxes/{inboxId}/send
A new message (to and subject) or a reply (threadId) from the inbox's address. Attachment contents may be bytes or base64. With an idempotencyKey, a retry within 24 hours replays the original answer, flagged with replayed. Where the security policy asks for the owner's word, a message to someone the inbox does not know is not sent: the answer is a held send (isHeldSend(result)), which the owner sends or discards. Do not send it again.
Access any: any API key, or a console session. An app token needs mail:send and mail:read.
client.inboxes.reply
client.inboxes.reply(inboxId: string, threadId: string, body: ReplyInput, options: SendOptions = {}): Promise<SendResult>A reply in a thread: inboxes.send with threadId. The subject, recipient and threading headers default from the thread.
client.inboxes.drafts.create
client.inboxes.drafts.create(inboxId: string, body: SendMessageInput): Promise<HeldSend>Sends inboxes.drafts.create: POST /v1/inboxes/{inboxId}/drafts
Write a message and leave it for the owner. Nothing is sent. The body is the one a send takes, a reply included (threadId), and it is checked as a send would be. The answer is a held send with kind draft: only the owner sends it, and client.heldSends.get(draft.id) says where it stands. An app needs mail:draft; it does not need mail:send.
Access key: an API key, or a correctly scoped app token where delegated access is allowed; console sessions are refused. An app token needs mail:draft and mail:read.
client.drafts.delete
client.drafts.delete(heldSendId: string): Promise<void>Sends drafts.delete: DELETE /v1/drafts/{heldSendId}
Take a draft back before the owner sent it. For the app or the key that wrote it. A send the security policy kept is not a draft and answers 404 here.
Access key: an API key, or a correctly scoped app token where delegated access is allowed; console sessions are refused. An app token needs mail:draft.

