Skip to content
Rotate › SendGrid

How to rotate a SendGrid API key

SendGrid has no roll button: you create a new key, deploy it and delete the old one. That's easy to do with zero downtime. The parts that catch people are the permissions you give the new key and the 100-key ceiling.

Keysquid team · Updated · Checked against Twilio SendGrid's docs on November 30, 2026

Format
Starts with SG. and is 69 characters long.
Where
Settings → API Keys in the SendGrid app. Create API Key, then Create & View.
Shown once
SendGrid shows the key one time and can't retrieve or restore it later.
Access levels
Full Access, Custom Access (No, Read or Full per area) or Billing Access. Billing can't be combined with anything else.
Overlap
Yes: keys are independent, so old and new work side by side until you delete the old one.
Revoke
Action menu → Delete, or DELETE /v3/api_keys/{api_key_id}. Requests with a deleted key fail after a short propagation delay.
Limit
100 API keys per account. Creating more returns 403.
Scope ceiling
You can't give a key more permissions than you have yourself.
Keysquid
Automatic: a new key with the scopes you choose (mail.send by default), and the old one deleted.

Which access level should the new key have?

LevelWhat it can doUse it for
Full AccessEvery endpoint on the account except billing and Email Address ValidationAlmost nothing. Avoid for apps.
Custom AccessOnly the areas you set to Read Access or Full AccessApps: usually just mail.send
Billing AccessBilling endpoints onlyA separate key, kept apart from sending

Inside Custom Access, Read Access allows GET and Full Access allows GET, POST, PUT, PATCH and DELETE for that area.

An app that only sends mail needs one scope, mail.send. A rotation is the cheapest moment to fix a key that was created with Full Access years ago: the new key gets the narrow scope, and once the old one is deleted, the broad access is gone for good.

Rotate a key in the SendGrid app

  1. Go to Settings → API Keys and click Create API Key.
  2. Name it so you can tell it apart later (the name doesn’t need to be unique, so add a date or service), pick Custom Access and turn on only what the app uses.
  3. Click Create & View and copy the key straight into your secret store. This is the only time you’ll see it.
  4. Deploy it wherever SENDGRID_API_KEY lives and send a test message. A good send returns 202 Accepted.
  5. Back in API Keys, open the old key’s action menu and choose Delete.

Rotate a key with the API

You need an existing key with permission to manage API keys, and your very first key always has to be made in the app. Use https://api.eu.sendgrid.com instead of api.sendgrid.com for EU regional subusers.

SG=https://api.sendgrid.com/v3

# 1. Create the replacement. Always pass scopes: leaving them out creates a Full Access key.
curl -s -X POST "$SG/api_keys" -H "Authorization: Bearer $SENDGRID_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "web-app 2026-12", "scopes": ["mail.send"]}' | jq -r '.api_key, .api_key_id'

# 2. Deploy the new key, send a test, then delete the old one by its id
curl -s -X DELETE "$SG/api_keys/$OLD_KEY_ID" -H "Authorization: Bearer $SENDGRID_ADMIN_KEY"

The default that bites: POST /v3/api_keys without a scopes field gives the new key Full Access. Scripts written as “just make me a key” quietly upgrade every key they rotate.

To narrow an existing key without replacing it, PUT /v3/api_keys/{api_key_id} takes the key’s name and a scopes array with at least one scope. That changes what the key can do, but anyone who copied it still has it, so after a leak, replace the key instead.

Hitting the 100-key limit

Every rotation that forgets the last step leaves a live key behind, and at 100 keys SendGrid refuses to create another one with a 403. If you hit it, list the keys under Settings → API Keys (or GET /v3/api_keys), delete the ones nothing uses, and treat the clean-up as a review: each forgotten key was a working credential.

If a SendGrid key leaked

  1. Delete it first, then create the replacement. A stolen sending key is used to send spam and phishing from your domain, which damages your sender reputation quickly.
  2. Allow for the short propagation delay after deleting before you assume it’s dead.
  3. Look at your activity and statistics for sends you don’t recognise, and for new keys, senders or settings made with the leaked key if it had Full Access.
  4. Work through the wider checklist in the first 10 minutes after a key leak.

By hand vs. with Keysquid

By hand

  1. Create a Custom Access key and copy it once.
  2. Update every service and CI secret that sends mail.
  3. Send a test, then delete the old key.
  4. Keep an eye on the 100-key count.

With Keysquid

  1. Keysquid creates the new key with the scopes you set.
  2. It checks the key, writes it everywhere and redeploys.
  3. It deletes the old key after the grace period, so keys don’t pile up.
  4. It lists every key on the account, including ones it doesn’t manage.

How Keysquid handles SendGrid keys

Automatic Keysquid creates, verifies, distributes and revokes SendGrid keys on a schedule, with no one in the loop. API keys with the scopes you choose (mail.send by default).

Setup, as the app shows it:

  1. Create a SendGrid API key with the “API Keys” permission for Keysquid.
  2. SendGrid allows 100 keys per account; Keysquid deletes old keys so you won't hit it.
  • Writes to: API key (default variable SENDGRID_API_KEY), in every platform and secret store you map it to.
  • Interval: from every 1 hour to every 4 weeks, subject to your plan’s minimum.
  • Inventory: Keysquid lists every SendGrid key the connection can see, including keys it doesn’t manage, with names and last use.

Every rotation runs in the same order: create the new key, verify it, write it everywhere, redeploy where a platform needs it, and only then revoke the previous key after a grace period. If any write fails, everything written so far is restored and the new key is revoked. The value is encrypted to the agent you run, so Keysquid’s servers never see it.

Keysquid always sends an explicit scope list when it creates a key, so it never falls into the Full Access default. Its own connection key needs the API Keys permission, and because of the scope ceiling it can only hand out scopes that key already has. Choose the EU region when you connect if your account uses api.eu.sendgrid.com.

Frequently asked questions

Can I rotate a SendGrid API key without downtime?

Yes. SendGrid keys are independent, so create the new key, deploy it, confirm mail sends (202 Accepted), and only then delete the old key. Both work in the meantime.

Can I see a SendGrid API key again after creating it?

No. SendGrid shows the key once, at creation, and can't retrieve or restore it. If you lose it, create a new key and delete the old one.

How many API keys can a SendGrid account have?

100. At the limit, creating another key returns a 403, so delete keys you no longer use. Rotations that never delete the old key are the usual cause.

What permissions does a SendGrid key need just to send email?

Custom Access with mail.send. Full Access reaches every part of the account except billing and Email Address Validation, which an app that only sends mail doesn't need.

Why did my API-created SendGrid key get Full Access?

Because the scopes field was left out. POST /v3/api_keys creates a Full Access key by default; pass a scopes array such as ["mail.send"].

Is a deleted SendGrid key revoked immediately?

Deleting is permanent, but SendGrid notes that authentication with a revoked key fails after a small propagation delay, so expect a short tail.

Sources

  1. Twilio SendGrid docs: API keys (Settings → API Keys)
  2. Twilio SendGrid docs: API key permissions
  3. Twilio SendGrid API: Create API keys
  4. Twilio SendGrid API: Delete API keys
  5. Twilio SendGrid API: Update API key name and scopes
Rotate a SendGrid API Key (and Scope It Right)