Skip to main content

Crate agentmail

Crate agentmail 

Source
Expand description

Unofficial typed Rust client for AgentMail, the email API for agents (official SDKs exist for Python and TypeScript; this fills the Rust gap).

Wire shapes follow AgentMail’s OpenAPI spec (docs.agentmail.to/openapi.json, API v0). Coverage focuses on the transactional core: inboxes, messages (send/list/get), and webhooks. Everything deserializes permissively - unknown fields are ignored, optional fields default, so spec additions don’t break callers.

let client = agentmail::Client::from_env()?; // AGENTMAIL_API_KEY
let inbox = client
    .create_inbox(agentmail::CreateInbox {
        username: Some("my-agent".into()),
        display_name: Some("My Agent".into()),
        ..Default::default()
    })
    .await?;
client
    .send_message(
        &inbox.inbox_id,
        agentmail::SendMessage {
            to: vec!["someone@example.com".into()],
            subject: Some("Hello".into()),
            text: Some("From an agent's own inbox.".into()),
            ..Default::default()
        },
    )
    .await?;

Structs§

Client
An authenticated handle on the AgentMail API. Cheap to clone-ish (it owns a pooled reqwest::Client); construct once and share by reference.
CreateInbox
Request body for Client::create_inbox. All fields optional; the API generates a username when none is given.
CreateWebhook
Request body for Client::create_webhook.
Inbox
An agent-owned inbox, as the API returns it.
InboxList
One page of inboxes from Client::list_inboxes_page.
Message
A message as the API returns it. List items are a subset of the full get-message shape; every non-id field defaults so both parse.
MessageList
One page of messages from Client::list_messages_page.
Page
Pagination controls for the list_*_page calls. Default is the API’s own defaults (first page, server-chosen page size).
SendMessage
Request body for Client::send_message. At least one recipient in to and one of text/html are required by the API.
SentMessage
The API’s acknowledgement of a send.
Webhook
A webhook subscription, as the API returns it.
WebhookList
One page of webhooks from Client::list_webhooks_page.

Enums§

Error
Everything that can go wrong talking to AgentMail.

Constants§

DEFAULT_BASE_URL
The production API host. Override with Client::new(key, base_url) for the EU region (https://api.agentmail.eu) or a mock server.
DEFAULT_TIMEOUT
The per-request timeout applied by Client::new (connect + response).