SendGrid API keys are created under Settings → API Keys in the SendGrid Console and are shown only once at creation. Permissions are set per key (Full Access, Custom Access, Billing Access or Email Address Validation Access), and there is no rotate button: you create a new key and delete the old one.
Twilio SendGrid key types
| Type | Prefix | Secret? | Scope | Expiry |
|---|---|---|---|---|
| API key A key cannot have more permissions than the account that creates it. Accounts are limited to 100 API keys. Billing API calls need a separate key. | — | Yes | Full Access, Custom Access (chosen endpoints and levels), Billing Access, or Email Address Validation Access | Does not expire until deleted |
How to create a Twilio SendGrid key
- Sign in to the SendGrid Console.
- Go to Settings → API Keys and create a key.
- Choose a permission level (Full Access, Custom Access, Billing Access or Email Address Validation Access).
- Copy the key right away. The Console displays it only once.
Limiting what the key can do
Choose Custom Access and select only the endpoints and access levels the integration needs. For a sender that only mails, grant just the mail send permission. A key cannot exceed the permissions of the account that makes it.
How to rotate a Twilio SendGrid key
- Create a new API key with the same permissions.
- Replace the old key in your code and secret stores.
- Delete the old key from Settings → API Keys (action menu → Delete API Key → Confirm).
SendGrid has no built-in rotation feature. Deleted keys cannot be restored.
How to revoke a Twilio SendGrid key
- Go to Settings → API Keys.
- Open the key's action menu, choose Delete API Key and confirm. SendGrid rejects calls made with the key afterwards.
If your Twilio SendGrid key leaked
- Delete the exposed key in Settings → API Keys.
- Create a replacement with the minimum permissions and update every app that used it.
- Review recent sending activity for mail you did not send.
Things that catch people out
- The key is displayed only once; a lost key means creating a new one.
- Use the v3 API with an
Authorization: Bearerheader, not account username and password. - Billing API calls need their own Billing Access key.
Common Twilio SendGrid authentication errors
Requires authentication
The request had no valid Authorization header, or the key was deleted.
`From` address doesn't match Verified Sender Identity
The request authenticated but the From address is not a verified sender (HTTP 403).
Using your Twilio SendGrid 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 Twilio SendGrid 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. |
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. |
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 SendGrid API key?
You cannot view an existing key. Create one under Settings → API Keys; the Console shows it only once at creation.
How do I rotate a SendGrid API key?
There is no rotate button. Create a new key, update your code, then delete the old key.
Does a SendGrid API key expire?
The docs describe no expiry; a key works until you delete it.
Can an AI agent use my Twilio SendGrid 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.