agentmail/types/webhooks.rs
1use serde::{Deserialize, Serialize};
2
3/// Request body for [`Client::create_webhook`].
4#[derive(Clone, Debug, Default, Serialize)]
5pub struct CreateWebhook {
6 /// HTTPS endpoint to deliver events to.
7 pub url: String,
8 /// e.g. `["message.received"]`.
9 pub event_types: Vec<String>,
10 /// Limit delivery to these inboxes; empty means all.
11 #[serde(skip_serializing_if = "Vec::is_empty")]
12 pub inbox_ids: Vec<String>,
13 /// Limit delivery to these pods; empty means all.
14 #[serde(skip_serializing_if = "Vec::is_empty")]
15 pub pod_ids: Vec<String>,
16 /// Your own idempotency/reference id for this webhook.
17 #[serde(skip_serializing_if = "Option::is_none")]
18 pub client_id: Option<String>,
19}
20
21/// Request body for [`Client::update_webhook`]. Every field is optional; leave
22/// a field empty to keep it unchanged. Inbox and pod targeting is edited by
23/// delta (add/remove lists) rather than by replacing the whole set.
24#[derive(Clone, Debug, Default, Serialize)]
25pub struct UpdateWebhook {
26 /// Replace the subscribed event types.
27 #[serde(skip_serializing_if = "Vec::is_empty")]
28 pub event_types: Vec<String>,
29 /// Inboxes to add to the subscription.
30 #[serde(skip_serializing_if = "Vec::is_empty")]
31 pub add_inbox_ids: Vec<String>,
32 /// Inboxes to remove from the subscription.
33 #[serde(skip_serializing_if = "Vec::is_empty")]
34 pub remove_inbox_ids: Vec<String>,
35 /// Pods to add to the subscription.
36 #[serde(skip_serializing_if = "Vec::is_empty")]
37 pub add_pod_ids: Vec<String>,
38 /// Pods to remove from the subscription.
39 #[serde(skip_serializing_if = "Vec::is_empty")]
40 pub remove_pod_ids: Vec<String>,
41}
42/// A webhook subscription, as the API returns it.
43#[derive(Clone, Debug, Deserialize)]
44pub struct Webhook {
45 /// Unique id, used to delete the subscription.
46 pub webhook_id: String,
47 /// The subscribed HTTPS endpoint.
48 pub url: String,
49 /// Signing secret, returned once, on creation.
50 #[serde(default)]
51 pub secret: Option<String>,
52 /// Subscribed event types.
53 #[serde(default)]
54 pub event_types: Vec<String>,
55 /// Inboxes the subscription is limited to; empty means all.
56 #[serde(default)]
57 pub inbox_ids: Vec<String>,
58 /// Pods the subscription is limited to; empty means all.
59 #[serde(default)]
60 pub pod_ids: Vec<String>,
61 /// Whether the subscription currently delivers.
62 pub enabled: bool,
63 /// Your own reference id, echoed back if set on creation.
64 #[serde(default)]
65 pub client_id: Option<String>,
66 /// Timestamp the subscription was last updated (RFC 3339).
67 #[serde(default)]
68 pub updated_at: Option<String>,
69 /// Timestamp the subscription was created (RFC 3339).
70 #[serde(default)]
71 pub created_at: Option<String>,
72}
73/// One page of webhooks from [`Client::list_webhooks_page`].
74#[derive(Clone, Debug, Deserialize)]
75pub struct WebhookList {
76 /// Total webhooks in the account (not just this page).
77 pub count: u64,
78 /// This page of webhooks.
79 #[serde(default)]
80 pub webhooks: Vec<Webhook>,
81 /// Cursor for the next page; `None` on the last page.
82 #[serde(default)]
83 pub next_page_token: Option<String>,
84}