Skip to main content

agentmail/types/
auth.rs

1use serde::Deserialize;
2
3/// What an API key is scoped to.
4#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
5#[serde(rename_all = "lowercase")]
6pub enum ScopeType {
7    /// The whole organization.
8    Organization,
9    /// A single pod.
10    Pod,
11    /// A single inbox.
12    Inbox,
13    /// A scope type this client version does not recognize.
14    #[serde(other)]
15    Unknown,
16}
17
18/// Who the current API key authenticates as, from [`Client::auth_me`](crate::Client::auth_me).
19#[derive(Clone, Debug, Deserialize)]
20pub struct Identity {
21    /// Whether the key is scoped to the organization, a pod, or an inbox.
22    pub scope_type: ScopeType,
23    /// Id of the scope (`organization_id`, `pod_id`, or `inbox_id`).
24    pub scope_id: String,
25    /// The organization the key belongs to.
26    pub organization_id: String,
27    /// The pod, when the key is pod-scoped.
28    #[serde(default)]
29    pub pod_id: Option<String>,
30    /// The inbox, when the key is inbox-scoped.
31    #[serde(default)]
32    pub inbox_id: Option<String>,
33    /// The API key's own id.
34    #[serde(default)]
35    pub api_key_id: Option<String>,
36}