Skip to main content

REST API v1

Everything the app can do, as an endpoint.

Manage contacts, build and send campaigns, read reporting, subscribe to webhooks, and call the AI copy tools, from your own systems.

Base URL

https://tweak.email/api/v1

Authentication

Authorization: Bearer <your-api-key>

Or the X-Api-Key header. API access is on every paid plan. Team owners and admins generate the key in the app under Settings → API.

Your first call

Confirm the credential works and see what it can reach:

curl https://tweak.email/api/v1/me \
  -H "Authorization: Bearer $TWEAK_API_KEY"

Add a contact. The write is an upsert on email address, so re-running it is safe:

curl -X POST https://tweak.email/api/v1/contacts \
  -H "Authorization: Bearer $TWEAK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email":"jane@example.com","first_name":"Jane","tag_ids":[3],"consent_attested":true}'

A contact who has already unsubscribed keeps that status no matter what you send, so a full-address-book re-sync can never quietly resubscribe someone. metadata is merged into what is stored: keys you send overwrite, a key sent as null is removed, the rest stay.

consent_attested is required whenever a request creates a contact (in a bulk upsert, for the batch or on each row that creates one): it confirms the person gave permission to receive email from you and was not taken from a purchased, rented or scraped list. Requests that would create a contact without it are refused with 422. Updating a contact you already have does not need it.

Webhooks & keys

Subscribe a URL to platform events instead of polling. Manage credentials programmatically for automated rotation. A connected Shopify store posts its own updates to /webhooks/shopify/{id}; connecting the store under Settings → Integrations registers them there, so there is nothing for you to call.

Idempotency

Send an Idempotency-Key header on any write. A retry with the same key replays the original response instead of executing again.

-H "Idempotency-Key: order-4417-receipt"

Use it on campaign sends especially: a duplicated send is the one mistake here you can't undo. Keys are honoured for 24 hours. A replayed response carries Idempotency-Replayed: true; the same key with a different body is a 422, and a retry while the first is still running is a 409. Keys are shared by your team and bound to the API key that first used them, so another of your keys reusing one gets the 422 too: give each integration its own keys.

Scoped keys

Issue one key per integration with only the scopes it needs, then revoke that one without disturbing the others.

contacts:read contacts:write campaigns:read campaigns:write campaigns:send events:read events:write suppressions:read suppressions:write transactional:send ai:write webhooks:read webhooks:write keys:manage

A :write grant implies the matching :read. Sending is its own scope, so a key that drafts campaigns can't put mail in front of customers. Creating and revoking keys needs keys:manage, and regenerating the main key in Settings revokes every key created through the API.

Webhook signatures

Every delivery carries a Tweak-Signature header. Verify it against the raw request body before trusting the payload.

Tweak-Signature: t=1754835600,v1=9f86d0818...

hmac_sha256(secret, "{t}.{raw_body}") == v1

The timestamp is inside the signed material, so a captured payload can't be replayed at you indefinitely. Reject anything older than a few minutes.

Unified event pipeline

Every delivery event, whether from provider webhooks, native sends, or delivery events you report with POST /events for mail sent elsewhere, flows through one pipeline, and back out again over GET /events and your webhooks.

  • Campaign stats updated automatically
  • Auto-suppress on bounce, spam, unsubscribe
  • Contact statuses synced in real time
  • Switch providers, keep your history

POST /events takes delivery event types only, not product events of your own. To react to something in your product, add a tag to the contact with POST /contacts/{contact}/tags and let a sequence with the tag-added trigger take it from there.

Reverse ETL

Connect BigQuery, pick an audience without a CSV, and use approved warehouse fields as merge tags at send time.

  • OAuth with read-only BigQuery scope
  • Browse datasets, tables, and columns
  • Map columns to email placeholders
  • Approved fields resolved during sending

Rate limits

Counted per API key, so one integration's burst never eats another's headroom. Every response carries X-RateLimit-Limit and X-RateLimit-Remaining; a 429 adds Retry-After. An address that keeps sending a missing or wrong key is blocked for the rest of the minute.

Requests (Starter)120/min
Requests (Pro)300/min
Requests (Business)600/min
Events per request1,000
Contacts per bulk call1,000
Records per page100

Error responses

Standard HTTP status codes with JSON error bodies.

400Body sent as JSON is not valid JSON (invalid_json)
401Missing, invalid, revoked, or expired key
403Missing scope, or plan excludes API access
404No such record on your team
409Same Idempotency-Key still in progress
422Validation error, an unsupported body field, or a send gate failed
429Rate limited, see Retry-After
502A transactional send could not be handed over; nothing sent
503Sending or AI temporarily unavailable; retry later

A refused send returns a blockers array naming each unmet requirement. POST /campaigns/{id}/preflight returns the same list without attempting to send.

Every paid plan

Build on it today

Generate your key under Settings → API, mint a scoped key for each integration, point your client at the OpenAPI spec, and ship.

Start free