postkit
Guides

Migrate from SendGrid

Step-by-step guide to switch from SendGrid to Postkit

Moving from SendGrid to Postkit involves adapting to a simpler, flatter API structure. SendGrid's v3 API uses nested personalizations arrays and ECDSA webhook signing, while Postkit uses a flat request body and HMAC-SHA256 signing. This guide maps SendGrid's v3 API to Postkit equivalents and highlights the key structural differences.

Key differences

FeatureSendGridPostkit
API key prefixSG.pk_live_ / pk_test_
Base URLhttps://api.sendgrid.com/v3https://api.postkit.eu/v1
Send structureNested personalizations arrayFlat to array (max 50 recipients)
Webhook signingECDSA (asymmetric, public key)HMAC-SHA256 (symmetric, shared secret)
Suppression endpointsSeparate per type (/bounces, /blocks, /spam_reports)Unified /v1/suppressions with reason filter
Domain management"Domain authentication" / "whitelabel"POST /v1/domains

Endpoint mapping

OperationSendGridPostkit
Send emailPOST /v3/mail/sendPOST /v1/emails
Create domain authPOST /v3/whitelabel/domainsPOST /v1/domains
Webhook settingsPUT /v3/user/webhooks/event/settingsPOST /v1/webhooks
Create templatePOST /v3/templatesPOST /v1/templates
List suppressionsGET /v3/suppression/bounces (per type)GET /v1/suppressions?reason=hard_bounce
Get email activityGET /v3/messagesGET /v1/emails/{id}
Domain verificationAutomatic after DNS setupPOST /v1/domains/{id}/verify

Step-by-step migration

Get your Postkit API key

Sign up at app.postkit.eu and create an API key in Settings > API Keys. Production keys start with pk_live_. For testing the migration without sending real emails, create a sandbox key starting with pk_test_.

Update base URL and auth

Change your base URL from SendGrid's v3 API to Postkit's v1 API, and replace your SG. key with a pk_live_ key.

Before (SendGrid):

curl -X POST https://api.sendgrid.com/v3/mail/send \
  -H "Authorization: Bearer SG.abc123..."

After (Postkit):

curl -X POST https://api.postkit.eu/v1/emails \
  -H "Authorization: Bearer pk_live_abc123..."

Flatten your send request

This is the biggest change. SendGrid uses nested personalizations arrays, while Postkit uses a flat structure.

Before (SendGrid):

{
  "personalizations": [
    {
      "to": [{ "email": "user@example.com", "name": "User" }],
      "subject": "Hello from SendGrid"
    }
  ],
  "from": { "email": "you@yourdomain.com", "name": "You" },
  "content": [
    { "type": "text/html", "value": "<h1>Hello</h1>" }
  ]
}

After (Postkit):

{
  "from": "You <you@yourdomain.com>",
  "to": ["user@example.com"],
  "subject": "Hello from Postkit",
  "html": "<h1>Hello</h1>"
}

Key structural differences:

  • from is a string ("Name <email>" format), not an object
  • to is a flat array of email strings, not nested inside personalizations
  • subject is a top-level field, not inside personalizations
  • html and text replace the content array

Update webhook verification

SendGrid uses ECDSA (asymmetric) webhook signing with a public key. Postkit uses HMAC-SHA256 (symmetric) with a shared secret prefixed whsec_.

Replace your ECDSA verification code with HMAC-SHA256 verification. Postkit sends three headers with each webhook delivery: webhook-id, webhook-timestamp, and webhook-signature.

See the Webhooks guide for complete verification examples and the signing algorithm details.

Consolidate suppression endpoints

SendGrid uses separate endpoints for each suppression type (/suppression/bounces, /suppression/blocks, /suppression/spam_reports). Postkit unifies all suppressions under a single endpoint with optional filtering.

# SendGrid -- separate endpoints per type
GET /v3/suppression/bounces
GET /v3/suppression/blocks
GET /v3/suppression/spam_reports

# Postkit -- unified endpoint with reason filter
GET /v1/suppressions
GET /v1/suppressions?reason=hard_bounce
GET /v1/suppressions?reason=complaint

Verify your domain

Add your sending domain in Postkit and configure the DNS records. Unlike SendGrid where domain verification happens automatically after DNS setup, Postkit uses an explicit verification step.

See the Domain Setup guide for step-by-step DNS configuration instructions.

Test with sandbox keys

Use a pk_test_ key to verify your integration end-to-end without delivering actual emails. Once everything works as expected, switch to your pk_live_ key for production.

What's next?

  • Quickstart -- send your first email with Postkit
  • Domain Setup -- configure DNS records for production sending
  • Webhooks -- set up webhook endpoints and signature verification