agentmail/types/domains.rs
1use serde::{Deserialize, Serialize};
2
3/// A sending domain, as the API returns it.
4#[derive(Clone, Debug, Deserialize)]
5pub struct Domain {
6 /// Unique domain id.
7 pub domain_id: String,
8 /// The domain name, e.g. `mail.example.com`.
9 #[serde(default)]
10 pub domain: Option<String>,
11 /// Owning pod, when the account uses pods.
12 #[serde(default)]
13 pub pod_id: Option<String>,
14 /// Verification status (e.g. `pending`, `verified`).
15 #[serde(default)]
16 pub status: Option<String>,
17 /// Why the domain is in its current state, when the API reports one.
18 #[serde(default)]
19 pub reason: Option<String>,
20 /// Whether bounce/complaint feedback is enabled.
21 #[serde(default)]
22 pub feedback_enabled: Option<bool>,
23 /// Whether inbound mail to this domain is delivered to agent inboxes.
24 #[serde(default)]
25 pub inbound_enabled: Option<bool>,
26 /// Whether subdomains of this domain may be used for inboxes.
27 #[serde(default)]
28 pub subdomains_enabled: Option<bool>,
29 /// Whether open/click tracking is enabled for this domain.
30 #[serde(default)]
31 pub tracking_enabled: Option<bool>,
32 /// The DNS records to add for verification and sending.
33 #[serde(default)]
34 pub records: Vec<VerificationRecord>,
35 /// Your reference id from creation, when set.
36 #[serde(default)]
37 pub client_id: Option<String>,
38 /// Timestamp the domain was last updated (RFC 3339).
39 #[serde(default)]
40 pub updated_at: Option<String>,
41 /// Timestamp the domain was created (RFC 3339).
42 #[serde(default)]
43 pub created_at: Option<String>,
44}
45
46/// A single DNS record to publish for a domain.
47#[derive(Clone, Debug, Deserialize)]
48pub struct VerificationRecord {
49 /// DNS record type, e.g. `TXT`, `MX`, `CNAME`.
50 #[serde(rename = "type")]
51 pub record_type: String,
52 /// The record name (host).
53 pub name: String,
54 /// The record value.
55 pub value: String,
56 /// Verification status of this record.
57 #[serde(default)]
58 pub status: Option<String>,
59 /// Priority, for records that need one (e.g. `MX`).
60 #[serde(default)]
61 pub priority: Option<i64>,
62 /// Why the record fails verification, when it does.
63 #[serde(default)]
64 pub reason: Option<String>,
65}
66
67/// Request body for `create_domain`.
68#[derive(Clone, Debug, Default, Serialize)]
69pub struct CreateDomain {
70 /// The domain name to add.
71 pub domain: String,
72 /// Proceed even if the domain's DNS is managed by another provider.
73 #[serde(skip_serializing_if = "Option::is_none")]
74 pub allow_conflicting_provider: Option<bool>,
75 /// Enable bounce/complaint feedback.
76 #[serde(skip_serializing_if = "Option::is_none")]
77 pub feedback_enabled: Option<bool>,
78 /// Deliver inbound mail for this domain to agent inboxes.
79 #[serde(skip_serializing_if = "Option::is_none")]
80 pub inbound_enabled: Option<bool>,
81 /// Allow subdomains of this domain to be used for inboxes.
82 #[serde(skip_serializing_if = "Option::is_none")]
83 pub subdomains_enabled: Option<bool>,
84 /// Enable open/click tracking for this domain.
85 #[serde(skip_serializing_if = "Option::is_none")]
86 pub tracking_enabled: Option<bool>,
87}
88
89/// Request body for `update_domain`. Fields left `None` stay unchanged.
90#[derive(Clone, Debug, Default, Serialize)]
91pub struct UpdateDomain {
92 /// Enable or disable bounce/complaint feedback.
93 #[serde(skip_serializing_if = "Option::is_none")]
94 pub feedback_enabled: Option<bool>,
95 /// Enable or disable inbound delivery to agent inboxes.
96 #[serde(skip_serializing_if = "Option::is_none")]
97 pub inbound_enabled: Option<bool>,
98 /// Enable or disable subdomains for inbox use.
99 #[serde(skip_serializing_if = "Option::is_none")]
100 pub subdomains_enabled: Option<bool>,
101 /// Enable or disable open/click tracking.
102 #[serde(skip_serializing_if = "Option::is_none")]
103 pub tracking_enabled: Option<bool>,
104}
105
106/// The provider setup link for a domain, from `get_domain_setup_link`. When
107/// [`DomainSetupLink::supported`] is false the registrar/provider flow isn't
108/// available and DNS records must be configured manually.
109#[derive(Clone, Debug, Deserialize)]
110pub struct DomainSetupLink {
111 /// Whether a provider setup flow exists for this domain.
112 pub supported: bool,
113 /// The detected DNS provider, when known.
114 #[serde(default)]
115 pub provider_name: Option<String>,
116 /// The setup URL to open.
117 #[serde(default)]
118 pub url: Option<String>,
119 /// Rendered QR-code width, when the link is meant to be scanned.
120 #[serde(default)]
121 pub width: Option<u32>,
122 /// Rendered QR-code height.
123 #[serde(default)]
124 pub height: Option<u32>,
125 /// Opaque state token carried through the provider flow.
126 #[serde(default)]
127 pub state: Option<String>,
128 /// The conflicting provider, when setup is blocked by one.
129 #[serde(default)]
130 pub conflicting_provider: Option<String>,
131}
132
133/// One page of domains from `list_domains_page`.
134#[derive(Clone, Debug, Deserialize)]
135pub struct DomainList {
136 /// Total domains in the account (not just this page).
137 pub count: u64,
138 /// This page of domains.
139 #[serde(default)]
140 pub domains: Vec<Domain>,
141 /// Cursor for the next page; `None` on the last page.
142 #[serde(default)]
143 pub next_page_token: Option<String>,
144}