This is the full developer documentation for MailPidge
# Introduction
> Send email from your server and reach users in your apps with push, in-app messages, a notification feed and SMS.
[Email API](/get-started/quickstart/)Send transactional email from your server.
[App SDKs](/sdks/concepts/)Push, in-app messages, a feed and SMS for your apps.
## Base URL
[Section titled “Base URL”](#base-url)
```text
https://api.mailpidge.com/api/v1
```
HTTPS and JSON only.
## Credentials
[Section titled “Credentials”](#credentials)
| Credential | Prefix | Lives in | Used for |
| -------------- | ------- | --------------------- | ---------------------------------------- |
| API key | `mpsk_` | Your server | Email, Users and Messages APIs, webhooks |
| Client key | `mpck_` | Your app | App SDKs |
| Identity token | JWT | Signed by your server | Proving which user is signed in |
Never ship an API key in an app or web page.
## Plan
[Section titled “Plan”](#plan)
Requires a Pro workspace. API emails count toward Pro’s 10,000 emails a month.
## For AI tools
[Section titled “For AI tools”](#for-ai-tools)
[/llms.txt](/llms.txt) · [/llms-full.txt](/llms-full.txt)
# Domains
> Add, verify, change and delete sending domains.
Scope: `domains:manage`. See [Domains](/email/domains/) for what the records do.
## The domain object
[Section titled “The domain object”](#the-domain-object)
```json
{
"id": "dom_7c2k",
"name": "pidgefit.com",
"status": "pending",
"tlsMode": "opportunistic",
"records": [
{ "type": "CNAME", "name": "abc123._domainkey", "value": "abc123.dkim.amazonses.com", "status": "pending" },
{ "type": "MX", "name": "bounce", "value": "10 feedback-smtp.us-east-1.amazonses.com", "status": "pending" },
{ "type": "TXT", "name": "bounce", "value": "v=spf1 include:amazonses.com ~all", "status": "pending" }
],
"createdAt": "2026-11-25T09:00:00.000Z"
}
```
## Create a domain
[Section titled “Create a domain”](#create-a-domain)
`POST /api/v1/domains`
| Field | Type | Notes |
| --------- | ------ | ------------------------------------------- |
| `name` | string | **Required.** Lowercased; no scheme or path |
| `tlsMode` | string | `opportunistic` (default) or `enforced` |
* Node.js
```ts
const domain = await mailpidge.domains.create({ name: 'pidgefit.com' })
console.log(domain.records)
```
* Python
```python
domain = mailpidge.domains.create(name="pidgefit.com")
print(domain.records)
```
* curl
```sh
curl https://api.mailpidge.com/api/v1/domains \
-H "Authorization: Bearer $MAILPIDGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "pidgefit.com" }'
```
Returns the domain object. `409 domain_claimed` if another workspace verified it.
## Verify a domain
[Section titled “Verify a domain”](#verify-a-domain)
`POST /api/v1/domains/{id}/verify` checks the DNS records now instead of waiting for the next automatic check. Returns the domain object.
## List domains
[Section titled “List domains”](#list-domains)
`GET /api/v1/domains` returns `{ "domains": [domain, …] }`.
## Get a domain
[Section titled “Get a domain”](#get-a-domain)
`GET /api/v1/domains/{id}`
## Update a domain
[Section titled “Update a domain”](#update-a-domain)
`PATCH /api/v1/domains/{id}` with `{ "tlsMode": "enforced" }`.
## Delete a domain
[Section titled “Delete a domain”](#delete-a-domain)
`DELETE /api/v1/domains/{id}` returns `204`. Scheduled emails from the domain fail.
# Emails
> Send, schedule, read and cancel transactional emails.
Scope `emails:send`. Transactional only; for marketing, use campaigns in the app.
## Send an email
[Section titled “Send an email”](#send-an-email)
`POST /api/v1/emails`
| Field | Type | Notes |
| ------------- | --------- | ---------------------------------------------------------------------------------------------------------------- |
| `from` | string | **Required.** `Name ` on a verified domain |
| `to` | string\[] | **Required.** 1 to 50 addresses |
| `subject` | string | **Required** |
| `html` | string | `html` or `text` is required |
| `text` | string | Plain-text part; generated from `html` when missing |
| `cc`, `bcc` | string\[] | Count toward the 50 |
| `replyTo` | string\[] | |
| `attachments` | object\[] | `filename`, `content` (base64), `contentType`, optional `contentId` for inline images. 40 MB per email in total. |
| `tags` | object\[] | `name` and `value`; returned in webhooks and metrics |
| `headers` | object | Extra headers, such as `X-Entity-Ref-ID` |
| `scheduledAt` | string | ISO 8601, up to 30 days ahead |
Add an [`Idempotency-Key`](/get-started/rate-limits/#idempotency) header so retries never send twice.
* Node.js
```ts
const email = await mailpidge.emails.send(
{
from: 'Pidge Fit ',
to: ['jamie@example.com'],
subject: 'Your receipt',
html: 'Thanks for your order.
',
tags: [{ name: 'category', value: 'receipt' }],
},
{ idempotencyKey: 'order-58213-receipt' },
)
```
* Python
```python
email = mailpidge.emails.send(
from_="Pidge Fit ",
to=["jamie@example.com"],
subject="Your receipt",
html="Thanks for your order.
",
tags=[{"name": "category", "value": "receipt"}],
idempotency_key="order-58213-receipt",
)
```
* curl
```sh
curl https://api.mailpidge.com/api/v1/emails \
-H "Authorization: Bearer $MAILPIDGE_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-58213-receipt" \
-d '{
"from": "Pidge Fit ",
"to": ["jamie@example.com"],
"subject": "Your receipt",
"html": "Thanks for your order.
",
"tags": [{ "name": "category", "value": "receipt" }]
}'
```
**Response `200`**
```json
{ "id": "em_01JD4V8QK3S6T2Y9Z7XWB5N0RA", "suppressed": [] }
```
`suppressed`: recipients skipped as [suppressed](/email/suppressions/).
[Errors](/get-started/errors/): `invalid_request`, `domain_not_allowed`, `recipient_suppressed`, `monthly_limit_reached`, `idempotency_key_reused`, `rate_limited`.
## Send a batch
[Section titled “Send a batch”](#send-a-batch)
`POST /api/v1/emails/batch`
Up to 100 emails with the fields above, except `attachments` and `scheduledAt`.
```sh
curl https://api.mailpidge.com/api/v1/emails/batch \
-H "Authorization: Bearer $MAILPIDGE_API_KEY" \
-H "Content-Type: application/json" \
-d '[
{ "from": "Pidge Fit ", "to": ["a@example.com"], "subject": "Hi A", "html": "Hi
" },
{ "from": "Pidge Fit ", "to": ["b@example.com"], "subject": "Hi B", "html": "Hi
" }
]'
```
**Response `200`**
```json
{ "emails": [{ "id": "em_01JD4V…RA" }, { "id": "em_01JD4V…RB" }] }
```
## Get an email
[Section titled “Get an email”](#get-an-email)
`GET /api/v1/emails/{id}`
```json
{
"id": "em_01JD4V8QK3S6T2Y9Z7XWB5N0RA",
"from": "Pidge Fit ",
"to": ["jamie@example.com"],
"subject": "Your receipt",
"createdAt": "2026-11-25T09:14:01.002Z",
"scheduledAt": null,
"lastEvent": "delivered",
"tags": [{ "name": "category", "value": "receipt" }]
}
```
`lastEvent` is one of `queued`, `scheduled`, `sent`, `delivered`, `delivery_delayed`, `bounced`, `complained`, `failed`, `suppressed`, `canceled`, `opened`, `clicked`.
## List emails
[Section titled “List emails”](#list-emails)
`GET /api/v1/emails?limit=50&cursor={nextCursor}`
`limit` is 1 to 100 (default 50). Newest first.
```json
{ "emails": [{ "id": "em_…", "subject": "Your receipt", "lastEvent": "delivered", "createdAt": "…" }], "nextCursor": "c_8Jd…" }
```
Pass `nextCursor` as `cursor` to get the next page; it is `null` on the last page.
## Reschedule an email
[Section titled “Reschedule an email”](#reschedule-an-email)
`PATCH /api/v1/emails/{id}` with `{ "scheduledAt": "2026-11-28T09:00:00Z" }`. Only for emails that haven’t been sent.
## Cancel an email
[Section titled “Cancel an email”](#cancel-an-email)
`POST /api/v1/emails/{id}/cancel`. Only for scheduled emails that haven’t been sent. Returns the email with `lastEvent: "canceled"`.
# Messages
> Send push, in-app, feed and SMS messages to users, segments or devices.
Scope: `messages:send`. For email, use [Emails](/api/emails/).
## Send a message
[Section titled “Send a message”](#send-a-message)
`POST /api/v1/messages`
| Field | Type | Notes |
| ------------ | ------ | ----------------------------------------------------------------------------------------------- |
| `appId` | string | **Required** |
| `channel` | string | **Required.** `push`, `in_app`, `feed` or `sms` |
| `target` | object | **Required.** Exactly one of `aliases`, `segmentId`, `subscriptionIds` |
| `content` | object | `title`, `body`, `url`, `imageUrl`, `data`, `buttons`, per language: `{ "en": {…}, "ko": {…} }` |
| `templateId` | string | Instead of `content` |
| `topic` | string | Consent topic, such as `promotions`. Marketing topics go only to opted-in users. |
| `sendAfter` | string | ISO 8601, up to 30 days ahead |
| `ttlSeconds` | number | Drop if not delivered in time |
`target.aliases` takes up to 20,000 ids: `{ "external_id": ["u_8812", "u_9001"] }`.
* Node.js
```ts
const message = await mailpidge.messages.send(
{
appId: 'pidgefit-ios',
channel: 'push',
target: { aliases: { external_id: ['u_8812'] } },
content: { en: { title: 'Streak at risk', body: 'One workout keeps your 12-day streak.', url: 'pidgefit://today' } },
},
{ idempotencyKey: 'streak-u_8812-2026-11-25' },
)
```
* Python
```python
message = mailpidge.messages.send(
app_id="pidgefit-ios",
channel="push",
target={"aliases": {"external_id": ["u_8812"]}},
content={"en": {"title": "Streak at risk", "body": "One workout keeps your 12-day streak.", "url": "pidgefit://today"}},
idempotency_key="streak-u_8812-2026-11-25",
)
```
* curl
```sh
curl https://api.mailpidge.com/api/v1/messages \
-H "Authorization: Bearer $MAILPIDGE_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: streak-u_8812-2026-11-25" \
-d '{
"appId": "pidgefit-ios",
"channel": "push",
"target": { "aliases": { "external_id": ["u_8812"] } },
"content": { "en": { "title": "Streak at risk", "body": "One workout keeps your 12-day streak.", "url": "pidgefit://today" } }
}'
```
**Response `200`**
```json
{ "id": "msg_01JD4W2F…", "status": "queued" }
```
Each recipient’s result shows in the delivery log and as webhooks. See [Push delivery outcomes](/troubleshooting/push-delivery-outcomes/).
### Safety limit
[Section titled “Safety limit”](#safety-limit)
Sending more than 10× an app’s subscriber count within 15 minutes pauses sends and alerts owners.
## Get a message
[Section titled “Get a message”](#get-a-message)
`GET /api/v1/messages/{id}`
```json
{ "id": "msg_01JD4W2F…", "channel": "push", "status": "sending", "counts": { "targeted": 1, "delivered": 1, "failed": 0, "skipped": 0 } }
```
## List messages
[Section titled “List messages”](#list-messages)
`GET /api/v1/messages?limit=50&cursor={nextCursor}` returns `{ "messages": [...], "nextCursor": … }`.
## Cancel a message
[Section titled “Cancel a message”](#cancel-a-message)
`POST /api/v1/messages/{id}/cancel` stops a scheduled message, or the part of a large send that hasn’t gone out.
## Live Activities
[Section titled “Live Activities”](#live-activities)
On iPhone, `channel: "push"` with `liveActivity` starts, updates or ends a [Live Activity](/features/live-activities/):
```json
{
"appId": "pidgefit-ios",
"channel": "push",
"target": { "aliases": { "external_id": ["u_8812"] } },
"liveActivity": { "event": "update", "activityId": "run-2026-11-25", "contentState": { "distanceKm": 4.2 } }
}
```
`event` is `start`, `update` or `end`.
# Metrics
> Daily email counts for your workspace.
Scope: `analytics:read`.
## Get metrics
[Section titled “Get metrics”](#get-metrics)
`GET /api/v1/metrics?from=2026-11-01&to=2026-11-25`
| Query | Notes |
| ------------ | ---------------------------------------------- |
| `from`, `to` | **Required.** Dates (UTC), up to 90 days apart |
| `domain` | Only emails from this domain |
| `tag` | Only emails with this tag, as `name:value` |
```json
{
"metrics": [
{
"date": "2026-11-24",
"sent": 1204,
"delivered": 1190,
"bounced": 6,
"complained": 1,
"opened": 612,
"clicked": 140,
"unsubscribed": 3
}
]
}
```
`opened` counts Apple Mail privacy opens too; webhooks mark them with `isAppleMailPrivacyProtectionOpen`.
# Suppressions
> Read, add and remove suppressed addresses.
Scope: `suppressions:manage`. See [Suppressions](/email/suppressions/).
## List suppressions
[Section titled “List suppressions”](#list-suppressions)
`GET /api/v1/suppressions?limit=100&cursor={nextCursor}`
`limit` is 1 to 100 (default 50).
```json
{
"suppressions": [
{ "email": "old@example.com", "reason": "bounce", "createdAt": "2026-11-02T10:11:12.000Z" }
],
"nextCursor": null
}
```
## Add a suppression
[Section titled “Add a suppression”](#add-a-suppression)
`POST /api/v1/suppressions`
```sh
curl https://api.mailpidge.com/api/v1/suppressions \
-H "Authorization: Bearer $MAILPIDGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "email": "no-more@example.com" }'
```
Added with reason `manual`. Returns `201`.
## Remove a suppression
[Section titled “Remove a suppression”](#remove-a-suppression)
`DELETE /api/v1/suppressions/{email}` returns `204`. The address can receive email again.
# Users
> Create and update users, aliases, tags and subscriptions from your server.
Scopes `users:read`, `users:write`. Terms: [Concepts](/sdks/concepts/#users-and-subscriptions).
Address a user by any alias: `/apps/pidgefit-ios/users/by/external_id/u_8812`.
## The user object
[Section titled “The user object”](#the-user-object)
```json
{
"aliases": { "external_id": "u_8812", "crm_id": "c-5501" },
"tags": { "plan": "pro" },
"language": "en",
"timezone": "America/New_York",
"subscriptions": [
{ "id": "sub_2v8d", "type": "ios_push", "status": "active", "sdk": "MailPidgeLifecycleSDK/1.0.0", "lastSessionAt": "2026-11-24T18:02:11.000Z" },
{ "id": "sub_4m1q", "type": "email", "status": "active", "address": "jamie@example.com" }
],
"firstSessionAt": "2026-10-02T07:30:00.000Z",
"sessionCount": 41
}
```
Subscription `type` is `ios_push`, `macos_push`, `android_push`, `web_push`, `windows_push`, `email` or `sms`.
## Create a user
[Section titled “Create a user”](#create-a-user)
`POST /api/v1/apps/{appId}/users`
* Node.js
```ts
await mailpidge.users.create('pidgefit-ios', {
aliases: { external_id: 'u_8812' },
tags: { plan: 'pro' },
subscriptions: [{ type: 'email', address: 'jamie@example.com' }],
})
```
* Python
```python
mailpidge.users.create(
"pidgefit-ios",
aliases={"external_id": "u_8812"},
tags={"plan": "pro"},
subscriptions=[{"type": "email", "address": "jamie@example.com"}],
)
```
* curl
```sh
curl https://api.mailpidge.com/api/v1/apps/pidgefit-ios/users \
-H "Authorization: Bearer $MAILPIDGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "aliases": { "external_id": "u_8812" }, "tags": { "plan": "pro" },
"subscriptions": [{ "type": "email", "address": "jamie@example.com" }] }'
```
If a user with that alias exists, it is updated instead.
## Get a user
[Section titled “Get a user”](#get-a-user)
`GET /api/v1/apps/{appId}/users/by/{aliasLabel}/{aliasValue}`
## Update a user
[Section titled “Update a user”](#update-a-user)
`PATCH /api/v1/apps/{appId}/users/by/{aliasLabel}/{aliasValue}` with `tags`, `language` or `timezone`. A tag set to `""` is removed.
## Delete a user
[Section titled “Delete a user”](#delete-a-user)
`DELETE /api/v1/apps/{appId}/users/by/{aliasLabel}/{aliasValue}` erases the user with their subscriptions, events, feed and consent records. Returns `202`; erasure finishes within 30 days.
## Add aliases
[Section titled “Add aliases”](#add-aliases)
`POST /api/v1/apps/{appId}/users/by/{aliasLabel}/{aliasValue}/aliases` with `{ "aliases": { "crm_id": "c-5501" } }`. Up to 10 per user.
## Remove an alias
[Section titled “Remove an alias”](#remove-an-alias)
`DELETE /api/v1/apps/{appId}/users/by/{aliasLabel}/{aliasValue}/aliases/{label}`. `external_id` can’t be removed.
## Move a subscription
[Section titled “Move a subscription”](#move-a-subscription)
`POST /api/v1/apps/{appId}/subscriptions/{subscriptionId}/transfer` with `{ "to": { "external_id": "u_9001" } }` moves a device to another user of the same app. Consent doesn’t move with it.
# Webhooks
> Create endpoints, rotate secrets and retry deliveries.
Scope: `webhooks:manage`. See [Webhooks](/webhooks/) for events and signatures.
## The webhook object
[Section titled “The webhook object”](#the-webhook-object)
```json
{
"subscriptionId": "dwh_5n2p",
"url": "https://pidgefit.com/webhooks/mailpidge",
"eventTypes": ["email.bounced", "email.complained"],
"status": "active",
"secretHint": "9fQx",
"lastDeliveryAt": "2026-11-25T09:14:04.020Z",
"failedDeliveryCount": 0,
"createdAt": "2026-11-25T09:00:00.000Z",
"updatedAt": "2026-11-25T09:00:00.000Z"
}
```
`status` is `active`, `paused` or `disabled`. `secretHint` is the secret’s last 4 characters, to tell endpoints apart.
## Create a webhook
[Section titled “Create a webhook”](#create-a-webhook)
`POST /api/v1/webhooks`
| Field | Type | Notes |
| ------------ | --------- | ----------------------------------------------------- |
| `url` | string | **Required.** HTTPS, public address |
| `eventTypes` | string\[] | **Required.** At least one [event](/webhooks/#events) |
* Node.js
```ts
const webhook = await mailpidge.webhooks.create({
url: 'https://pidgefit.com/webhooks/mailpidge',
eventTypes: ['email.bounced', 'email.complained'],
})
```
* Python
```python
webhook = mailpidge.webhooks.create(
url="https://pidgefit.com/webhooks/mailpidge",
event_types=["email.bounced", "email.complained"],
)
```
* curl
```sh
curl https://api.mailpidge.com/api/v1/webhooks \
-H "Authorization: Bearer $MAILPIDGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "url": "https://pidgefit.com/webhooks/mailpidge", "eventTypes": ["email.bounced", "email.complained"] }'
```
**Response `201`**: `{ "subscription": {…}, "secret": "whsec_…" }`. The secret is returned only here; store it.
A workspace can have 10 webhooks; the 11th returns `subscription_limit_reached`.
## List webhooks
[Section titled “List webhooks”](#list-webhooks)
`GET /api/v1/webhooks` returns `{ "subscriptions": [webhook, …] }`.
## Get a webhook
[Section titled “Get a webhook”](#get-a-webhook)
`GET /api/v1/webhooks/{subscriptionId}`
## Update a webhook
[Section titled “Update a webhook”](#update-a-webhook)
`PUT /api/v1/webhooks/{subscriptionId}` with any of `url`, `eventTypes` and `status` (`active` or `paused`).
## Delete a webhook
[Section titled “Delete a webhook”](#delete-a-webhook)
`DELETE /api/v1/webhooks/{subscriptionId}` returns `204`.
## Rotate a secret
[Section titled “Rotate a secret”](#rotate-a-secret)
`POST /api/v1/webhooks/{subscriptionId}/rotate-secret` returns the new `secret`. Both secrets sign requests for 72 hours.
## List deliveries
[Section titled “List deliveries”](#list-deliveries)
`GET /api/v1/webhooks/{subscriptionId}/deliveries?limit=50&cursor={nextCursor}`
`limit` is 1 to 100 (default 50).
```json
{
"deliveries": [
{
"deliveryId": "dwd_9r1x",
"subscriptionId": "dwh_5n2p",
"eventType": "email.bounced",
"eventId": "evt_6f1c2b0e9a7d4c3b",
"attemptCount": 10,
"lastStatusCode": 500,
"lastError": "HTTP 500",
"lastAttemptAt": "2026-11-26T02:20:41.000Z",
"status": "dead_lettered",
"deliveredAt": null,
"createdAt": "2026-11-25T09:14:04.020Z"
}
],
"nextCursor": null
}
```
`status` is `pending`, `delivered` or `dead_lettered` (gave up after the last retry).
## Retry a delivery
[Section titled “Retry a delivery”](#retry-a-delivery)
`POST /api/v1/webhooks/{subscriptionId}/deliveries/{deliveryId}/retry` sends a `dead_lettered` delivery again. Any other status returns `409 delivery_not_dead_lettered`.
# Domains
> Verify a sending domain with DKIM, a custom MAIL FROM and DMARC.
Add your domain in **Settings → Delivery → Sending domains**, or with [Create a domain](/api/domains/#create-a-domain).
## DNS records
[Section titled “DNS records”](#dns-records)
Exact values appear in the app and the API response.
| Type | Name | Value | For |
| ----- | --------------------- | ------------------------------------------ | ------------------- |
| CNAME | `._domainkey` | `.dkim.amazonses.com` | DKIM |
| CNAME | `._domainkey` | `.dkim.amazonses.com` | DKIM |
| CNAME | `._domainkey` | `.dkim.amazonses.com` | DKIM |
| MX | `bounce` | `10 feedback-smtp.us-east-1.amazonses.com` | Bounces |
| TXT | `bounce` | `v=spf1 include:amazonses.com ~all` | SPF |
| TXT | `_dmarc` | `v=DMARC1; p=none;` | DMARC (recommended) |
Usually verified within minutes; DNS can take up to 72 hours.
## Status
[Section titled “Status”](#status)
| Status | Meaning |
| ---------- | ------------------------------------- |
| `pending` | Records not found yet |
| `verified` | Ready to send |
| `failed` | Records were found, then went missing |
## TLS mode
[Section titled “TLS mode”](#tls-mode)
| Mode | Behavior |
| --------------- | ---------------------------------------------------- |
| `opportunistic` | TLS when offered (default) |
| `enforced` | TLS required; fails instead of sending in plain text |
## Already claimed
[Section titled “Already claimed”](#already-claimed)
A domain belongs to one workspace. If another workspace verified it, you get `409 domain_claimed` and a TXT record to prove ownership.
# SMTP relay
> Send through MailPidge from any app that speaks SMTP.
Create credentials in **Settings → Developers → SMTP**. The password is shown once.
| Setting | Value |
| -------- | ------------------------------------ |
| Host | `email-smtp.us-east-1.amazonaws.com` |
| Port | `587` (STARTTLS) or `465` (TLS) |
| Username | Starts with `mp-smtp-` |
| Password | Shown once |
Sends only from your verified domains, and counts toward the same monthly limit as the API.
| Action | Effect |
| ------ | ------------------------------------------------------- |
| Rotate | New password; the old one works until the next rotation |
| Revoke | Both stop at once |
# Suppressions
> Addresses MailPidge will not send to.
Suppressed recipients are skipped and returned in `suppressed`. If all are suppressed: `422 recipient_suppressed`.
| Reason | Added when |
| ------------- | ----------------------------------- |
| `bounce` | The address is rejected permanently |
| `complaint` | The recipient marks you as spam |
| `unsubscribe` | The recipient unsubscribes |
| `manual` | You add it |
The list is per workspace. Manage it in **Audience → Suppressions** or with the [Suppressions API](/api/suppressions/).
# In-app messages
> Banners, modals and full-screen messages inside your app.
Add your SDK’s `in-app` product. The SDK fetches active messages at session start and shows each when its trigger fires.
| Trigger | Example |
| ------------- | ------------------------- |
| Session start | Welcome back |
| Event | After `workout_completed` |
| Tag | When `plan` becomes `pro` |
| Content | Rendered as |
| ----------------------------- | -------------------------------------------------------------- |
| Blocks (text, image, buttons) | Native views |
| HTML | Sandboxed web view, no remote scripts, up to 1 MB per language |
HTML can call only `tag`, `openUrl`, `addClickName`, `triggerPushPrompt` and `close`. `triggerPushPrompt` records [consent](/sdks/concepts/#consent), then shows the OS prompt.
Send with the [Messages API](/api/messages/) (`channel: "in_app"`). Events: `in_app.delivered`, `opened`, `clicked`, `dismissed`.
# Live Activities and Live Updates
> Update a lock-screen activity on iPhone, or an ongoing notification on Android, from your server.
| Platform | Feature |
| ------------------- | ---------------------------------------------------------------------------- |
| iPhone (iOS 16.1+) | Live Activities; add the `live-activity` product |
| Android | Live Updates (promoted ongoing notification; a normal one where not allowed) |
| macOS, web, Windows | Not available |
On iPhone the SDK registers `push_to_start` (start from your server) and `activity_update` (update or end one activity) tokens.
Send `start`, `update` and `end` with the [Messages API](/api/messages/#live-activities). Transactional only: marketing topics are refused.
# Location
> Target users by country or by area.
| Targeting | Needs |
| ----------------- | ----------------------------------------------------------------------------------------- |
| Country | Nothing; recorded from the network at each session |
| Areas (geofences) | The `location` product, [consent](/sdks/concepts/#consent) and the OS location permission |
Geofences are checked on the device and reported as enter and leave events. Only the latest coarse location is kept, and it expires. Locations never appear in logs, exports or AI prompts.
# Notification feed
> A per-user list of messages inside your app, with unread counts.
| Platform | Ready-made view |
| ----------------------- | ----------------------------- |
| Web | `` |
| iOS, macOS | `MailPidgeFeedView` (SwiftUI) |
| Android, Kotlin desktop | `MailPidgeFeed` (Compose) |
For your own UI, the headless model gives items, the unread count, `markRead`, `markSeen` and `archive`.
| Rule | |
| --------- | -------------------------------------------------------------------------------------------------------------------------- |
| Access | Signed-in users need an [identity token](/sdks/concepts/#identity-verification); anonymous devices see only their own feed |
| Sign-in | The anonymous feed merges into the user’s |
| Updates | Silent push, or polling when push isn’t available |
| Retention | 90 days; deleted with the user |
Send with the [Messages API](/api/messages/) (`channel: "feed"`) or a journey step.
# SMS
> Register a sending number and text your users.
Register in **Settings → Delivery → SMS sender**. Carrier review takes days to weeks.
| Number | Countries | Needs |
| --------- | ---------- | ------------------------------------------------------ |
| Toll-free | US, Canada | Business details, public privacy policy and terms URLs |
| 10DLC | US | Brand and campaign registration |
| Rule | |
| ------------- | ---------------------------------------------------------------------------- |
| Cost | At cost, with a monthly spend cap that stops sending when reached |
| Opt-out | STOP, QUIT, END, REVOKE, OPT OUT, CANCEL and UNSUBSCRIBE are handled for you |
| Hours | Marketing held outside 08:00–21:00 recipient local time |
| Numbers | E.164, such as `+14155550142` |
| Not supported | South Korea (`sms_destination_unsupported`) |
Add numbers with `addSms`, then send with the [Messages API](/api/messages/) (`channel: "sms"`) or a journey step.
# API keys
> Create, scope, limit and rotate the keys your server uses.
Send the key as a bearer token:
```http
Authorization: Bearer mpsk_live_…
```
Create keys in **Settings → Developers → API keys** (owners and admins). The key is shown once.
## Access
[Section titled “Access”](#access)
| Access | Scopes |
| -------------- | ---------------------------------------- |
| Full access | All |
| Sending access | `emails:send`, optionally for one domain |
| Custom | The ones you pick |
## Scopes
[Section titled “Scopes”](#scopes)
| Scope | Allows |
| ---------------------------------- | ----------------------------------------------- |
| `emails:send` | Send, schedule and cancel emails |
| `domains:manage` | Manage sending domains |
| `suppressions:manage` | Manage the suppression list |
| `analytics:read` | Read metrics |
| `webhooks:manage` | Manage webhooks |
| `users:read` · `users:write` | Read or change users, aliases and subscriptions |
| `messages:send` | Send push, in-app, feed and SMS messages |
| `segments:read` · `segments:write` | Read or change segments |
| `apps:manage` | Change app settings and push credentials |
| `lifecycle:write` | Send user events from your server |
| `templates:write` | Manage templates |
| `plans:write` · `plans:activate` | Manage plans; start a plan (owner only) |
Missing scope: `403 scope_required`.
## Limits
[Section titled “Limits”](#limits)
| Setting | Values |
| ------------ | ----------------------------------------------------------- |
| Domain | Any, or one domain (sending keys) |
| Expiry | 1, 3, 7, 30, 90 (default) or 365 days, or custom up to 365 |
| IP allowlist | Optional IPv4/IPv6 CIDR ranges; other addresses are refused |
Owners get an email before a key expires.
## Rotate
[Section titled “Rotate”](#rotate)
Create a new key, deploy it, check **Last used** on the old one, then revoke the old one.
# Errors
> Every error code, its response body and what to do.
```json
{ "error": "invalid_request", "message": "to must contain between 1 and 50 addresses" }
```
Match on `error`; `message` may change.
| Status | `error` | Cause | Action |
| ------ | --------------------------- | ------------------------------------------------------------ | ------------------------------------- |
| 400 | `invalid_request` | A field is missing or invalid; `message` names it | Fix the request |
| 401 | `credential_invalid` | Missing, malformed or unknown key | Check the key |
| 401 | `credential_expired` | Key expired | Create a new key |
| 401 | `credential_revoked` | Key revoked | Create a new key |
| 401 | `service_account_disabled` | The key’s service account is disabled | Enable it or use another key |
| 403 | `scope_required` | Key lacks the scope; `requiredScope` names it | Add the scope |
| 403 | `ip_not_allowed` | Address not on the key’s allowlist | Add the address |
| 403 | `domain_not_allowed` | `from` domain not verified, or the key is for another domain | Fix `from` or the key |
| 403 | `pro_subscription_required` | Workspace isn’t on Pro | Upgrade |
| 404 | `not_found` | No such resource in this workspace | Check the id |
| 409 | `idempotency_key_reused` | Same `Idempotency-Key`, different body, within 24 h | Use a new key |
| 409 | `domain_claimed` | Another workspace verified this domain | Prove ownership with the TXT record |
| 422 | `recipient_suppressed` | Every recipient is suppressed | Remove them or the suppressions |
| 422 | `monthly_limit_reached` | 10,000 emails sent this month | Wait for the next month |
| 429 | `rate_limited` | Over 600 requests a minute | Retry after `Retry-After` |
| 503 | `rate_limiter_unavailable` | Limiter unreachable; refused, not allowed | Retry with backoff |
| 503 | `service_unavailable` | A dependency is down | Retry with backoff |
| 500 | `internal_error` | Unexpected error | Contact us with the time and endpoint |
Retry only `429` and `5xx`, with an [`Idempotency-Key`](/get-started/rate-limits/#idempotency). The Node SDK does this for you (3 tries: 1 s, 2 s, 4 s, or `Retry-After`) and throws `MailPidgeApiError`.
Push codes: [Push delivery outcomes](/troubleshooting/push-delivery-outcomes/).
# Quickstart
> Send your first email with Node, Python or curl.
## Prerequisites
[Section titled “Prerequisites”](#prerequisites)
* A [verified domain](/email/domains/)
* An [API key](/get-started/api-keys/) with sending access, saved as `MAILPIDGE_API_KEY`
## 1. Install
[Section titled “1. Install”](#1-install)
* Node.js
```sh
npm install @mailpidge/sdk
```
* Python
```sh
pip install mailpidge
```
* curl
Nothing to install.
## 2. Send an email
[Section titled “2. Send an email”](#2-send-an-email)
* Node.js
send.ts
```ts
import { MailPidgeClient } from '@mailpidge/sdk'
const mailpidge = new MailPidgeClient({ token: process.env.MAILPIDGE_API_KEY! })
const email = await mailpidge.emails.send({
from: 'Pidge Fit ',
to: ['you@example.com'],
subject: 'Hello from MailPidge',
html: 'It works.
',
})
console.log(email.id)
```
Run `npx tsx send.ts`.
* Python
send.py
```python
import os
from mailpidge import MailPidge
mailpidge = MailPidge(token=os.environ["MAILPIDGE_API_KEY"])
email = mailpidge.emails.send(
from_="Pidge Fit ",
to=["you@example.com"],
subject="Hello from MailPidge",
html="It works.
",
)
print(email.id)
```
Run `python send.py`.
* curl
```sh
curl https://api.mailpidge.com/api/v1/emails \
-H "Authorization: Bearer $MAILPIDGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Pidge Fit ",
"to": ["you@example.com"],
"subject": "Hello from MailPidge",
"html": "It works.
"
}'
```
`from` must use your verified domain.
## Response
[Section titled “Response”](#response)
```json
{ "id": "em_01JD4V8QK3S6T2Y9Z7XWB5N0RA", "suppressed": [] }
```
The email arrives within a minute. Follow its status with [webhooks](/webhooks/) or [Get an email](/api/emails/#get-an-email). Errors: [Errors](/get-started/errors/).
# Rate limits and idempotency
> Request limits, and retrying without sending twice.
## Rate limits
[Section titled “Rate limits”](#rate-limits)
| Limit | Value |
| ---------------------- | ------------ |
| Requests per API key | 600 a minute |
| Recipients per email | 50 |
| Emails per batch | 100 |
| Emails per month (Pro) | 10,000 |
Over the request limit: `429 rate_limited` with `Retry-After` in seconds.
## Idempotency
[Section titled “Idempotency”](#idempotency)
Add `Idempotency-Key` to `POST /emails`, `POST /emails/batch` and `POST /messages`:
```http
Idempotency-Key: order-58213-receipt
```
| Within 24 hours | Result |
| ------------------------ | -------------------------------------------- |
| Same key, same body | The first response again; nothing sent twice |
| Same key, different body | `409 idempotency_key_reused` |
# ADM and HMS
> Credentials for Amazon Fire and for Huawei devices without Google services.
| Provider | Where to get it | Enter in Settings → Apps |
| -------- | ------------------------------------------------------------------------------------- | ------------------------ |
| ADM | Amazon Developer Console → your app → **Device Messaging** → security profile | Client ID, Client secret |
| HMS | AppGallery Connect → **Project settings → General information**; turn on **Push Kit** | App ID, App secret |
# APNs key (.p8)
> Let MailPidge send push to your iOS and macOS apps.
One key covers every app on your Apple team, sandbox and production.
1. Apple Developer → **Certificates, Identifiers & Profiles → Keys → +**.
2. Check **Apple Push Notifications service (APNs)**, register, and **download** the `.p8` (only once).
3. Note the **Key ID** and your **Team ID**.
In **Settings → Apps → your app → Apple**:
| Field | Example |
| ----------------- | --------------------- |
| Key ID | `8KX2M4Q9TZ` |
| Team ID | `A1B2C3D4E5` |
| Bundle ID | `com.pidgefit.app` |
| Signing key (.p8) | The downloaded file |
| Environment | Production or Sandbox |
Saved keys are checked, encrypted and never shown again. Status shows **Verified** or **Failing** with a reason.
To replace a key: upload the new one, wait for **Verified**, then revoke the old one at Apple.
| Failure | Fix |
| -------------------------------- | --------------------------------------------- |
| `provider_authentication_failed` | Wrong Key ID or Team ID, or key revoked |
| `provider_credentials_mismatch` | Bundle ID doesn’t match the app |
| `provider_token_mismatch` | Sandbox token with production, or the reverse |
# FCM service account
> Let MailPidge send push to Android through Firebase Cloud Messaging.
1. Firebase console → **Project settings → Service accounts → Generate new private key**.
2. The default `firebase-adminsdk` account works. A custom account needs **Firebase Cloud Messaging API Admin**.
In **Settings → Apps → your app → Android**:
| Field | Example |
| -------------------- | ------------------------------------------ |
| Project ID | `pidge-fit-prod` |
| Service account JSON | The downloaded file (delete it afterwards) |
| Failure | Fix |
| -------------------------------- | ----------------------------------- |
| `provider_authentication_failed` | Key deleted or role removed |
| `provider_credentials_mismatch` | Token from another Firebase project |
# Web Push (VAPID)
> Keys that let MailPidge send push to your website.
MailPidge creates the VAPID keys. In **Settings → Apps → your app → Web**:
| Field | Value |
| ----------- | ------------------------------------------------------------ |
| Site origin | `https://pidgefit.com` (HTTPS required) |
| Public key | Use as `applicationServerKey` in the [web setup](/sdks/web/) |
| Private key | Kept by MailPidge, never shown |
Replacing the keys ends every browser subscription; replace them only after a leak.
| Failure | Fix |
| --------------------------- | ---------------------------------------------- |
| `web_push_title_missing` | Add a title |
| `web_push_navigate_missing` | Add a link, or a default link for the app |
| `token_invalid` | User unsubscribed; the subscription is removed |
# WNS (Windows)
> Let MailPidge send push to Windows apps with a Microsoft Entra app.
1. Azure portal → **Microsoft Entra ID → App registrations → New registration**. Note the **Application (client) ID**.
2. **Certificates & secrets → New client secret**. Copy the value.
3. Ask Microsoft to map your app’s package family name to the Entra app, as Microsoft’s WNS docs describe. Until then: `provider_credentials_mismatch`.
In **Settings → Apps → your app → Windows**:
| Field | Example |
| -------------------- | ------------------------------------------------------------ |
| Package family name | `PidgeFit_8wekyb3d8bbwe` (Partner Center → Product identity) |
| Entra application ID | From step 1 |
| Client secret | From step 2 |
Entra secrets expire; add the new one before the old one does.
# Changelog
> Changes to the API, webhooks and SDKs.
Changes are additive; ignore fields you don’t know. Breaking changes get a new version path and six months’ notice here.
## 2026-11-25
[Section titled “2026-11-25”](#2026-11-25)
* Docs preview published. Nothing here is live yet.
# SDK license
> The Modified MIT license on every MailPidge SDK.
Every published MailPidge SDK uses the license below: MIT terms, plus one condition that the SDK is used with MailPidge’s services. The API, the apps and the dashboard are not open source.
```text
Modified MIT License
Copyright (c) 2026 MailPidge
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
1. The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
2. All copies of substantial portions of the Software may only be used in
connection with services provided by MailPidge.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
# SDK reference
> Generated reference for every SDK.
Generated from code comments at each release; published with each SDK’s first release.
| SDK | Package | Reference |
| ------ | ----------------------------------------------- | ---------------------------- |
| Node | `@mailpidge/sdk` (npm) | `/reference/node/` |
| Python | `mailpidge` (PyPI) | `/reference/python/` |
| Web | `@mailpidge/lifecycle-sdk` (npm) | `/reference/web/` |
| Swift | Swift Package Manager | `/reference/swift/` (DocC) |
| Kotlin | `com.mailpidge:lifecycle-sdk-*` (Maven Central) | `/reference/kotlin/` (Dokka) |
| .NET | `MailPidge.Lifecycle.Windows` (NuGet) | `/reference/dotnet/` |
Source for each SDK is public in its own repository under the [SDK license](/resources/license/).
# Security
> How MailPidge protects keys, user data and messages.
| Data | Protection |
| ---------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| Everything at rest | AES-256 by our infrastructure providers |
| Credentials, device tokens, recipient addresses, webhook secrets | Also AES-GCM encrypted by MailPidge |
| API keys | SHA-256 hash only; shown once |
| Traffic | HTTPS only |
| Email | TLS when offered; [enforced TLS](/email/domains/#tls-mode) per domain, no plain-text fallback |
| App requests | Client keys bound to origins or app ids; App Attest and Play Integrity |
| Webhooks | Signed (Standard Webhooks); ids only, no addresses |
| Deletion | Users and workspaces erased within 30 days |
MailPidge holds no SOC 2, ISO 27001 or HIPAA certification, signs no BAAs and offers no EU-only storage.
Report vulnerabilities to .
# Amazon and Huawei
> Push to Fire devices with ADM and to Huawei devices without Google services with HMS.
Follow the [Android](/sdks/android/) setup, then add the product:
| Devices | Product | Credentials |
| ------------------------------ | --------------------------------- | --------------------------------- |
| Fire tablets, Fire TV | `com.mailpidge:lifecycle-sdk-adm` | [ADM](/push-credentials/adm-hms/) |
| Huawei without Google services | `com.mailpidge:lifecycle-sdk-hms` | [HMS](/push-credentials/adm-hms/) |
The SDK picks the provider the device supports. HarmonyOS NEXT isn’t supported.
# Android
> Add the Kotlin SDK and FCM push to your Android app.
**Prerequisites:** Android 7.0+ (API 24), Firebase in your app, an app in **Settings → Apps** with an Android client key, and an [FCM service account](/push-credentials/fcm/). Read [Concepts](/sdks/concepts/).
1. Add the dependencies.
app/build.gradle.kts
```kotlin
implementation("com.mailpidge:lifecycle-sdk-core:1.0.0")
implementation("com.mailpidge:lifecycle-sdk-notifications:1.0.0")
```
2. Link a Google Cloud project to your app in Play Console and note its project number (without it: `403 attestation_required`).
3. Configure in your `Application`.
```kotlin
MailPidgeLifecycle.configure(
context = this,
clientCredential = "mpck_…",
appId = "pidgefit-android",
workerBaseUrl = "https://api.mailpidge.com",
playIntegrityCloudProjectNumber = 123456789012L,
)
```
4. Register the FCM token. On Android 13+, request `POST_NOTIFICATIONS` first.
```kotlin
override fun onNewToken(token: String) {
CoroutineScope(Dispatchers.IO).launch { MailPidgeLifecycle.registerPushToken(token) }
}
```
5. Identify after sign-in; reset on sign-out.
```kotlin
MailPidgeLifecycle.identify(externalUserId = user.id, identityToken = identityToken)
MailPidgeLifecycle.reset()
```
6. Track events and record [consent](/sdks/concepts/#consent).
```kotlin
MailPidgeLifecycle.track("workout_completed", mapOf("minutes" to 42))
```
## Test
[Section titled “Test”](#test)
**Settings → Apps → your app → Send test push.** The device shows as **Active**.
# Concepts
> Apps, users, subscriptions, consent and identity verification, used by every SDK.
## Apps
[Section titled “Apps”](#apps)
Each site or app is an **app** in **Settings → Apps**, with an app id (such as `pidgefit-ios`), push credentials, identity keys and client keys.
## Client keys
[Section titled “Client keys”](#client-keys)
The SDK uses a client key (`mpck_…`), safe to ship: it can record events, register devices and record consent, nothing else.
| Platform | Bound to | Checked with |
| ---------- | ------------- | -------------- |
| Web | Site origins | Origin |
| iOS, macOS | Bundle ids | App Attest |
| Android | Package names | Play Integrity |
SDKs send their version. Below an app’s minimum version: `426 sdk_upgrade_required`.
## Users and subscriptions
[Section titled “Users and subscriptions”](#users-and-subscriptions)
| Term | Meaning | Limit |
| ------------ | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------- |
| User | A person, identified by your user id (`externalUserId`) | |
| Alias | Another id for the user, such as a CRM id | 10 per user |
| Subscription | One way to reach the user: a device’s push token, an email address or a phone number | 20 per user; the oldest is dropped, but the newest 3 email and 3 SMS are kept |
| Tag | Key-value pair for segments, such as `plan: "pro"` | |
Before sign-in the SDK uses an anonymous id. `identify` links it and the device to the user; `reset` on sign-out unlinks the device.
## Consent
[Section titled “Consent”](#consent)
The OS notification permission is not consent to marketing. Record the user’s answer with `setChannelConsent`:
| Field | Values |
| ---------------------- | ----------------------------------------------------- |
| `channel` | `email`, `push`, `sms`, `in_app` |
| `topicKey` | Optional, such as `promotions` |
| `status` | `opted_in` or `opted_out` |
| `consentLanguageShown` | The text the user agreed to (required for `opted_in`) |
Marketing goes only to opted-in users; transactional messages don’t need it. To hold all network calls until users accept your terms, call `setConsentRequired(true)` before `configure` and `setConsentGiven(true)` after.
## Identity verification
[Section titled “Identity verification”](#identity-verification)
Stops someone with your client key from claiming another user’s id. Your server signs a token; the app passes it to `identify`.
1. Add an ES256 public key in **Settings → Apps → your app → Identity keys**.
2. Sign a JWT on your server:
| Claim | Value |
| ---------------------- | -------------------------------------------------- |
| `alg` / `kid` (header) | `ES256` / your key id |
| `iss` | The app id |
| `identity.external_id` | The user’s id |
| `iat`, `exp` | `exp` at most 30 days after `iat`; 60 s clock skew |
server.ts
```ts
import { SignJWT, importPKCS8 } from 'jose'
const privateKey = await importPKCS8(process.env.MAILPIDGE_IDENTITY_PRIVATE_KEY!, 'ES256')
export const createMailPidgeIdentityToken = (userId: string) =>
new SignJWT({ identity: { external_id: userId } })
.setProtectedHeader({ alg: 'ES256', kid: 'es256-2027-01' })
.setIssuer('pidgefit-ios')
.setIssuedAt()
.setExpirationTime('1h')
.sign(privateKey)
```
| Error | Cause |
| -------------------------------- | ------------------------------------------ |
| `identity_verification_required` | The app requires a token and none was sent |
| `identity_verification_failed` | The token is invalid or expired |
**Refresh:** register the SDK’s token refresh listener. On expiry it asks your app for a new token and resumes queued requests; if that token fails too, the queue fails instead of retrying forever.
## Erasure
[Section titled “Erasure”](#erasure)
Deleting a user removes their subscriptions, events, feed and consent records. Also call `reset` on their devices.
# iOS
> Add the Swift SDK and push notifications to your iPhone and iPad app.
**Prerequisites:** iOS 15+, an app in **Settings → Apps** with an iOS client key, and an [APNs key](/push-credentials/apns/). Read [Concepts](/sdks/concepts/).
1. Add the package `https://github.com/mailpidge/mailpidge-swift` (product `MailPidgeLifecycleSDK`).
2. In **Signing & Capabilities**, add Push Notifications, App Attest, and Background Modes → Remote notifications.
3. Configure at launch.
```swift
import MailPidgeLifecycleSDK
do {
try MailPidgeLifecycle.configure(clientCredential: "mpck_…", appId: "pidgefit-ios")
} catch {
assertionFailure("MailPidge configuration is invalid: \(error)")
}
```
Debug builds: add `pushEnvironment: .sandbox`.
4. Request permission and register the token.
```swift
if try await UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) {
UIApplication.shared.registerForRemoteNotifications()
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Task { try await MailPidgeLifecycle.registerPushToken(deviceToken) }
}
```
5. Identify after sign-in; reset on sign-out.
```swift
try await MailPidgeLifecycle.identify(externalUserId: user.id, identityToken: identityToken)
await MailPidgeLifecycle.reset()
```
6. Track events and record [consent](/sdks/concepts/#consent).
```swift
try await MailPidgeLifecycle.track("workout_completed", properties: ["minutes": 42])
```
## Images and receipts
[Section titled “Images and receipts”](#images-and-receipts)
Add a Notification Service Extension with the `MailPidgeNotificationServiceExtension` product and an App Group shared with the app. It attaches images and reports `push.confirmed`.
## Test
[Section titled “Test”](#test)
On a real device: **Settings → Apps → your app → Send test push.** The device shows as **Active**.
# macOS
> The Swift SDK in a Mac app.
Same package and calls as [iOS](/sdks/ios/); macOS 12+. Register from your `NSApplicationDelegate`:
```swift
func applicationDidFinishLaunching(_ notification: Notification) {
do {
try MailPidgeLifecycle.configure(clientCredential: "mpck_…", appId: "pidgefit-mac")
} catch {
assertionFailure("MailPidge configuration is invalid: \(error)")
}
NSApplication.shared.registerForRemoteNotifications()
}
func application(_ application: NSApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Task { try await MailPidgeLifecycle.registerPushToken(deviceToken) }
}
```
| | macOS |
| --------------- | ------------------------------------ |
| Bundle id | The Mac app’s own, on the client key |
| Distribution | Mac App Store or Developer ID |
| Live Activities | Not available |
# Web
> Add the web SDK and web push to your site.
**Prerequisites:** an app in **Settings → Apps** with a web client key for your origin, and [Web Push keys](/push-credentials/web-push/). Read [Concepts](/sdks/concepts/).
1. Install.
```sh
npm install @mailpidge/lifecycle-sdk
```
2. Create the client.
```ts
import { createMailPidgeLifecycleClient } from '@mailpidge/lifecycle-sdk'
export const mailpidge = createMailPidgeLifecycleClient({ clientCredential: 'mpck_…', appId: 'pidgefit-web' })
```
3. Identify after sign-in; reset on sign-out.
```ts
await mailpidge.identify(user.id, { plan: user.plan }, { identityToken })
await mailpidge.reset()
```
4. Track events.
```ts
await mailpidge.track('workout_completed', { minutes: 42 })
```
5. Serve `node_modules/@mailpidge/lifecycle-sdk/service-worker/mailpidge-sw.js` at `/mailpidge-sw.js`.
6. Subscribe to push from a user action.
```ts
const registration = await navigator.serviceWorker.register('/mailpidge-sw.js')
const pushSubscription = await registration.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: 'BOr0…vX9c', // Settings → Apps → Web → Public key
})
await mailpidge.registerWebPushSubscription(pushSubscription.toJSON())
```
7. Record [consent](/sdks/concepts/#consent).
```ts
await mailpidge.setChannelConsent({ channel: 'push', status: 'opted_in', consentLanguageShown: 'Send me workout tips' })
```
## Test
[Section titled “Test”](#test)
**Settings → Apps → your app → Send test push.** The notification appears and the browser shows as **Active**.
iPhone and iPad receive web push only after the site is added to the Home Screen.
# Windows
> Push to Windows apps through WNS.
**Prerequisites:** [WNS credentials](/push-credentials/wns/). Read [Concepts](/sdks/concepts/).
| App | SDK |
| ------------------------ | ------------------------------------------------------------------- |
| WinUI / Windows App SDK | `MailPidge.Lifecycle.Windows` (NuGet) |
| Kotlin / Compose Desktop | [Kotlin SDK](/sdks/android/); your app supplies the WNS channel URI |
| .NET MAUI | [MAUI wrapper](/sdks/wrappers/) |
```powershell
dotnet add package MailPidge.Lifecycle.Windows
```
```csharp
await MailPidgeLifecycle.ConfigureAsync(clientCredential: "mpck_…", appId: "pidgefit-windows");
var channel = await PushNotificationManager.Default.CreateChannelAsync(wnsRemoteId);
await MailPidgeLifecycle.RegisterPushChannelAsync(channel.Channel.Uri);
```
| Packaging | Push |
| --------------- | ----------------------- |
| Packaged (MSIX) | Background push |
| Unpackaged | Only while the app runs |
# Cross-platform frameworks
> React Native, Expo, Flutter, Capacitor, Unity and .NET MAUI.
Wrappers call the native SDKs, so set up [iOS](/sdks/ios/) and [Android](/sdks/android/) capabilities and credentials first. Calls match the platform pages.
| Framework | Install |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| React Native | `npm install @mailpidge/react-native` then `pod install` in `ios/` |
| Expo | `npx expo install @mailpidge/react-native @mailpidge/expo-plugin`; add `@mailpidge/expo-plugin` to `plugins` in `app.json`. Development builds only (no Expo Go). |
| Flutter | `flutter pub add mailpidge` |
| Capacitor | `npm install @mailpidge/capacitor` then `npx cap sync`; uses the [web SDK](/sdks/web/) on the web |
| Unity | Package Manager → git URL `https://github.com/mailpidge/mailpidge-unity.git` |
| .NET MAUI | `dotnet add package MailPidge.Lifecycle.Maui` |
Cordova isn’t supported.
# Push delivery outcomes
> Every result a push can have, and what to do.
| Outcome | Meaning | MailPidge does | You do |
| ------------------- | -------------------------------- | --------------------------------- | --------- |
| `delivered` | Push service accepted it | Sends `push.delivered` | Nothing |
| `retryable` | Push service busy or down | Retries with backoff | Nothing |
| `token_invalid` | App deleted or user unsubscribed | Marks the subscription invalid | Nothing |
| `permanent_failure` | Can’t be delivered as sent | Sends `push.failed` with a reason | See below |
| Reason | Fix |
| -------------------------------- | ---------------------------------------------------------- |
| `provider_not_configured` | Add credentials for the platform |
| `provider_authentication_failed` | Replace the refused credentials |
| `provider_credentials_mismatch` | Credentials and token belong to different apps or projects |
| `provider_token_mismatch` | Sandbox/production mix-up |
| `payload_too_large` | Shorten it; APNs and FCM allow 4 KB |
| `invalid_request` | Content broke a rule (image, link, reserved key, buttons) |
| `destination_not_allowed` | The push service refused the destination |
| `provider_rejected_request` | See the reason in the delivery log |
| `web_push_title_missing` | Add a title |
| `web_push_navigate_missing` | Add a link or an app default link |
## Skipped before sending
[Section titled “Skipped before sending”](#skipped-before-sending)
| Reason | Meaning |
| --------------- | ----------------------------------------- |
| No consent | Not opted in to marketing on this channel |
| Quiet hours | Held until they end |
| Frequency cap | Over your limit |
| No subscription | No active device |
# Webhooks
> A signed POST to your endpoint when an event happens.
Add an endpoint in **Settings → Developers → Webhooks**, or with [Create a webhook](/api/webhooks/#create-a-webhook). HTTPS only; redirects aren’t followed; 10 per workspace.
## Payload
[Section titled “Payload”](#payload)
```json
{
"eventId": "evt_6f1c2b0e9a7d4c3b",
"eventType": "email.bounced",
"tenantId": "tnt_3k9w2",
"occurredAt": "2026-11-25T09:14:03.511Z",
"receivedAt": "2026-11-25T09:14:04.020Z",
"source": "ses-events",
"schemaVersion": 1,
"campaignId": "cmp_8h2q",
"trackingRowId": "row_41",
"bounceCategory": "permanent"
}
```
Ids only, never email addresses. API emails also carry `emailId`.
## Events
[Section titled “Events”](#events)
| Event | When |
| ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `email.sent` | Accepted for sending |
| `email.delivered` | Accepted by the receiving server |
| `email.delivery_delayed` | Being retried |
| `email.bounced` | Rejected permanently |
| `email.complained` | Marked as spam |
| `email.failed` | Couldn’t be sent |
| `email.suppressed` | Skipped: suppressed address |
| `email.opened` | Opened; `isAppleMailPrivacyProtectionOpen: true` means Apple Mail loaded it, not a person |
| `email.clicked` | Link clicked |
| `email.unsubscribed` | Unsubscribed |
| `push.sent` · `push.delivered` · `push.confirmed` · `push.failed` | `delivered`: push service accepted; `confirmed`: device showed it |
| `push.opened` · `push.clicked` · `push.dismissed` · `push.unsubscribed` | Push engagement |
| `sms.sent` · `sms.delivered` · `sms.failed` · `sms.unsubscribed` | SMS |
| `in_app.delivered` · `in_app.opened` · `in_app.clicked` · `in_app.dismissed` | In-app messages |
| `campaign.sent` · `campaign.completed` | Campaigns |
| `plan.activated` · `plan.completed` · `plan.stopped` · `wave.proposed` · `wave.launched` | Plans |
| `contact.created` · `contact.updated` | Contacts |
Next: [Verify webhooks](/webhooks/verify/) · [Retries, ordering and duplicates](/webhooks/delivery/)
# Retries, ordering and duplicates
> What happens when your endpoint is slow, down or returns an error.
Answer `2xx` within **10 seconds**. Timeouts, network errors, `3xx`, `4xx` and `5xx` are failures.
## Retries
[Section titled “Retries”](#retries)
| Attempt | Delay after the previous one |
| ------- | ---------------------------- |
| 2 | 2 min |
| 3 | 4 min |
| 4 | 8 min |
| 5 | 16 min |
| 6 | 32 min |
| 7 | \~1 h |
| 8 | \~2 h |
| 9 | \~4 h |
| 10 | \~8.5 h |
After 10 attempts (\~17 hours) the delivery stops and stays in the delivery log, where you can retry it.
## Rules for your endpoint
[Section titled “Rules for your endpoint”](#rules-for-your-endpoint)
| Case | Do |
| ------------------- | ------------------------------------------------------------------- |
| Duplicates | Store `webhook-id`; skip ids you’ve seen |
| Out-of-order events | Order by `occurredAt`, not arrival |
| Replays | Refuse timestamps more than 300 s off; retries get fresh timestamps |
| Slow work | Answer first, then process |
Events that happen while an endpoint is paused are not sent later.
# Verify webhooks
> Check the Standard Webhooks signature on every request.
MailPidge follows [Standard Webhooks](https://www.standardwebhooks.com), so any Standard Webhooks library works.
| Header | Value |
| ------------------- | --------------------------------------------------------- |
| `webhook-id` | Delivery id (`dwd_…`), same on every retry |
| `webhook-timestamp` | Unix seconds of this attempt |
| `webhook-signature` | `v1,`; two space-separated values during rotation |
Verify against the raw body, not a re-serialized one.
* Node.js
```ts
import { verifyWebhookRequest } from '@mailpidge/sdk'
const body = await request.text()
const isValid = await verifyWebhookRequest({
headers: request.headers,
body,
secret: process.env.MAILPIDGE_WEBHOOK_SECRET!,
})
if (!isValid) return new Response('invalid signature', { status: 401 })
```
* Python
```python
from mailpidge import verify_webhook_request
body = request.get_data(as_text=True)
if not verify_webhook_request(headers=request.headers, body=body, secret=WEBHOOK_SECRET):
return "invalid signature", 401
```
* Any language
1. Refuse if `webhook-timestamp` is more than 300 s from your clock.
2. Base64-decode the part of the secret after `whsec_`.
3. HMAC-SHA256 `{webhook-id}.{webhook-timestamp}.{body}` with it; base64-encode.
4. Compare with each `v1,` value in constant time. One match passes.
## Rotate the secret
[Section titled “Rotate the secret”](#rotate-the-secret)
After **Rotate secret**, requests carry both signatures for 72 hours.