How do I create my first inbox?
An inbox gives your AI agent its own email address. You can create one on the shared @agentmail.to domain right away, or on your own domain once it is verified. For the full path from sign-up to your first sent email, follow the Quickstart.
Install the SDK
The examples below read your API key from the AGENTMAIL_API_KEY environment variable. Keep the key out of your source code. See How do I get my API key? to create one.
Create an inbox
With no arguments, AgentMail picks a random username on @agentmail.to:
email is the new address, such as cleverstar482@agentmail.to. Pass inbox_id (inboxId in TypeScript) to every other call on the inbox. The inbox can receive mail as soon as it exists.
Choose the address and make creation safe to retry
The main fields, all optional:
Use client_id whenever your agent creates its inbox on startup, so a restart or a retried request does not create a second inbox:
Send both text and html so the message reads well in every email client. To create inboxes on your own domain, set domain to a domain you have added and verified. Custom domains are available on the Developer plan and above; see How do I set up a custom domain?.
Common issues
Most error responses also carry a fix field with the next step. See the Error Reference for all error codes.
Next steps
- Send and receive emails in a conversational loop
- Set up webhooks to get notified when emails arrive
- Use labels to track message state in your agent workflows
- See What can I do with an AgentMail inbox? for everything else an inbox supports
