### GET v0/domains/{domain_id}/setup-link Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/endpoints.md Retrieves a setup link for a specific domain. ```APIDOC ## GET v0/domains/{domain_id}/setup-link ### Description Retrieves a setup link for a specific domain. ### Method GET ### Endpoint v0/domains/{domain_id}/setup-link ### Parameters #### Path Parameters - **domain_id** (string) - Required - The ID of the domain. ### Response #### Success Response (200) - **GetSetupLinkResponse** - The setup link details. ``` -------------------------------- ### Usage Example Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/agentmail-sdk-resources.md Example of building an AgentMail client and listing and getting threads. ```APIDOC ## Usage Example ```rust use agentmail_sdk::prelude::*; #[tokio::main] async fn main() { let client = ApiClientBuilder::new("https://api.agentmail.to") .token("my-token") .build() .expect("build client"); // List threads in an inbox, then read the first thread. let inbox_id = InboxesInboxId("inbox_id".to_string()); let threads = client .inboxes .threads .list( &inbox_id, &InboxesThreadsListQueryRequest { ..Default::default() }, None, ) .await .expect("list threads"); if let Some(first) = threads.threads.first() { let thread = client .inboxes .threads .get( &inbox_id, &first.thread_id, &InboxesThreadsGetQueryRequest { ..Default::default() }, None, ) .await .expect("get thread"); println!("thread {} has {} messages", thread.thread_id, thread.message_count); } } ``` ``` -------------------------------- ### Usage example: list and get threads Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/agentmail-sdk-resources.md Shows how to build an ApiClient with a token and base URL, list threads in an inbox, and fetch the first thread. Requires the agentmail_sdk crate and a valid token. ```rust use agentmail_sdk::prelude::*; #[tokio::main] async fn main() { let client = ApiClientBuilder::new("https://api.agentmail.to") .token("my-token") .build() .expect("build client"); // List threads in an inbox, then read the first thread. let inbox_id = InboxesInboxId("inbox_id".to_string()); let threads = client .inboxes .threads .list( &inbox_id, &InboxesThreadsListQueryRequest { ..Default::default() }, None, ) .await .expect("list threads"); if let Some(first) = threads.threads.first() { let thread = client .inboxes .threads .get( &inbox_id, &first.thread_id, &InboxesThreadsGetQueryRequest { ..Default::default() }, None, ) .await .expect("get thread"); println!("thread {} has {} messages", thread.thread_id, thread.message_count); } } ``` -------------------------------- ### Output format examples Source: https://github.com/agentmail-to/agentmail-cli/blob/main/README.md Examples of using the --format flag to control output: pipe JSON through jq, keep human rendering when piped, and get a machine-readable catalog of operations. ```bash # Pipe JSON output through jq agentmail --format json | jq # Keep the human rendering even when piped agentmail --human | less # Machine-readable catalog of every operation (same as --schema) agentmail --help --format json | jq '.operations | length' ``` -------------------------------- ### GET /v0/domains/{domain_id}/setup-link Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Builds a one-click DNS setup link for the domain via the Domain Connect standard. When the domain's DNS provider supports Domain Connect and carries the AgentMail template, the response contains a signed URL: opening it lets the domain owner approve the required DNS records at their provider, which writes them automatically — no copy-paste. When the provider does not support it, `supported` is `false` and the domain's `records` should be added manually instead. ```APIDOC ## GET /v0/domains/{domain_id}/setup-link ### Description Builds a one-click DNS setup link for the domain via the Domain Connect standard. When the domain's DNS provider supports Domain Connect and carries the AgentMail template, the response contains a signed URL: opening it lets the domain owner approve the required DNS records at their provider, which writes them automatically — no copy-paste. When the provider does not support it, `supported` is `false` and the domain's `records` should be added manually instead. ### Method GET ### Endpoint /v0/domains/{domain_id}/setup-link ### Parameters #### Path Parameters - **domain_id** (DomainId) - Required - The ID of the domain. ### Request Example ```bash agentmail domains get-setup-link --domain-id ``` ``` -------------------------------- ### Getting started with AgentmailClient Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/agentmail-sdk.md Builds a client with a token and lists inboxes. The doc comment uses the name AgentmailClient, but the concrete type is ApiClient. ```rust use agentmail_sdk::prelude::*; #[tokio::main] async fn main() { let config = ClientConfig { token: Some("".to_string()), ..Default::default() }; let client = AgentmailClient::new(config).expect("Failed to build client"); client .inboxes .list(&InboxesListQueryRequest { ..Default::default() }, None) .await; } ``` -------------------------------- ### HTTP client example Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/http.md Example of creating an HTTP client using HttpConfig, which honors environment variables like AGENTMAIL_CA_BUNDLE and AGENTMAIL_PROXY. ```rust use fern_cli_sdk::http::HttpConfig; let config = HttpConfig::new("agentmail")?; let client = config.build_client()?; // honors AGENTMAIL_CA_BUNDLE, AGENTMAIL_PROXY, ... ``` -------------------------------- ### Install via npm Source: https://github.com/agentmail-to/agentmail-cli/blob/main/README.md Install the AgentMail CLI globally using npm. ```bash npm install -g agentmail-cli ``` -------------------------------- ### Install via shell (macOS/Linux) Source: https://github.com/agentmail-to/agentmail-cli/blob/main/README.md Install the AgentMail CLI on macOS or Linux using the official installer script. ```bash curl --proto '=https' --tlsv1.2 -LsSf https://github.com/agentmail-to/agentmail-cli/releases/latest/download/agentmail-cli-installer.sh | sh ``` -------------------------------- ### Install via PowerShell (Windows) Source: https://github.com/agentmail-to/agentmail-cli/blob/main/README.md Install the AgentMail CLI on Windows using PowerShell. ```powershell powershell -ExecutionPolicy ByPass -c "irm https://github.com/agentmail-to/agentmail-cli/releases/latest/download/agentmail-cli-installer.ps1 | iex" ``` -------------------------------- ### DomainsClient Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/agentmail-sdk-resources.md Client for managing domains. Provides methods to list, create, get, delete, update, get zone file, verify, and get setup link for domains. ```APIDOC ## DomainsClient ### Methods - `list(&DomainsListQueryRequest) -> ListDomainsResponse` - `create(&CreateDomainRequest) -> Domain` - `get(&DomainId) -> Domain` - `delete(&DomainId) -> ()` - `update(&DomainId, &UpdateDomainRequest) -> Domain` - `get_zone_file(&DomainId) -> ()` - `verify(&DomainId) -> ()` - `get_setup_link(&DomainId) -> GetSetupLinkResponse` ``` -------------------------------- ### CLI App Authentication Example Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/auth.md Shows how to configure a CLI app with Bearer, Basic, and OAuth2 authentication methods, each reading credentials from environment variables, and bind an OpenAPI spec. The example uses the fern_cli_sdk crate. ```rust use fern_cli_sdk::app::CliApp; use fern_cli_sdk::auth::{BearerAuth, BasicAuth, OAuth2Auth}; use fern_cli_sdk::openapi::OpenApiBinding; CliApp::new("platform") .auth(BearerAuth::new("bearerAuth").env("PLATFORM_TOKEN")) .auth(BasicAuth::new("basicAuth").username_env("USER").password_env("PASS")) .auth(OAuth2Auth::new("OAuth2Security") .client_id_env("CLIENT_ID") .client_secret_env("CLIENT_SECRET") .token_url("https://auth.example.com/token")) .binding(OpenApiBinding::new().spec(include_str!("openapi.yaml"))) .run(); ``` -------------------------------- ### CliApp usage example with auth and binding Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/cli-app.md Example of building a CLI app with two auth schemes (Bearer and API key) and an OpenAPI binding. The auth schemes are registered at root level and shared across bindings. ```rust use fern_cli_sdk::app::CliApp; use fern_cli_sdk::auth::{BearerAuth, ApiKeyAuth}; CliApp::new("my-cli") .auth(BearerAuth::new("bearerAuth").env("MY_TOKEN")) .auth(ApiKeyAuth::new("apiKey").env("API_KEY")) .binding(OpenApiBinding::new().spec(include_str!("openapi.yaml"))) .run() ``` -------------------------------- ### AutoResponder ping/pong example Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/websocket.md Example closure that replies with a pong JSON frame when the inbound frame has type "ping", otherwise returns None to let the frame flow through to OutputPipeline::emit. ```rust let responder: AutoResponder = Arc::new(|frame| { if frame.get("type")?.as_str()? == "ping" { Some(ResponderAction::Reply(serde_json::json!({"type": "pong"}))) } else { None } }); ``` -------------------------------- ### Example: Configuring Authentication Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/auth.md Shows how to configure Bearer, Basic, and OAuth2 authentication methods in a CliApp. ```APIDOC ## Example: Configuring Authentication ### Description Shows how to configure Bearer, Basic, and OAuth2 authentication methods in a CliApp. ### Code ```rust use fern_cli_sdk::app::CliApp; use fern_cli_sdk::auth::{BearerAuth, BasicAuth, OAuth2Auth}; use fern_cli_sdk::openapi::OpenApiBinding; CliApp::new("platform") .auth(BearerAuth::new("bearerAuth").env("PLATFORM_TOKEN")) .auth(BasicAuth::new("basicAuth").username_env("USER").password_env("PASS")) .auth(OAuth2Auth::new("OAuth2Security") .client_id_env("CLIENT_ID") .client_secret_env("CLIENT_SECRET") .token_url("https://auth.example.com/token")) .binding(OpenApiBinding::new().spec(include_str!("openapi.yaml"))) .run(); ``` ``` -------------------------------- ### GraphQL binding usage example Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/graphql.md Shows how to create a CLI app with the GraphqlBinding, providing a schema JSON and an endpoint URL. ```rust use fern_cli_sdk::app::CliApp; use fern_cli_sdk::graphql::GraphqlBinding; CliApp::new("graphcli") .binding( GraphqlBinding::new() .spec(include_str!("schema.json")) .endpoint("https://api.example.com/graphql"), ) .run() ``` -------------------------------- ### run_with_args Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/cli-app.md Like `run` but takes argv explicitly. Performs one-time setup: reset_sigpipe(), load_dotenv_filtered(name), init_logging(name), propagate_root_auth(), propagate_root_global_parameters(). Builds a fresh tokio runtime and calls std::process::exit(exit_code). ```APIDOC ## run_with_args ### Description Like `run` but takes argv explicitly. Performs one-time setup: `reset_sigpipe()`, `load_dotenv_filtered(name)` (reporting ignored keys after `init_logging`), `init_logging(name)`, `propagate_root_auth()`, `propagate_root_global_parameters()`. Builds a fresh tokio runtime and calls `std::process::exit(exit_code)`. ### Method run_with_args ### Signature ```rust pub fn run_with_args(mut self, args: I) where I: IntoIterator, T: Into, ``` ### Parameters - **args** (I) - Required - An iterator of arguments to pass to the CLI. Each item must be convertible into an `OsString`. ### Returns None (process terminates with exit code) ``` -------------------------------- ### GET v0/apps Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/endpoints.md Lists apps. Accepts an optional AppsListQueryRequest for filtering. ```APIDOC ## GET v0/apps ### Description Lists apps. Accepts an optional AppsListQueryRequest for filtering. ### Method GET ### Endpoint v0/apps ### Parameters #### Query Parameters - **AppsListQueryRequest** (object) - Optional - Query parameters for listing apps. ### Response #### Success Response (200) - **ListAppsResponse** - The list of apps. ``` -------------------------------- ### agentmail domains get-setup-link Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Builds a one-click DNS setup link for the domain via the Domain Connect standard. When the provider supports it, the response contains a signed URL; otherwise, 'supported' is false and records must be added manually. ```bash agentmail domains get-setup-link --domain-id ``` -------------------------------- ### GET /v0/inboxes/{inbox_id}/calendar/events/{event_id}/instances Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Lists the dates of one recurring event in a time window, in start order, with each date's edits applied. Requires the calendar_event_read permission. ```APIDOC ## GET /v0/inboxes/{inbox_id}/calendar/events/{event_id}/instances ### Description Lists the dates of one recurring event in a time window, in start order, with each date's edits applied. Dates are computed from the rule, so this works for any window up to 366 days, including dates far in the future. Cancelled dates are left out. The window defaults to now through 90 days from now. Items omit `description`, `metadata` and `attendees`; get a date by its ID for the full object. Like other reads, the list can trail a change made moments earlier by a few seconds; pass `consistency=primary` to read your own change right away. Requires the `calendar_event_read` permission. Calendar is in private beta: organizations without access receive a `403`. ### Method GET ### Endpoint /v0/inboxes/{inbox_id}/calendar/events/{event_id}/instances ### Parameters #### Path Parameters - **inbox_id** (inboxesInboxId) - Required - The inbox ID. - **event_id** (string) - Required - UUID of the recurring event. #### Query Parameters - **consistency** (CalendarConsistency) - Optional - Consistency level for the read. - **after** (WindowAfter) - Optional - Start of the time window. - **before** (WindowBefore) - Optional - End of the time window. - **include-overlapping** (IncludeOverlapping) - Optional - Whether to include overlapping instances. - **limit** (CalendarLimit) - Optional - Maximum number of instances to return. - **page-token** (PageToken) - Optional - Token for pagination. ### Response #### Success Response (200) Returns a list of event instances. ``` -------------------------------- ### Example usage of OpenApiBinding::handler Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/openapi.md Shows how to create a CLI with an OpenAPI binding and register a command with a handler. ```rust CliApp::new("my-cli") .binding(OpenApiBinding::new().spec(include_str!("openapi.yaml"))) .command(my_cmd(), OpenApiBinding::handler(my_handler)) .run() ``` -------------------------------- ### GET /v0/metrics/usage Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Cumulative usage series for the organization. Each point is the running total of the usage type at that timestamp, not the change within the bucket. Defaults to the last 24 hours; start must be within the last 90 days, and a future end is clamped to now. The range divided by period must not exceed 1000 buckets. ```APIDOC ## GET /v0/metrics/usage ### Description Cumulative usage series for the organization. Each point is the running total of the usage type at that timestamp, not the change within the bucket. Defaults to the last 24 hours; `start` must be within the last 90 days, and a future `end` is clamped to now. The range divided by `period` must not exceed 1000 buckets. ### Method GET ### Endpoint /v0/metrics/usage ### Parameters #### Query Parameters - **usage-types** (UsageTypes) - Optional - - **start** (Start) - Optional - - **end** (End) - Optional - - **period** (Period) - Optional - - **limit** (MetricLimit) - Optional - - **descending** (Descending) - Optional - ### CLI ```bash agentmail metrics query-usage ``` ``` -------------------------------- ### GET /v0/metrics/events Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Counts of email events (sent, delivered, bounced, etc.) over time for the organization. Defaults to the last 24 hours; start must be within the last 90 days, and a future end is clamped to now. Omit period for individual event counts, or set it to sum counts into buckets of that many seconds. ```APIDOC ## GET /v0/metrics/events ### Description Counts of email events (sent, delivered, bounced, etc.) over time for the organization. Defaults to the last 24 hours; `start` must be within the last 90 days, and a future `end` is clamped to now. Omit `period` for individual event counts, or set it to sum counts into buckets of that many seconds. ### Method GET ### Endpoint /v0/metrics/events ### Parameters #### Query Parameters - **event-types** (MetricEventTypes) - Optional - - **start** (Start) - Optional - - **end** (End) - Optional - - **period** (Period) - Optional - - **limit** (MetricLimit) - Optional - - **descending** (Descending) - Optional - ### CLI ```bash agentmail metrics query-events ``` ``` -------------------------------- ### WebSocketClient usage example Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/websocket.md Shows how to create a WsConfig, set bearer auth from an environment variable, connect to a WebSocket endpoint, send a JSON message, and run the receive loop. ```rust use fern_cli_sdk::http::HttpConfig; use fern_cli_sdk::websocket::{WsConfig, WsAuth, WebSocketClient}; use fern_cli_sdk::auth::AuthCredentialSource; let mut config = WsConfig::new("wss://api.example.com/stream"); config.auth = WsAuth::bearer(AuthCredentialSource::from_env("MY_KEY")); let http_config = HttpConfig::new("my-cli")?; let mut client = WebSocketClient::connect(config, &http_config).await?; client.send(&serde_json::json!({"type": "hello"})).await?; client.run_recv_loop().await?; ``` -------------------------------- ### GET /v0/inboxes/search Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Searches inboxes in the organization by address or display name, ranked by relevance. Each word in the query matches the start of a word in the address or display name, so `sup` matches `support@example.com` but `port` does not. An exact address match always ranks first. `limit` cannot exceed 100. A page can be empty and still carry a `next_page_token`; keep paging until the token is absent. ```APIDOC ## GET /v0/inboxes/search ### Description Searches inboxes in the organization by address or display name, ranked by relevance. Each word in the query matches the start of a word in the address or display name, so `sup` matches `support@example.com` but `port` does not. An exact address match always ranks first. `limit` cannot exceed 100. A page can be empty and still carry a `next_page_token`; keep paging until the token is absent. ### Method GET ### Endpoint /v0/inboxes/search ### Parameters #### Query Parameters - **q** (string) - Required - Address or display name to search for. Matches word prefixes. Must be 2 to 256 characters. - **limit** (Limit) - Optional - Maximum number of results. - **page-token** (PageToken) - Optional - Token for pagination. ### Response #### Success Response (200) - **inboxes** (array) - List of matching inboxes. - **next_page_token** (string) - Token for the next page, if any. ``` -------------------------------- ### agentmail pods metrics query-rates Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Rolling bounce and complaint rates for the pod. Defaults to the rolling 24-hour rate sampled hourly over the last day; start must be within the last 90 days, window must be a whole multiple of period, and the range plus window divided by period must not exceed 1000 buckets. Corresponds to GET /v0/pods/{pod_id}/metrics/rates. ```bash agentmail pods metrics query-rates --pod-id ``` -------------------------------- ### List available commands Source: https://github.com/agentmail-to/agentmail-cli/blob/main/README.md Display the help message listing all available commands. ```bash agentmail --help ``` -------------------------------- ### agentmail pods metrics query-events Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Counts email events (sent, delivered, bounced, etc.) over time for the pod. Defaults to the last 24 hours; start must be within the last 90 days, and a future end is clamped to now. Omit period for individual event counts, or set it to sum counts into buckets of that many seconds. Corresponds to GET /v0/pods/{pod_id}/metrics/events. ```bash agentmail pods metrics query-events --pod-id ``` -------------------------------- ### WsConfig::new constructor Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/websocket.md Creates a new WsConfig with the given URL, no authentication, and the default output pipeline. ```rust impl WsConfig { pub fn new(url: impl Into) -> Self // no auth, default pipeline } ``` -------------------------------- ### WsConfig::new Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/websocket.md Creates a new WsConfig with the given URL, no authentication, and the default output pipeline. ```APIDOC ## WsConfig::new ### Description Creates a new `WsConfig` instance with the specified URL, no authentication, and the default output pipeline. ### Method `WsConfig::new` ### Signature ```rust pub fn new(url: impl Into) -> Self ``` ### Parameters - **url** (`impl Into`) - Required - The WebSocket URL to connect to. ### Returns - `WsConfig` - A new configuration instance. ### Example ```rust let config = WsConfig::new("wss://example.com/socket"); ``` ``` -------------------------------- ### Get an inbox: agentmail pods inboxes get Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Fetches a single inbox by pod ID and inbox ID. Corresponds to `GET /v0/pods/{pod_id}/inboxes/{inbox_id}`. Requires `--pod-id` and `--inbox-id`. ```bash agentmail pods inboxes get --pod-id --inbox-id ``` -------------------------------- ### Example: constructing OutputPipeline Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/formatter.md Shows two ways to create an OutputPipeline: from parsed clap matches using from_matches, or directly with a struct literal. The direct construction uses OutputFormat::Json, ColorMode::Auto, quiet: false, and a JMESPath query. ```rust use fern_cli_sdk::formatter::{OutputPipeline, OutputFormat}; // From parsed clap matches: let pipeline = OutputPipeline::from_matches(&matches, "agentmail")?; // Direct construction: let pipeline = OutputPipeline { format: OutputFormat::Json, color_mode: fern_cli_sdk::formatter::ColorMode::Auto, quiet: false, query: Some("messages[?labels=='important']".to_string()), }; ``` -------------------------------- ### Get a draft: agentmail pods drafts get Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Fetches a single draft by pod ID and draft ID. Corresponds to `GET /v0/pods/{pod_id}/drafts/{draft_id}`. Requires `--pod-id` and `--draft-id`. ```bash agentmail pods drafts get --pod-id --draft-id ``` -------------------------------- ### init_logging Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/fern-cli-sdk.md Initializes logging from environment variables. Call once at startup. Reads `_LOG` and `_LOG_FILE`, where `` is `cli_name` uppercased with hyphens replaced by underscores. Backed by `tracing` + `tracing-subscriber` with env-filter and JSON support. ```APIDOC ## init_logging ### Description Initializes logging from environment variables. Call once at startup. Reads `_LOG` and `_LOG_FILE`, where `` is `cli_name` uppercased with hyphens replaced by underscores. Backed by `tracing` + `tracing-subscriber` with env-filter and JSON support. ### Signature ```rust pub fn init_logging(cli_name: &str) ``` ### Parameters - `cli_name` (`&str`) - Required - Binary name, e.g. `"agentmail"`. ### Source `src/lib.rs` (`logging::init_logging`). ``` -------------------------------- ### Get webhook with agentmail webhooks get Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Retrieves a webhook by its ID. Requires the --webhook-id flag. ```bash agentmail webhooks get --webhook-id ``` -------------------------------- ### agentmail pods get CLI command Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Gets a pod by ID. Requires --pod-id flag. ```bash agentmail pods get --pod-id ``` -------------------------------- ### POST /v0/agent/sign-up Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Create a new agent organization with an inbox and API key. This endpoint is for signing up for the first time. ```APIDOC ## POST /v0/agent/sign-up ### Description Create a new agent organization with an inbox and API key. This endpoint is for signing up for the first time. If you've already signed up, you're all set — just use your existing API key. ### Method POST ### Endpoint /v0/agent/sign-up ### Parameters #### Request Body - **human_email** (string) - Optional - The email address of the human to associate with the organization. If omitted, the inbox can receive email but cannot send to anyone until a human is attached. - **username** (string) - Required - A unique username for the organization. ### Request Example { "human_email": "user@example.com", "username": "my-agent" } ### Response #### Success Response (200) - **api_key** (string) - The API key for the new organization. - **inbox** (string) - The inbox address. #### Response Example { "api_key": "sk-...", "inbox": "my-agent@agentmail.to" } ### Notes - A 6-digit OTP is sent to the human's email for verification. - This endpoint is idempotent. Calling it again with the same `human_email` will rotate the API key and resend the OTP if expired. - The returned API key has limited permissions until the organization is verified via the verify endpoint. ``` -------------------------------- ### Example: Invoke API method with fern_cli_sdk Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/openapi.md Shows how to use the OpenApiBinding and AppContext to find and invoke an API method, printing the response as pretty JSON. ```rust use fern_cli_sdk::openapi::{OpenApiBinding, AppContext}; fn handle_me(matches: &clap::ArgMatches, ctx: &AppContext) -> Result<(), fern_cli_sdk::error::CliError> { let method = ctx.find_method("auth", "me")?; let body = ctx.invoke(method, None, None, None)?; println!("{}", serde_json::to_string_pretty(&body).unwrap()); Ok(()) } ``` -------------------------------- ### Get a draft with agentmail inboxes drafts get Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Retrieves a single draft by its ID from the specified inbox. ```bash agentmail inboxes drafts get --inbox-id --draft-id ``` -------------------------------- ### Get a thread: agentmail pods threads get Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Retrieves a thread by pod and thread ID. Supports optional --limit (max 100) and --page-token for pagination. Corresponds to GET /v0/pods/{pod_id}/threads/{thread_id}. ```bash agentmail pods threads get --pod-id --thread-id ``` -------------------------------- ### Build from source Source: https://github.com/agentmail-to/agentmail-cli/blob/main/README.md Build the AgentMail CLI from source using the Rust toolchain. ```bash cargo build --release ./target/release/agentmail --help ``` -------------------------------- ### DraftsClient Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/agentmail-sdk-resources.md Client for managing drafts. Provides methods to list drafts, get a draft, and get a draft attachment. ```APIDOC ## DraftsClient ### Methods - `list(&DraftsListQueryRequest) -> ListDraftsResponse` - `get(&DraftId) -> Draft` - `get_attachment(&DraftId, &AttachmentId) -> AttachmentResponse` ``` -------------------------------- ### agentmail inboxes get Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Retrieves details of a specific inbox by its ID. The command sends a GET request to /v0/inboxes/{inbox_id}. ```bash agentmail inboxes get --inbox-id ``` -------------------------------- ### ThreadsClient Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/agentmail-sdk-resources.md Client for managing threads. Provides methods to list, search, get, delete, update, and get attachments for threads. ```APIDOC ## ThreadsClient ### Methods - `list(&ThreadsListQueryRequest) -> ListThreadsResponse` - `search(&ThreadsSearchQueryRequest) -> SearchThreadsResponse` - `get(&ThreadId, &ThreadsGetQueryRequest) -> Thread` - `delete(&ThreadId) -> ()` - `update(&ThreadId, &UpdateThreadRequest) -> UpdateThreadResponse` - `get_attachment(&ThreadId, &AttachmentId) -> AttachmentResponse` ``` -------------------------------- ### ByteStream usage example Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/agentmail-sdk-core.md Shows how to create a ByteStream via execute_stream_request and collect all bytes into memory. ```rust let mut stream = client.execute_stream_request(Method::GET, "/file", None, None, None).await?; let bytes = stream.collect().await?; ``` -------------------------------- ### Get domain: agentmail pods domains get Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Retrieves details of a specific domain. Requires --pod-id and --domain-id. ```bash agentmail pods domains get --pod-id --domain-id ``` -------------------------------- ### ThreadsClient2 Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/agentmail-sdk-resources.md Client for managing threads within an inbox. Provides methods to list, search, get, delete, update, and get attachments. ```APIDOC ## ThreadsClient2 ### Description Client for managing threads within an inbox. ### Methods #### list - **Signature**: `(inbox_id, request: &InboxesThreadsListQueryRequest, options)` - **Returns**: `ListThreadsResponse` #### search - **Signature**: `(inbox_id, request: &InboxesThreadsSearchQueryRequest, options)` - **Returns**: `SearchThreadsResponse` #### get - **Signature**: `(inbox_id, thread_id: &ThreadId, request: &InboxesThreadsGetQueryRequest, options)` - **Returns**: `Thread` #### delete - **Signature**: `(inbox_id, thread_id: &ThreadId, options)` - **Returns**: `()` #### update - **Signature**: `(inbox_id, thread_id: &ThreadId, request: &UpdateThreadRequest, options)` - **Returns**: `UpdateThreadResponse` #### get_attachment - **Signature**: `(inbox_id, thread_id: &ThreadId, attachment_id: &AttachmentId, options)` - **Returns**: `AttachmentResponse` ``` -------------------------------- ### OpenApiBinding::new Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/openapi.md Creates a new OpenApiBinding instance. The CLI name is set automatically by CliApp::binding(). ```APIDOC ## OpenApiBinding::new ### Description Creates a new OpenApiBinding instance. The CLI name is set automatically by CliApp::binding(). ### Method Constructor ### Signature ```rust pub fn new() -> Self ``` ### Parameters None ### Returns A new `OpenApiBinding` instance. ``` -------------------------------- ### init_logging function signature Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/fern-cli-sdk.md Initializes logging from environment variables. Call once at startup. Reads _LOG and _LOG_FILE, where is cli_name uppercased with hyphens replaced by underscores. Backed by tracing and tracing-subscriber. ```rust pub fn init_logging(cli_name: &str) ``` -------------------------------- ### HttpConfig::new Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/http.md Constructs a new HttpConfig with the given CLI binary name. Returns an error if the name is empty. ```APIDOC ## HttpConfig::new ### Description Constructs a new `HttpConfig` with the given CLI binary name. Returns an error if the name is empty (would silently disable the env-var scoping system). ### Method `new` ### Signature ```rust pub fn new(name: impl Into) -> Result ``` ### Parameters - `name` (impl Into) - Required - CLI binary name ### Returns - `Result` - Ok with the new config, or `Err(CliError::Other)` if name is empty. ``` -------------------------------- ### Get a pod-scoped webhook with agentmail pods webhooks get Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Retrieves a specific webhook scoped to a pod. Requires --pod-id and --webhook-id. ```bash agentmail pods webhooks get --pod-id --webhook-id ``` -------------------------------- ### GraphqlBinding::new Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/graphql.md Creates a new GraphqlBinding instance. The CLI name is set automatically by CliApp::binding(). ```APIDOC ## GraphqlBinding::new ### Description Creates a new GraphqlBinding instance. The CLI name is set automatically by CliApp::binding(). ### Method new ### Signature pub fn new() -> Self ### Parameters None ### Returns Self - A new GraphqlBinding instance. ### Example ```rust let binding = GraphqlBinding::new(); ``` ``` -------------------------------- ### agentmail inboxes messages get Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Retrieves a specific message by inbox ID and message ID. Corresponds to GET /v0/inboxes/{inbox_id}/messages/{message_id}. ```bash agentmail inboxes messages get --inbox-id --message-id ``` -------------------------------- ### CliApp::new Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/cli-app.md Creates a new CliApp instance with the given CLI binary name. The name is used for environment variable prefixing, logging, and User-Agent derivation. ```APIDOC ## CliApp::new ### Description Creates a new `CliApp` with no bindings, auth, or commands. The `name` parameter is used for env-var prefixing, logging, and `User-Agent` derivation. ### Method `new` ### Signature ```rust pub fn new(name: &str) -> Self ``` ### Parameters - **name** (`&str`) - Required - CLI binary name; used for env-var prefixing, logging, and `User-Agent` derivation. ### Returns Returns a `CliApp` with no bindings, auth, or commands. ### Example ```rust let app = CliApp::new("my-cli"); ``` ``` -------------------------------- ### DraftsClient2 Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/agentmail-sdk-resources.md Nested client for draft resources within an inbox. Provides methods to list, create, get, delete, update, get attachments, and send drafts. ```APIDOC ## DraftsClient2 ### Description Nested client for draft resources. All methods take `inbox_id: &InboxesInboxId` as the first argument. ### Methods #### list - Signature: `(inbox_id, request: &InboxesDraftsListQueryRequest, options)` - Returns: `ListDraftsResponse` #### create - Signature: `(inbox_id, request: &CreateDraftRequest, options)` - Returns: `Draft` #### get - Signature: `(inbox_id, draft_id: &DraftId, options)` - Returns: `Draft` #### delete - Signature: `(inbox_id, draft_id: &DraftId, options)` - Returns: `()` #### update - Signature: `(inbox_id, draft_id: &DraftId, request: &UpdateDraftRequest, options)` - Returns: `Draft` #### get_attachment - Signature: `(inbox_id, draft_id: &DraftId, attachment_id: &AttachmentId, options)` - Returns: `AttachmentResponse` #### send - Signature: `(inbox_id, draft_id: &DraftId, request: &UpdateMessageRequest, options)` - Returns: `SendMessageResponse` ``` -------------------------------- ### ApiClientBuilder usage example Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/agentmail-sdk.md Builds an ApiClient with a token, timeout, retries, and a custom header. The build method returns a Result and panics on failure. ```rust let client = ApiClientBuilder::new("https://api.agentmail.to") .token("my-token") .timeout(Duration::from_secs(120)) .max_retries(5) .custom_header("X-Custom", "value") .build() .expect("Failed to build client"); ``` -------------------------------- ### agentmail pods metrics query-usage Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Cumulative usage series for the pod. Each point is the running total of the usage type at that timestamp, not the change within the bucket. Pod-scoped queries carry every usage type except pod_count; requested types that don't apply to the scope are ignored. Defaults to the last 24 hours; start must be within the last 90 days, and a future end is clamped to now. The range divided by period must not exceed 1000 buckets. Corresponds to GET /v0/pods/{pod_id}/metrics/usage. ```bash agentmail pods metrics query-usage --pod-id ``` -------------------------------- ### GET /v0/apps/{app_id} Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Gets one app by ID or slug. A catalog app returns its full entry. A registered app that the catalog does not list returns its ID and name only, without updated_at. ```APIDOC ## GET /v0/apps/{app_id} ### Description Gets one app by ID or slug. A catalog app returns its full entry. A registered app that the catalog does not list returns its ID and name only, without `updated_at`, so anyone holding its ID can still look it up; a slug finds catalog apps only. ### Method GET ### Endpoint /v0/apps/{app_id} ### Parameters #### Path Parameters - **app_id** (string) - Required - ID of app, or the `slug` of an app in the catalog. A slug ignores case, spaces and punctuation. ### Response #### Success Response (200) - **id** (string) - App ID. - **name** (string) - App name. - **updated_at** (string) - Timestamp (only for catalog apps). ``` -------------------------------- ### POST /v0/apps/{app_id}/connect Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Starts signing an inbox in to an app. Returns a single-use magic_url valid for five minutes. The app can be identified by its slug. A 404 indicates a missing App or Inbox, and a 403 AppSignupLimitError indicates the app accepts no more sign-ups from your organization. ```APIDOC ## POST /v0/apps/{app_id}/connect ### Description Starts signing an inbox in to an app. Returns a single-use `magic_url`, valid for five minutes, to open in the client that will hold the sign-in; the client enrolls as the inbox and continues to the app. ### Method POST ### Endpoint /v0/apps/{app_id}/connect ### Parameters #### Path Parameters - **app_id** (string) - Required - ID of app, or the `slug` of an app in the catalog. A slug ignores case, spaces and punctuation. #### Request Body - **idempotency_key** (string) - Optional - Unique key that makes the connect idempotent. The endpoint requires one; the CLI generates a UUID when the flag is omitted and reuses it across retries, so a transient failure cannot start a second sign-in. Pass a value to make a manual re-run resolve to the same attempt. ### Response #### Success Response (200) - **magic_url** (string) - Single-use URL valid for five minutes. #### Error Responses - **404** - Missing resource: `App` or `Inbox`. - **403** - `AppSignupLimitError` - The app accepts no more sign-ups from your organization. ``` -------------------------------- ### GET /v0/inboxes/{inbox_id}/calendar/events/{event_id} Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Gets an event by its UUID, or one date of a recurring event by its dated ID. The response's etag is used for conditional updates. Requires the calendar_event_read permission. ```APIDOC ## GET /v0/inboxes/{inbox_id}/calendar/events/{event_id} ### Description Gets an event by its UUID, or one date of a recurring event by its dated ID (`_`). A dated ID returns the date as it currently stands, including any edit to it, with `kind: instance`. The response's `etag` (also the `ETag` header) is the value to send in `If-Match` to make an update, delete or response to this event or date conditional. Treat it as opaque. Reads can trail a change made moments earlier by a few seconds; pass `consistency=primary` to read the latest state of an event or a date. A date that has already started or ended reads back as it ran, even if a later change to the series no longer produces it. Requires the `calendar_event_read` permission. Calendar is in private beta: organizations without access receive a `403`. ### Method GET ### Endpoint /v0/inboxes/{inbox_id}/calendar/events/{event_id} ### Parameters #### Path Parameters - **inbox_id** (inboxesInboxId) - Required - The inbox ID. - **event_id** (CalendarEventId) - Required - The event UUID or dated ID. #### Query Parameters - **consistency** (CalendarConsistency) - Optional - Consistency level for the read. ### Response #### Success Response (200) Returns the event object. ``` -------------------------------- ### GET /v0/inboxes/{inbox_id}/calendar Source: https://github.com/agentmail-to/agentmail-cli/blob/main/reference.md Gets the inbox's calendar. Every inbox has one calendar, so this works before any event is created. The `etag` (also the `ETag` response header) is used for conditional updates. ```APIDOC ## GET /v0/inboxes/{inbox_id}/calendar ### Description Gets the inbox's calendar. Every inbox has one calendar, so this works before any event is created. Its `etag` (also the `ETag` response header) is the value to send in `If-Match` to make an update conditional. Requires the `calendar_read` permission. ### Method GET ### Endpoint `/v0/inboxes/{inbox_id}/calendar` ### Parameters #### Path Parameters - **inbox_id** (inboxesInboxId) - Required - The inbox ID. #### Query Parameters - **consistency** (CalendarConsistency) - Optional - Consistency level for the read. ### Response #### Success Response (200) - **calendar** (object) - The calendar object, including its `etag`. #### Error Responses - **403** - Organization lacks access to calendar (private beta). ### Notes - The `etag` is also returned in the `ETag` response header. ``` -------------------------------- ### OpenApiBinding::command_namespace Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/openapi.md Mounts all spec-derived subcommands under a namespace prefix. ```APIDOC ## OpenApiBinding::command_namespace ### Description Mounts all spec-derived subcommands under a namespace prefix (e.g. `cli api users list`). ### Method Builder method ### Signature ```rust pub fn command_namespace(mut self, namespace: impl Into) -> Self ``` ### Parameters - **namespace** (string) - Required - The namespace prefix under which all spec-derived subcommands are mounted. ### Returns The modified `OpenApiBinding` instance. ``` -------------------------------- ### agentmail CLI main.rs entry point Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/agentmail-binary.md The main function sets up the CLI app with BearerAuth from AGENTMAIL_API_KEY, an OpenAPI binding with the embedded spec, and runs the app. It also calls custom::register to add custom commands. ```rust mod custom; mod sdk; use fern_cli_sdk::app::CliApp; use fern_cli_sdk::openapi::OpenApiBinding; use fern_cli_sdk::auth::{BearerAuth}; fn main() { let app = CliApp::new("agentmail") .auth(BearerAuth::new("BearerAuth").env("AGENTMAIL_API_KEY")) .binding( OpenApiBinding::new() .spec(include_str!("openapi0.json")) ); let app = custom::register(app); app.run() } ``` -------------------------------- ### Initialize logging and load dotenv keys with fern_cli_sdk Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/api-reference/fern-cli-sdk.md Use this snippet to set up logging and load dotenv keys for a CLI application. It calls load_dotenv_filtered with the CLI name, then init_logging, and finally warns about ignored dotenv keys. ```rust use fern_cli_sdk::{init_logging, load_dotenv_filtered, warn_ignored_dotenv_keys}; fn main() { let cli_name = "agentmail"; let ignored = load_dotenv_filtered(cli_name); init_logging(cli_name); warn_ignored_dotenv_keys(&ignored); } ``` -------------------------------- ### GET v0/organizations Source: https://github.com/agentmail-to/agentmail-cli/blob/main/_autodocs/endpoints.md Retrieves the organization details. ```APIDOC ## GET v0/organizations ### Description Retrieves the organization details. ### Method GET ### Endpoint v0/organizations ### Response #### Success Response (200) - **Organization** - The organization details. ```