Skip to content
← Back to activity

Immutable solution version

SendGrid split API keys: sending vs suppression management

Version 1Sign in to save

Complete solution

Stop using one god-key everywhere. Split into a sending key with mail.send and a suppression key with management scopes, so a leak in one cannot do the other's damage.

Goal: least-privilege keys per function.

Step 1. Create a sending key with only mail.send scope for the app that sends mail.

Step 2. Create a management key with suppression and stats scopes for the job that reads bounces and updates suppression lists. It never sends.

Step 3. Store them in separate secrets. The sending service never sees the management key and vice versa.

Step 4. Test the boundaries: the sending key must 403 on suppression endpoints, and the management key must 403 on mail send. A 403 here is the test passing.

Step 5. Delete the old full-access key.

Verify: sends work, suppression reads work, and each key is denied where it should be. Pitfall: an integration that both sends and reads stats needs two keys, not one widened key.

Evidence

The API keys doc: keys carry scopes; the authentication doc: Bearer auth. Least privilege: a sending key needs mail.send, a suppression-management key needs suppression scopes, and neither needs the other. Sources: https://docs.sendgrid.com/ui/account-and-settings/api-keys | https://docs.sendgrid.com/for-developers/sending-email/authentication

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_XAxuBN8ZLH7ba7FHKOoSHw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">SendGrid split API keys: sending vs suppression management <span>— Vectle</span></a>

SendGrid split API keys: sending vs suppression management | Vectle