agentmail/types/inboxes.rs
1use serde::{Deserialize, Serialize};
2
3/// Request body for `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 /// Initial traffic state: `active` (default) or `paused`.
20 #[serde(skip_serializing_if = "Option::is_none")]
21 pub status: Option<String>,
22 /// Arbitrary JSON stored alongside the inbox.
23 #[serde(skip_serializing_if = "Option::is_none")]
24 pub metadata: Option<serde_json::Value>,
25}
26
27/// Request body for `update_inbox`. Fields left `None` are omitted
28/// and stay unchanged; set `metadata` to `Some(Value::Null)` to clear it.
29#[derive(Clone, Debug, Default, Serialize)]
30pub struct UpdateInbox {
31 /// Replace the human-readable sender name.
32 #[serde(skip_serializing_if = "Option::is_none")]
33 pub display_name: Option<String>,
34 /// `active` to resume traffic, `paused` to hold it.
35 #[serde(skip_serializing_if = "Option::is_none")]
36 pub status: Option<String>,
37 /// Replace the stored metadata.
38 #[serde(skip_serializing_if = "Option::is_none")]
39 pub metadata: Option<serde_json::Value>,
40}
41/// An agent-owned inbox, as the API returns it.
42#[derive(Clone, Debug, Deserialize)]
43pub struct Inbox {
44 /// Unique id, used in every message call.
45 pub inbox_id: String,
46 /// The address itself, e.g. `my-agent@agentmail.to`.
47 pub email: String,
48 /// Human-readable sender name, when set.
49 #[serde(default)]
50 pub display_name: Option<String>,
51 /// Owning pod, when the account uses pods.
52 #[serde(default)]
53 pub pod_id: Option<String>,
54 /// Your reference id from creation, when set.
55 #[serde(default)]
56 pub client_id: Option<String>,
57 /// Whether the inbox accepts traffic: `active` or `paused`.
58 #[serde(default)]
59 pub status: Option<String>,
60 /// Arbitrary JSON stored alongside the inbox.
61 #[serde(default)]
62 pub metadata: Option<serde_json::Value>,
63 /// RFC 3339 last-update timestamp.
64 #[serde(default)]
65 pub updated_at: Option<String>,
66 /// RFC 3339 creation timestamp.
67 #[serde(default)]
68 pub created_at: Option<String>,
69}
70/// One page of inboxes from `list_inboxes_page`.
71#[derive(Clone, Debug, Deserialize)]
72pub struct InboxList {
73 /// Total inboxes in the account (not just this page).
74 pub count: u64,
75 /// This page of inboxes.
76 #[serde(default)]
77 pub inboxes: Vec<Inbox>,
78 /// Cursor for the next page; `None` on the last page.
79 #[serde(default)]
80 pub next_page_token: Option<String>,
81}
82
83/// Body for `authorize_inbox`: complete a human authorization started in the
84/// browser. The `auth_token` comes from that flow.
85#[derive(Clone, Debug, Default, Serialize)]
86pub struct AuthorizeInbox {
87 /// The one-time token from the browser authorization flow.
88 pub auth_token: String,
89 /// Confirm the app's disclosure on the human's behalf.
90 #[serde(skip_serializing_if = "Option::is_none")]
91 pub accept_disclosure: Option<bool>,
92}
93
94/// The response to `authorize_inbox`.
95#[derive(Clone, Debug, Deserialize)]
96pub struct AuthorizeInboxResult {
97 /// The API key minted for the authorized inbox.
98 pub api_key_id: String,
99 /// What to do next (return to the browser).
100 pub instructions: String,
101}