Resend API keys are created on the API keys page of the dashboard (resend.com/api-keys). A key's value cannot be viewed or edited after creation, each key has a permission setting, and it can optionally be restricted to a domain.
Resend key types
| Type | Prefix | Secret? | Scope | Expiry |
|---|---|---|---|---|
| API key Resend suggests deleting keys unused for 30 days. | re_ | Yes | Permission set on the key (a sending-only key can only send emails); optionally restricted to a domain | Does not expire until removed |
How to create a Resend key
- Sign in to the Resend dashboard.
- Open API keys (
resend.com/api-keys) and create a key. - Choose its permission and, optionally, a domain restriction.
- Copy the key. You cannot view its value after it has been created.
Limiting what the key can do
Set the permission on each key and optionally restrict it to one domain; both can be edited later in the dashboard (More options → Edit API key). A key restricted to sending is rejected by other endpoints with restricted_api_key.
How to rotate a Resend key
- Create a new key with the same permission and domain restriction.
- Update every app and secret store to use it.
- Remove the old key (More options → Remove API key).
The docs do not describe a rotation flow; this is the create-replace-delete pattern.
How to revoke a Resend key
- Open the API keys page.
- Click More options → Remove API key on the key.
If your Resend key leaked
- Remove the exposed key from the API keys page.
- Create a replacement and update every deployment.
- Review sent emails for messages you did not send.
Environment variables and CLI
Resend's SDKs and docs read the key from RESEND_API_KEY.
Resend CLI (resend): resend login validates the key and saves it to the system credential store; in CI use RESEND_API_KEY or resend login --key
Things that catch people out
- You cannot view or edit a key's value after it is created.
- The CLI resolves the key in this order:
--api-keyflag,RESEND_API_KEY, then saved credentials. - The MCP server (
npx -y resend-mcp) reads the key fromRESEND_API_KEY.
Common Resend authentication errors
Missing API Key
No API key was sent with the request (HTTP 401, error name missing_api_key).
API key is invalid
The key is wrong or was removed (HTTP 400 or 401, error name validation_error).
This API key is restricted to only send emails.
A sending-only key was used on a non-sending endpoint (HTTP 401, restricted_api_key).
Using your Resend key with AI agents
A coding agent that can read your .env file or your shell history can read the key, and anything in its context can end up in logs, transcripts or a prompt-injected request. The safer pattern is to keep the key in a credential broker that performs the authenticated step for the agent and hands back only the result.
BotPassword works this way. For a Resend key, these intents fit:
| Intent | What BotPassword does |
|---|---|
run_with | Runs a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output. |
http_request | Makes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused. |
cli_login | Lets git, Docker, the AWS CLI and kubectl log in through bpw's credential helper, so the token is fetched when the tool needs it and not written into its config. The helper hands the value to the tool, so the grant is always disclosing. Other tools use run_with; OAuth device logins are planned. |
rotate | Partly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet. |
store_secret | Saves a value the agent already holds as a new vault item. |
Resend also publishes its own MCP server. Whatever server the agent uses, keep the credential it authenticates with out of the agent's context.
Set it up in your agent: Aider · Amp · Claude Code · Claude Desktop · Cline · OpenAI Codex CLI · all agents
Frequently asked questions
Where do I find my Resend API key?
Create or manage keys at resend.com/api-keys. The value is visible only when you create it.
Can a Resend API key be limited to sending only?
Yes. Keys have a permission setting, and a sending-only key is rejected on other endpoints with the message "This API key is restricted to only send emails."
How do I log in to the Resend CLI with an API key?
Run resend login, or set RESEND_API_KEY in CI. The environment variable takes priority over saved credentials.
Can an AI agent use my Resend key without seeing it?
Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a .env file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with run_with, http_request, store_secret, so the agent gets the result and never the value.