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. - Create
Inbox - Request body for
Client::create_inbox. All fields optional; the API generates a username when none is given. - Create
Webhook - Request body for
Client::create_webhook. - Inbox
- An agent-owned inbox, as the API returns it.
- Inbox
List - 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.
- Message
List - One page of messages from
Client::list_messages_page. - Page
- Pagination controls for the
list_*_pagecalls.Defaultis the API’s own defaults (first page, server-chosen page size). - Send
Message - Request body for
Client::send_message. At least one recipient intoand one oftext/htmlare required by the API. - Sent
Message - The API’s acknowledgement of a send.
- Webhook
- A webhook subscription, as the API returns it.
- Webhook
List - 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).