The official CLI for the AgentMail API.
npm install -g agentmail-cliexport AGENTMAIL_API_KEY=am_us_xxxagentmail [resource] <command> [flags...]# List inboxes
agentmail inboxes list
# Create an inbox
agentmail inboxes create --display-name "My Inbox"
# Send a message
agentmail inboxes:messages send \
--inbox-id inb_xxx \
--to user@example.com \
--subject "Hello" \
--text "Hi there"
# List threads
agentmail inboxes:threads list --inbox-id inb_xxxUse --help on any command for details.
| Environment variable | Required |
|---|---|
AGENTMAIL_API_KEY |
yes |
--api-key(can also be set withAGENTMAIL_API_KEYenv var)--help- Show command line usage--debug- Enable debug logging (includes HTTP request/response details)--version,-v- Show the CLI version--base-url- Use a custom API backend URL--format- Change the output format (auto,explore,json,jsonl,pretty,raw,yaml)--format-error- Change the output format for errors (auto,explore,json,jsonl,pretty,raw,yaml)--transform- Transform the data output using GJSON syntax--transform-error- Transform the error output using GJSON syntax
To pass files to your API, you can use the @myfile.ext syntax:
agentmail <command> --arg @abe.jpgFiles can also be passed inside JSON or YAML blobs:
agentmail <command> --arg '{image: "@abe.jpg"}'
# Equivalent:
agentmail <command> <<YAML
arg:
image: "@abe.jpg"
YAMLIf you need to pass a string literal that begins with an @ sign, you can
escape the @ sign to avoid accidentally passing a file.
agentmail <command> --username '\@abe'For JSON endpoints, the CLI tool does filetype sniffing to determine whether the
file contents should be sent as a string literal (for plain text files) or as a
base64-encoded string literal (for binary files). If you need to explicitly send
the file as either plain text or base64-encoded data, you can use
@file://myfile.txt (for string encoding) or @data://myfile.dat (for
base64-encoding). Note that absolute paths will begin with @file:// or
@data://, followed by a third / (for example, @file:///tmp/file.txt).
agentmail <command> --arg @data://file.txt