Providers
SendGrid
Send email through SendGrid.
import { createClient } from '@nicogenz/emails-sdk';
import { sendgrid } from '@nicogenz/emails-sdk/sendgrid';
const email = createClient({
provider: sendgrid({ apiKey: process.env.SENDGRID_API_KEY! }),
});
Options
| Option | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | Your SendGrid API key. |
region | 'global' | 'eu' | No | Use eu for accounts with EU data residency. Defaults to global. |
fetch | typeof fetch | No | A custom fetch implementation. |
Notes
tagsare sent as SendGridcustom_args.idempotencyKeyisn't supported. Passing one throws anEmailErrorwith the codeunsupported.sendBatchsends the emails one by one, because SendGrid has no endpoint for sending different emails in one request.- The returned
idis SendGrid'sX-Message-Id. Webhook events use a longersg_message_idthat starts with this ID.rawis empty, because SendGrid doesn't return a response body.