AgentMailClient

Main entry point for the AgentMail SDK. Holds all top-level API resources (inboxes, threads, drafts, domains, pods, webhooks, lists, metrics, apiKeys, organization). Created via companion object invoke with optional DSL configuration. Implements Closeable to release the underlying HTTP client. Supports scoped access via inboxes and pods for nested resources.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun AgentMailClient.autoReply(inboxId: String, scope: CoroutineScope = CoroutineScope(Dispatchers.Default + SupervisorJob()), block: AutoReplyBuilder.() -> Unit): Job

Starts an auto-reply monitor on the given inbox that automatically replies to incoming messages based on configured rules.

Link copied to clipboard

Executes a batch of send and thread-iteration operations.

Link copied to clipboard
open override fun close()

Closes the underlying HTTP client and releases resources.

Link copied to clipboard

Creates a new API key.

Link copied to clipboard

Creates a new custom domain.

Link copied to clipboard
suspend fun AgentMailClient.createDraft(inboxId: String, block: CreateDraftBuilder.() -> Unit): Draft

Creates a new draft in an inbox.

Link copied to clipboard
suspend fun AgentMailClient.createInbox(username: String, domain: String, displayName: String): Inbox

Creates a new inbox with the given username, domain, and display name.

Link copied to clipboard

Creates a new allow/block list entry.

Link copied to clipboard

Creates a new pod.

Link copied to clipboard

Creates a new webhook.

Link copied to clipboard
suspend fun AgentMailClient.deleteApiKey(apiKeyId: String)

Deletes an API key by ID.

Link copied to clipboard
suspend fun AgentMailClient.deleteDomain(domainId: String)

Deletes a domain by ID.

Link copied to clipboard
suspend fun AgentMailClient.deleteDraft(inboxId: String, draftId: String)

Deletes a draft by inbox and draft ID.

Link copied to clipboard
suspend fun AgentMailClient.deleteInbox(inboxId: String)

Deletes an inbox by ID.

Link copied to clipboard
suspend fun AgentMailClient.deleteListEntry(direction: ListDirection, type: ListType, entry: String)

Deletes a specific list entry.

Link copied to clipboard
suspend fun AgentMailClient.deletePod(podId: String)

Deletes a pod by ID.

Link copied to clipboard
suspend fun AgentMailClient.deleteThread(inboxId: String, threadId: String, block: DeleteThreadBuilder.() -> Unit = {})

Deletes a thread by inbox and thread ID.

Link copied to clipboard
suspend fun AgentMailClient.deleteWebhook(webhookId: String)

Deletes a webhook by ID.

Link copied to clipboard

Forwards a message to new recipients. Returns null if rate-limited with SKIP.

Link copied to clipboard
suspend fun AgentMailClient.getAttachment(message: Message, attachmentId: String): AttachmentData

Retrieves a message attachment's binary data.

Link copied to clipboard
suspend fun AgentMailClient.getDomain(domainId: String): Domain

Retrieves a domain by ID.

Link copied to clipboard

Retrieves the DNS zone file for a domain.

Link copied to clipboard
suspend fun AgentMailClient.getDraft(inboxId: String, draftId: String): Draft

Retrieves a draft by inbox and draft ID.

Link copied to clipboard
suspend fun AgentMailClient.getDraftAttachment(inboxId: String, draftId: String, attachmentId: String): AttachmentData

Retrieves a draft attachment's binary data.

Link copied to clipboard
suspend fun AgentMailClient.getInbox(inboxId: String): Inbox

Retrieves an inbox by ID.

Link copied to clipboard
suspend fun AgentMailClient.getListEntry(direction: ListDirection, type: ListType, entry: String): ListEntry

Retrieves a specific list entry.

Link copied to clipboard

Retrieves the current organization's details.

Link copied to clipboard
suspend fun AgentMailClient.getPod(podId: String): Pod

Retrieves a pod by ID.

Link copied to clipboard

Retrieves the raw RFC 2822 content of a message.

Link copied to clipboard
suspend fun AgentMailClient.getThread(inboxId: String, threadId: String): Thread

Retrieves a thread by inbox and thread ID.

Link copied to clipboard
suspend fun AgentMailClient.getThreadAttachment(inboxId: String, threadId: String, attachmentId: String): AttachmentData

Retrieves a thread attachment's binary data.

Link copied to clipboard
suspend fun AgentMailClient.getWebhook(webhookId: String): Webhook

Retrieves a webhook by ID.

Link copied to clipboard
fun inboxes(inboxId: String): InboxScope

Returns an InboxScope for accessing resources nested under the given inbox.

Link copied to clipboard

Lists all API keys with optional pagination.

Link copied to clipboard

Lists all custom domains with optional pagination.

Link copied to clipboard
suspend fun AgentMailClient.listDrafts(inboxId: String, block: ListDraftsBuilder.() -> Unit = {}): DraftList

Lists drafts in an inbox with optional pagination and filtering.

Link copied to clipboard
suspend fun AgentMailClient.listEntries(direction: ListDirection, type: ListType, block: ListEntriesBuilder.() -> Unit = {}): ListEntryList

Lists allow/block entries for a given direction and type.

Link copied to clipboard

Lists all inboxes with optional pagination.

Link copied to clipboard
suspend fun AgentMailClient.listMessages(inboxId: String, block: ListMessagesBuilder.() -> Unit = {}): MessageList

Lists messages in an inbox with optional pagination and filtering.

Link copied to clipboard
suspend fun AgentMailClient.listPods(block: ListPodsBuilder.() -> Unit = {}): PodList

Lists all pods with optional pagination.

Link copied to clipboard
suspend fun AgentMailClient.listThreads(inboxId: String, block: ListThreadsBuilder.() -> Unit = {}): ThreadList

Lists threads in an inbox with optional pagination and filtering.

Link copied to clipboard

Lists all webhooks with optional pagination.

Link copied to clipboard
fun AgentMailClient.monitor(inboxId: String, scope: CoroutineScope = CoroutineScope(Dispatchers.Default + SupervisorJob()), block: MonitorBuilder.() -> Unit): Job

Starts a coroutine that polls an inbox for new messages and invokes handlers.

Link copied to clipboard
fun pods(podId: String): PodScope

Returns a PodScope for accessing resources nested under the given pod.

Link copied to clipboard
fun AgentMailClient.poll(inboxId: String, interval: Duration = 10.seconds, filter: (Message) -> Boolean? = null, scope: CoroutineScope = CoroutineScope(Dispatchers.Default + SupervisorJob()), handler: suspend (Message) -> Unit): Job

Simplified inbox polling that invokes a handler for each new message at a fixed interval.

Link copied to clipboard

Queries email event metrics with optional filters.

Link copied to clipboard

Sends a reply-all to a specific message. Returns null if rate-limited with SKIP.

Link copied to clipboard

Sends a reply to a specific message. Returns null if rate-limited with SKIP.

Link copied to clipboard
suspend fun AgentMailClient.sendDraft(inboxId: String, draftId: String, block: SendDraftBuilder.() -> Unit = {}): SendMessageResponse

Sends a draft as an email message.

Link copied to clipboard

Sends an email message from an inbox to recipients. Returns null if rate-limited with SKIP.

Link copied to clipboard

Fetches the full message content for a message (useful after listing which returns previews).

Link copied to clipboard
suspend fun AgentMailClient.updateDomain(domainId: String, block: UpdateDomainBuilder.() -> Unit): Domain

Updates a domain by ID.

Link copied to clipboard
suspend fun AgentMailClient.updateDraft(inboxId: String, draftId: String, block: UpdateDraftBuilder.() -> Unit): Draft

Updates a draft by inbox and draft ID.

Link copied to clipboard
suspend fun AgentMailClient.updateInbox(inboxId: String, block: UpdateInboxBuilder.() -> Unit): Inbox

Updates an inbox by ID.

Link copied to clipboard

Updates a message's labels.

Link copied to clipboard
suspend fun AgentMailClient.updateWebhook(webhookId: String, block: UpdateWebhookBuilder.() -> Unit): Webhook

Updates a webhook by ID.

Link copied to clipboard
suspend fun AgentMailClient.verifyDomain(domainId: String)

Triggers DNS verification for a domain.