Skip to main content

agentmail/types/
inboxes.rs

1use serde::{Deserialize, Serialize};
2
3/// Request body for [`Client::create_inbox`]. All fields optional; the API
4/// generates a username when none is given.
5#[derive(Clone, Debug, Default, Serialize)]
6pub struct CreateInbox {
7    /// Local part of the address; random when omitted.
8    #[serde(skip_serializing_if = "Option::is_none")]
9    pub username: Option<String>,
10    /// A verified domain (or subdomain of one); defaults to `agentmail.to`.
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub domain: Option<String>,
13    /// Human-readable sender name shown in email clients.
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub display_name: Option<String>,
16    /// Your own idempotency/reference id for this inbox.
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub client_id: Option<String>,
19    /// Arbitrary JSON stored alongside the inbox.
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub metadata: Option<serde_json::Value>,
22}
23
24/// Request body for [`Client::update_inbox`]. Fields left `None` are omitted
25/// and stay unchanged; set `metadata` to `Some(Value::Null)` to clear it.
26#[derive(Clone, Debug, Default, Serialize)]
27pub struct UpdateInbox {
28    /// Replace the human-readable sender name.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub display_name: Option<String>,
31    /// Replace the stored metadata.
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub metadata: Option<serde_json::Value>,
34}
35/// An agent-owned inbox, as the API returns it.
36#[derive(Clone, Debug, Deserialize)]
37pub struct Inbox {
38    /// Unique id, used in every message call.
39    pub inbox_id: String,
40    /// The address itself, e.g. `my-agent@agentmail.to`.
41    pub email: String,
42    /// Human-readable sender name, when set.
43    #[serde(default)]
44    pub display_name: Option<String>,
45    /// Owning pod, when the account uses pods.
46    #[serde(default)]
47    pub pod_id: Option<String>,
48    /// Your reference id from creation, when set.
49    #[serde(default)]
50    pub client_id: Option<String>,
51    /// RFC 3339 creation timestamp.
52    #[serde(default)]
53    pub created_at: Option<String>,
54}
55/// One page of inboxes from [`Client::list_inboxes_page`].
56#[derive(Clone, Debug, Deserialize)]
57pub struct InboxList {
58    /// Total inboxes in the account (not just this page).
59    pub count: u64,
60    /// This page of inboxes.
61    #[serde(default)]
62    pub inboxes: Vec<Inbox>,
63    /// Cursor for the next page; `None` on the last page.
64    #[serde(default)]
65    pub next_page_token: Option<String>,
66}