Skip to main content

agentmail/client/
agent.rs

1use crate::{Client, Error, types::*};
2
3impl Client {
4    /// POST /v0/agent/sign-up, start onboarding a new agent. Emails a one-time
5    /// code to `human_email`; confirm it with [`Client::agent_verify`]. Runs
6    /// before any credential exists, so the client's bearer token (if any) is
7    /// irrelevant.
8    pub async fn agent_sign_up(&self, signup: AgentSignup) -> Result<AgentSignupResult, Error> {
9        self.request(
10            reqwest::Method::POST,
11            "/v0/agent/sign-up",
12            &[],
13            Some(&signup),
14        )
15        .await
16    }
17
18    /// POST /v0/agent/verify, confirm the one-time code from
19    /// [`Client::agent_sign_up`].
20    pub async fn agent_verify(&self, otp_code: &str) -> Result<AgentVerifyResult, Error> {
21        self.request(
22            reqwest::Method::POST,
23            "/v0/agent/verify",
24            &[],
25            Some(&serde_json::json!({ "otp_code": otp_code })),
26        )
27        .await
28    }
29}