# Twilio SendGrid API keys: find, store, rotate, and use them safely with AI agents

Source: https://botpassword.com/keys/sendgrid
Last checked: 2026-10-25

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.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| API 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

1. Sign in to the SendGrid Console.
2. Go to **Settings → API Keys** and create a key.
3. Choose a permission level (Full Access, Custom Access, Billing Access or Email Address Validation Access).
4. 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

1. Create a new API key with the same permissions.
2. Replace the old key in your code and secret stores.
3. Delete the old key from **Settings → API Keys** (action menu → Delete API Key → Confirm).

## How to revoke a Twilio SendGrid key

1. Go to **Settings → API Keys**.
2. Open the key's action menu, choose **Delete API Key** and confirm. SendGrid rejects calls made with the key afterwards.

## If the key leaked

1. Delete the exposed key in **Settings → API Keys**.
2. Create a replacement with the minimum permissions and update every app that used it.
3. Review recent sending activity for mail you did not send.

## Gotchas

- The key is displayed only once; a lost key means creating a new one.
- Use the v3 API with an `Authorization: Bearer` header, not account username and password.
- Billing API calls need their own Billing Access key.

## Using this key with AI agents (BotPassword)

- `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.

## FAQ

### 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.

## Sources

- https://www.twilio.com/docs/sendgrid/ui/account-and-settings/api-keys
- https://www.twilio.com/docs/sendgrid/api-reference/how-to-use-the-sendgrid-v3-api/authentication
- https://www.twilio.com/docs/sendgrid/api-reference/how-to-use-the-sendgrid-v3-api/responses
