When to use
Use this when you need to change how SendGrid treats every message account-wide — enabling/disabling click and open tracking, adding a compliant footer, forcing TLS, or turning on the spam checker — via the Mail Settings and Tracking Settings APIs.
Not for: per-message options set in the send payload (see twilio-sendgrid-email-send) or per-recipient suppression management (see twilio-sendgrid-suppressions).
Method
- Distinguish the two setting groups. Mail Settings (
/v3/mail_settings/*) govern message handling: footer, forward spam, forward bounce, BCC, bounce purge, address whitelist, template, plain content. Tracking Settings (/v3/tracking_settings/*) govern instrumentation: click, open, subscription, Google Analytics.
- Set click and open tracking deliberately. Open tracking injects a pixel; click tracking rewrites URLs through your branded link domain. Decision point: sensitive/high-trust transactional mail (2FA codes, legal notices) → disable tracking to avoid URL rewriting and pixel warnings.
- Enable subscription tracking to inject a compliant one-click unsubscribe. This is effectively mandatory for bulk/marketing mail and improves reputation by giving recipients an alternative to the spam button.
- Use the footer setting for a global compliance footer (physical address, unsubscribe) when your templates do not already include one.
- Use sandbox mode during development — but note sandbox is a per-request mail setting in the send payload, not an account toggle; the account-level spam checker (
mail_settings/spam_check) is separate and screens outbound content.
- Enforce TLS via the account's transport requirements where available so mail is not sent in cleartext to receivers that support STARTTLS.
- Read current state before writing. GET each setting, change only the field you intend, PATCH back.
Example
Enable subscription tracking and disable click tracking for a transactional stream:
# Turn on one-click unsubscribe injection
curl -sS -X PATCH https://api.sendgrid.com/v3/tracking_settings/subscription \
-H "Authorization: Bearer $SENDGRID_API_KEY" \
-H "Content-Type: application/json" \
-d '{"enabled": true}'
# Turn OFF URL rewriting so 2FA links stay untouched
curl -sS -X PATCH https://api.sendgrid.com/v3/tracking_settings/click \
-H "Authorization: Bearer $SENDGRID_API_KEY" \
-H "Content-Type: application/json" \
-d '{"enabled": false}'
Pitfalls
- Click tracking on security mail. Rewritten URLs and redirect domains alarm users and some filters on 2FA/reset mail. Disable tracking on those streams.
- Open-tracking pixel on plaintext-critical mail. The pixel forces HTML and can trip filters; skip it where it adds no value.
- Blind PATCH without GET. Settings objects have multiple fields; PATCHing a partial body you assembled from memory can wipe a value. Read first.
- Assuming sandbox is account-wide. Sandbox mode is per-request in the send payload. Leaving it "on" in code means nothing ever delivers.
- No unsubscribe path. Marketing mail without subscription tracking or a footer link drives spam complaints and reputation loss.
Output format
# Mail/Tracking Settings: <account/stream>
MAIL SETTINGS: footer=<on/off> forward_spam=<..> bcc=<..> spam_check=<on/off>
TRACKING: open=<on/off> click=<on/off> subscription=<on/off>
TLS: enforced=<yes/no>
RATIONALE: <why each toggle for this stream>
CHANGED: [<field: old -> new>]
VERIFY: GET <setting> -> reflects change
Reference
- Mail Settings:
GET/PATCH https://api.sendgrid.com/v3/mail_settings/{footer,forward_spam,forward_bounce,bcc,bounce_purge,address_whitelist,template,plain_content,spam_check}.
- Tracking Settings:
GET/PATCH https://api.sendgrid.com/v3/tracking_settings/{click,open,subscription,google_analytics}.
- Auth:
Authorization: Bearer <API_KEY>; PATCH bodies are partial JSON.
- Deliverability note: subscription tracking (one-click unsubscribe) and a compliant footer directly reduce spam complaints; tracking on transactional/security mail can hurt more than help. Tune per stream, not globally.
1---2name: twilio-sendgrid-email-settings3description: Configure account-wide SendGrid mail behavior — sandbox mode, footer, click/open tracking, subscription tracking, BCC, spam checker, and the tracking settings that affect deliverability.4---56## When to use78Use this when you need to change how SendGrid treats every message account-wide — enabling/disabling click and open tracking, adding a compliant footer, forcing TLS, or turning on the spam checker — via the Mail Settings and Tracking Settings APIs.910**Not for:** per-message options set in the send payload (see `twilio-sendgrid-email-send`) or per-recipient suppression management (see `twilio-sendgrid-suppressions`).1112## Method13141. Distinguish the two setting groups. Mail Settings (`/v3/mail_settings/*`) govern message handling: footer, forward spam, forward bounce, BCC, bounce purge, address whitelist, template, plain content. Tracking Settings (`/v3/tracking_settings/*`) govern instrumentation: click, open, subscription, Google Analytics.152. Set click and open tracking deliberately. Open tracking injects a pixel; click tracking rewrites URLs through your branded link domain. Decision point: sensitive/high-trust transactional mail (2FA codes, legal notices) → disable tracking to avoid URL rewriting and pixel warnings.163. Enable subscription tracking to inject a compliant one-click unsubscribe. This is effectively mandatory for bulk/marketing mail and improves reputation by giving recipients an alternative to the spam button.174. Use the footer setting for a global compliance footer (physical address, unsubscribe) when your templates do not already include one.185. Use sandbox mode during development — but note sandbox is a per-request mail setting in the send payload, not an account toggle; the account-level spam checker (`mail_settings/spam_check`) is separate and screens outbound content.196. Enforce TLS via the account's transport requirements where available so mail is not sent in cleartext to receivers that support STARTTLS.207. Read current state before writing. GET each setting, change only the field you intend, PATCH back.2122## Example2324Enable subscription tracking and disable click tracking for a transactional stream:2526```bash27# Turn on one-click unsubscribe injection28curl -sS -X PATCH https://api.sendgrid.com/v3/tracking_settings/subscription \29 -H "Authorization: Bearer $SENDGRID_API_KEY" \30 -H "Content-Type: application/json" \31 -d '{"enabled": true}'3233# Turn OFF URL rewriting so 2FA links stay untouched34curl -sS -X PATCH https://api.sendgrid.com/v3/tracking_settings/click \35 -H "Authorization: Bearer $SENDGRID_API_KEY" \36 -H "Content-Type: application/json" \37 -d '{"enabled": false}'38```3940## Pitfalls4142- **Click tracking on security mail.** Rewritten URLs and redirect domains alarm users and some filters on 2FA/reset mail. Disable tracking on those streams.43- **Open-tracking pixel on plaintext-critical mail.** The pixel forces HTML and can trip filters; skip it where it adds no value.44- **Blind PATCH without GET.** Settings objects have multiple fields; PATCHing a partial body you assembled from memory can wipe a value. Read first.45- **Assuming sandbox is account-wide.** Sandbox mode is per-request in the send payload. Leaving it "on" in code means nothing ever delivers.46- **No unsubscribe path.** Marketing mail without subscription tracking or a footer link drives spam complaints and reputation loss.4748## Output format4950```51# Mail/Tracking Settings: <account/stream>52MAIL SETTINGS: footer=<on/off> forward_spam=<..> bcc=<..> spam_check=<on/off>53TRACKING: open=<on/off> click=<on/off> subscription=<on/off>54TLS: enforced=<yes/no>55RATIONALE: <why each toggle for this stream>56CHANGED: [<field: old -> new>]57VERIFY: GET <setting> -> reflects change58```5960## Reference6162- Mail Settings: `GET/PATCH https://api.sendgrid.com/v3/mail_settings/{footer,forward_spam,forward_bounce,bcc,bounce_purge,address_whitelist,template,plain_content,spam_check}`.63- Tracking Settings: `GET/PATCH https://api.sendgrid.com/v3/tracking_settings/{click,open,subscription,google_analytics}`.64- Auth: `Authorization: Bearer <API_KEY>`; PATCH bodies are partial JSON.65- Deliverability note: subscription tracking (one-click unsubscribe) and a compliant footer directly reduce spam complaints; tracking on transactional/security mail can hurt more than help. Tune per stream, not globally.