REST API v1
API Reference
All 93 endpoints. Click any one to see the fields you send and the shape you get back. Prefer to generate a client? Take the OpenAPI spec.
https://tweak.email/api/v1
Auth Authorization: Bearer <key>
Keys: every paid plan, in the app under Settings → API
Guides and concepts
No endpoint matches that filter.
Identity
Who the presented key belongs to
GET
/me
Describe the presented credential
Returns the owning team, whether its plan includes API access, the key's scopes and expiry, and the applicable rate limit. Answers even when the plan has no API access (every other endpoint is then a 403 `plan_required`), so an integration can tell why.
Response
-
dataobject -
data.teamobject -
data.api_keyobject or null -
data.rate_limitobject
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/me \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"team": {
"id": 9,
"name": "Acme",
"plan": "business",
"api_access": true,
"required_plan": null,
"on_trial": false,
"trial_ends_at": null
},
"api_key": {
"id": 4,
"name": "CRM sync",
"scopes": [
"contacts:read",
"contacts:write"
],
"legacy": false,
"expires_at": null
},
"rate_limit": {
"requests_per_minute": 600
}
}
}
Contacts
Contacts, lists, tags, and segments
GET
/contacts
List contacts
Requires scope contacts:read
Cursor-paginated. Filterable by status, tag, list, segment, and modification time.
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
-
statusstring - Filter by contact status.
-
activependingunsubscribedbounced -
tag_idinteger - Only contacts carrying this tag.
-
list_idinteger - Only contacts on this list.
-
segment_idinteger - Only contacts matching this saved segment.
-
updated_sincestring - ISO 8601 timestamp. Only contacts modified since. Use this to run an incremental sync.
-
includestring - Comma-separated relations to embed: tags, lists.
Response
-
dataarray of object -
data.idinteger -
data.emailstring -
data.first_namestring or null -
data.last_namestring or null -
data.statusstring -
activependingunsubscribedbounced -
data.metadataobject -
data.subscribed_atstring or null -
data.unsubscribed_atstring or null -
data.confirmed_atstring or null -
data.consent_sourcestring or null - How consent was obtained: `api`, `import`, `manual`, `signup_form`, `embedded_form`, or the value your integration supplied. Older records confirmed by e-mail may say `double_opt_in`; confirmation is now recorded in `confirmed_at` instead.
-
data.consent_attested_atstring or null - When the sender attested that this contact gave permission to be emailed.
-
data.soft_bounce_countinteger -
data.created_atstring or null -
data.updated_atstring or null -
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/contacts \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 42,
"email": "jane@example.com",
"first_name": "Jane",
"last_name": "Okonkwo",
"status": "active",
"metadata": {
"company": "Acme",
"city": "Copenhagen"
},
"subscribed_at": "2026-08-01T09:15:00+00:00",
"unsubscribed_at": null,
"confirmed_at": null,
"consent_source": "signup_form",
"consent_attested_at": "2026-08-01T09:15:00+00:00",
"soft_bounce_count": 0,
"created_at": "2026-08-01T09:15:00+00:00",
"updated_at": "2026-08-09T14:02:00+00:00"
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/contacts
Create or update a contact
Requires scope contacts:write
Upserts on email address. An existing contact that has unsubscribed or bounced keeps that status regardless of what is sent. Use `status_if_new` to control only what a brand-new contact is created as. When the request creates a contact (or restores a deleted one), `consent_attested` must be `true` (your confirmation that the person gave permission to receive email from you and was not taken from a purchased, rented or scraped list), otherwise the request is refused with 422. An update of an existing contact does not need it, so a sync that only changes metadata can leave it out.
Tags can be given by id (`tag_ids`) or by name (`tags`); a name your team has no tag for creates that tag.
`metadata` is merged into what is stored: keys you send overwrite, a key sent as `null` is removed (so is one sent as an empty string), and keys you leave out are kept. Send `"metadata": null` to clear it all.
Re-adding the address of a deleted contact restores that contact with the data you send (201). A deleted contact who had unsubscribed or bounced comes back with that status.
Creating a contact as `active` starts your active sequences with the signup trigger, including those limited to a list the contact is added to, as adding the contact in the app does. A contact created as `pending`, and a restored contact, does not start them.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
emailstring Required -
first_namestring -
last_namestring -
metadataobject or null - Arbitrary key/value data, addressable as merge tags. Merged into what is stored: keys you send overwrite, a key sent as `null` is removed (so is one sent as an empty string), keys you leave out are kept. `null` clears it all. A key that is one of your contact fields is stored in that field's type (`"1200"` becomes 1200 for a number field; a date field takes `YYYY-MM-DD` or a full ISO 8601 date-time, stored as its date); a value that cannot be converted is a 422 naming the key (`metadata.seats`) and the type expected. Other keys are stored as sent.
-
status_if_newstring - Status for a contact that does not already exist. Has no effect on an existing contact.
-
activepending -
tag_idsarray of integer - Tags to add, by id. Ids that are not your team's are skipped.
-
tagsarray of string - Tags to add, by name (matched without regard to case). A name your team has no tag for creates that tag.
-
list_idsarray of integer -
consent_sourcestring - Where consent was captured. Recorded for compliance evidence.
-
consent_ipstring -
consent_attestedboolean - Required, and must be `true`, when the request creates a contact (or restores a deleted one): confirms this person gave permission to receive email from you and was not taken from a purchased, rented or scraped list. Recorded as `consent_attested_at` on the new contact. Not needed to update an existing contact.
Response
- 201
- Created: no contact had this address, or a deleted one was restored.
- 200
- An existing contact was updated.
-
dataobject -
data.idinteger -
data.emailstring -
data.first_namestring or null -
data.last_namestring or null -
data.statusstring -
activependingunsubscribedbounced -
data.metadataobject -
data.subscribed_atstring or null -
data.unsubscribed_atstring or null -
data.confirmed_atstring or null -
data.consent_sourcestring or null - How consent was obtained: `api`, `import`, `manual`, `signup_form`, `embedded_form`, or the value your integration supplied. Older records confirmed by e-mail may say `double_opt_in`; confirmation is now recorded in `confirmed_at` instead.
-
data.consent_attested_atstring or null - When the sender attested that this contact gave permission to be emailed.
-
data.soft_bounce_countinteger -
data.created_atstring or null -
data.updated_atstring or null
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
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","last_name":"Okonkwo","metadata":{"company":"Acme","plan":"pro"},"status_if_new":"active","tag_ids":[3,8],"tags":["customer","newsletter"],"list_ids":[1],"consent_source":"signup_form","consent_ip":"203.0.113.24","consent_attested":true}'
Request body
{
"email": "jane@example.com",
"first_name": "Jane",
"last_name": "Okonkwo",
"metadata": {
"company": "Acme",
"plan": "pro"
},
"status_if_new": "active",
"tag_ids": [
3,
8
],
"tags": [
"customer",
"newsletter"
],
"list_ids": [
1
],
"consent_source": "signup_form",
"consent_ip": "203.0.113.24",
"consent_attested": true
}
Response 201
{
"data": {
"id": 42,
"email": "jane@example.com",
"first_name": "Jane",
"last_name": "Okonkwo",
"status": "active",
"metadata": {
"company": "Acme",
"city": "Copenhagen"
},
"subscribed_at": "2026-08-01T09:15:00+00:00",
"unsubscribed_at": null,
"confirmed_at": null,
"consent_source": "signup_form",
"consent_attested_at": "2026-08-01T09:15:00+00:00",
"soft_bounce_count": 0,
"created_at": "2026-08-01T09:15:00+00:00",
"updated_at": "2026-08-09T14:02:00+00:00"
}
}
POST
/contacts/bulk
Bulk upsert contacts
Requires scope contacts:write
Up to 1,000 per call. Returns a per-row result so a partial success is legible. Every row that creates a contact (or restores a deleted one) needs an attestation: `consent_attested: true` for the whole batch, or on that row. Without it the whole batch is refused with 422, naming each such row (`contacts.3.consent_attested`). Rows that only update existing contacts need none. Metadata is merged per contact exactly as on the single upsert, and deleted addresses are restored. `tags` (names) and `tag_ids` apply to every contact in the batch. A row that creates an `active` contact starts your active signup-triggered sequences, including those limited to a list the contact is added to; a restored or `pending` contact does not start them.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
contactsarray of object Required -
contacts.emailstring Required -
contacts.first_namestring -
contacts.last_namestring -
contacts.metadataobject or null - Arbitrary key/value data, addressable as merge tags. Merged into an existing contact's metadata, as on the single upsert, with values for your contact fields converted to the field's type (or refused, naming `contacts.N.metadata.key`).
-
contacts.status_if_newstring - Status for a contact that does not already exist. Has no effect on an existing contact.
-
activepending -
contacts.consent_attestedboolean - This row's attestation, for a batch that does not attest as a whole. Needed (as `true`) only when the row creates a contact.
-
tag_idsarray of integer - Applied to every contact in the batch.
-
tagsarray of string - Tag names applied to every contact in the batch; missing tags are created.
-
list_idsarray of integer - Applied to every contact in the batch.
-
consent_attestedboolean - `true` confirms every contact in the batch gave permission to receive email from you and the list is not purchased, rented or scraped. Needed when the batch creates contacts, unless each such row attests itself. Recorded as `consent_attested_at` on each new contact.
-
consent_sourcestring - Where consent was captured, applied to new contacts in the batch. Defaults to `api`.
Response
-
dataarray of object -
data.emailstring -
data.idinteger -
data.createdboolean - True for a new (or restored) contact.
-
data.statusstring -
createdinteger -
updatedinteger
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/contacts/bulk \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contacts":[{"email":"jane@example.com","first_name":"Jane","last_name":"Okonkwo","metadata":{"company":"Acme"},"status_if_new":"active","consent_attested":true}],"tag_ids":[3],"tags":["imported"],"list_ids":[1],"consent_attested":true,"consent_source":"signup_form"}'
Request body
{
"contacts": [
{
"email": "jane@example.com",
"first_name": "Jane",
"last_name": "Okonkwo",
"metadata": {
"company": "Acme"
},
"status_if_new": "active",
"consent_attested": true
}
],
"tag_ids": [
3
],
"tags": [
"imported"
],
"list_ids": [
1
],
"consent_attested": true,
"consent_source": "signup_form"
}
Response 200
{
"data": [
{
"email": "jane@example.com",
"id": 42,
"created": true,
"status": "active"
}
],
"created": 1,
"updated": 0
}
GET
/contacts/{contact}
Fetch a contact
Requires scope contacts:read
Accepts either a numeric id or an email address.
Path parameters
-
contactstring Required - Contact id, or the contact's email address.
Response
-
dataobject -
data.idinteger -
data.emailstring -
data.first_namestring or null -
data.last_namestring or null -
data.statusstring -
activependingunsubscribedbounced -
data.metadataobject -
data.subscribed_atstring or null -
data.unsubscribed_atstring or null -
data.confirmed_atstring or null -
data.consent_sourcestring or null - How consent was obtained: `api`, `import`, `manual`, `signup_form`, `embedded_form`, or the value your integration supplied. Older records confirmed by e-mail may say `double_opt_in`; confirmation is now recorded in `confirmed_at` instead.
-
data.consent_attested_atstring or null - When the sender attested that this contact gave permission to be emailed.
-
data.soft_bounce_countinteger -
data.created_atstring or null -
data.updated_atstring or null
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/contacts/:contact \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 42,
"email": "jane@example.com",
"first_name": "Jane",
"last_name": "Okonkwo",
"status": "active",
"metadata": {
"company": "Acme",
"city": "Copenhagen"
},
"subscribed_at": "2026-08-01T09:15:00+00:00",
"unsubscribed_at": null,
"confirmed_at": null,
"consent_source": "signup_form",
"consent_attested_at": "2026-08-01T09:15:00+00:00",
"soft_bounce_count": 0,
"created_at": "2026-08-01T09:15:00+00:00",
"updated_at": "2026-08-09T14:02:00+00:00"
}
}
PATCH
/contacts/{contact}
Update a contact
Requires scope contacts:write
Setting `status` to `unsubscribed` also creates a suppression; setting it back to `active` lifts only the unsubscribe suppression, never a bounce or complaint. `metadata` is merged as on the upsert.
Path parameters
-
contactstring Required - Contact id, or the contact's email address.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
first_namestring or null -
last_namestring or null -
metadataobject or null - Merged into the stored metadata: keys you send overwrite, a key sent as `null` is removed (so is one sent as an empty string), keys you leave out are kept. `null` clears it all. Values for your contact fields are converted to the field's type, or refused with 422 naming the key.
-
statusstring -
activependingunsubscribed -
tag_idsarray of integer - Replaces the contact's tags. Sent with `tags`, the contact gets the tags of both.
-
tagsarray of string - Replaces the contact's tags, by name; a name your team has no tag for creates that tag.
-
list_idsarray of integer - Replaces the contact's list memberships.
Response
-
dataobject -
data.idinteger -
data.emailstring -
data.first_namestring or null -
data.last_namestring or null -
data.statusstring -
activependingunsubscribedbounced -
data.metadataobject -
data.subscribed_atstring or null -
data.unsubscribed_atstring or null -
data.confirmed_atstring or null -
data.consent_sourcestring or null - How consent was obtained: `api`, `import`, `manual`, `signup_form`, `embedded_form`, or the value your integration supplied. Older records confirmed by e-mail may say `double_opt_in`; confirmation is now recorded in `confirmed_at` instead.
-
data.consent_attested_atstring or null - When the sender attested that this contact gave permission to be emailed.
-
data.soft_bounce_countinteger -
data.created_atstring or null -
data.updated_atstring or null
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X PATCH https://tweak.email/api/v1/contacts/:contact \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"first_name":"Jane","last_name":"Okonkwo","metadata":{"plan":"pro","city":null},"status":"active","tag_ids":[3,8],"tags":["customer"],"list_ids":[1]}'
Request body
{
"first_name": "Jane",
"last_name": "Okonkwo",
"metadata": {
"plan": "pro",
"city": null
},
"status": "active",
"tag_ids": [
3,
8
],
"tags": [
"customer"
],
"list_ids": [
1
]
}
Response 200
{
"data": {
"id": 42,
"email": "jane@example.com",
"first_name": "Jane",
"last_name": "Okonkwo",
"status": "active",
"metadata": {
"company": "Acme",
"city": "Copenhagen"
},
"subscribed_at": "2026-08-01T09:15:00+00:00",
"unsubscribed_at": null,
"confirmed_at": null,
"consent_source": "signup_form",
"consent_attested_at": "2026-08-01T09:15:00+00:00",
"soft_bounce_count": 0,
"created_at": "2026-08-01T09:15:00+00:00",
"updated_at": "2026-08-09T14:02:00+00:00"
}
}
DELETE
/contacts/{contact}
Delete a contact
Requires scope contacts:write
Soft delete: the contact disappears from every endpoint (a second delete is a 404) and can be re-added with the upsert. Sends the `contact.deleted` webhook. For GDPR erasure use the erase endpoint instead.
Path parameters
-
contactstring Required - Contact id, or the contact's email address.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.idinteger -
data.deletedboolean
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X DELETE https://tweak.email/api/v1/contacts/:contact \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 42,
"deleted": true
}
}
POST
/contacts/{contact}/erase
Erase a contact (GDPR Art. 17)
Requires scope contacts:write
Permanently removes the contact and anonymises their delivery events. The suppression record is deliberately retained so an erased opt-out is never lost. Sends `contact.deleted` with `erased: true` and no email address.
Path parameters
-
contactstring Required - Contact id or email address.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.contacts_deletedinteger -
data.events_anonymizedinteger
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/contacts/:contact/erase \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"contacts_deleted": 1,
"events_anonymized": 1
}
}
GET
/lists
List contact lists
Requires scope contacts:read
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
Response
-
dataarray of object -
data.idinteger -
data.namestring -
data.descriptionstring or null -
data.is_defaultboolean -
data.opt_in_modestring -
singledouble -
data.contacts_countinteger -
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/lists \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 7,
"name": "Newsletter",
"description": "Monthly product news",
"is_default": false,
"opt_in_mode": "single",
"contacts_count": 1280
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/lists
Create a contact list
Requires scope contacts:write
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
namestring Required -
descriptionstring -
opt_in_modestring - Double opt-in creates new contacts as `pending` until they confirm.
-
singledouble
Response
-
dataobject -
data.idinteger -
data.namestring -
data.descriptionstring or null -
data.is_defaultboolean -
data.opt_in_modestring -
singledouble -
data.contacts_countinteger
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/lists \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Newsletter","description":"Monthly product news","opt_in_mode":"single"}'
Request body
{
"name": "Newsletter",
"description": "Monthly product news",
"opt_in_mode": "single"
}
Response 201
{
"data": {
"id": 7,
"name": "Newsletter",
"description": "Monthly product news",
"is_default": false,
"opt_in_mode": "single",
"contacts_count": 1280
}
}
GET
/lists/{list}
Fetch a list
Requires scope contacts:read
Path parameters
-
listinteger Required - List id.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.descriptionstring or null -
data.is_defaultboolean -
data.opt_in_modestring -
singledouble -
data.contacts_countinteger
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/lists/:list \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 7,
"name": "Newsletter",
"description": "Monthly product news",
"is_default": false,
"opt_in_mode": "single",
"contacts_count": 1280
}
}
PATCH
/lists/{list}
Update a list
Requires scope contacts:write
Path parameters
-
listinteger Required - List id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
namestring Required -
descriptionstring -
opt_in_modestring - Double opt-in creates new contacts as `pending` until they confirm.
-
singledouble
Response
-
dataobject -
data.idinteger -
data.namestring -
data.descriptionstring or null -
data.is_defaultboolean -
data.opt_in_modestring -
singledouble -
data.contacts_countinteger
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X PATCH https://tweak.email/api/v1/lists/:list \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Newsletter","description":"Monthly product news","opt_in_mode":"single"}'
Request body
{
"name": "Newsletter",
"description": "Monthly product news",
"opt_in_mode": "single"
}
Response 200
{
"data": {
"id": 7,
"name": "Newsletter",
"description": "Monthly product news",
"is_default": false,
"opt_in_mode": "single",
"contacts_count": 1280
}
}
DELETE
/lists/{list}
Delete a list
Requires scope contacts:write
The default list cannot be deleted.
Path parameters
-
listinteger Required - List id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.idinteger -
data.deletedboolean
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X DELETE https://tweak.email/api/v1/lists/:list \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 42,
"deleted": true
}
}
GET
/lists/{list}/contacts
List the contacts on a list
Requires scope contacts:read
Path parameters
-
listinteger Required - List id.
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
Response
-
dataarray of object -
data.idinteger -
data.emailstring -
data.first_namestring or null -
data.last_namestring or null -
data.statusstring -
activependingunsubscribedbounced -
data.metadataobject -
data.subscribed_atstring or null -
data.unsubscribed_atstring or null -
data.confirmed_atstring or null -
data.consent_sourcestring or null - How consent was obtained: `api`, `import`, `manual`, `signup_form`, `embedded_form`, or the value your integration supplied. Older records confirmed by e-mail may say `double_opt_in`; confirmation is now recorded in `confirmed_at` instead.
-
data.consent_attested_atstring or null - When the sender attested that this contact gave permission to be emailed.
-
data.soft_bounce_countinteger -
data.created_atstring or null -
data.updated_atstring or null -
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/lists/:list/contacts \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 42,
"email": "jane@example.com",
"first_name": "Jane",
"last_name": "Okonkwo",
"status": "active",
"metadata": {
"company": "Acme",
"city": "Copenhagen"
},
"subscribed_at": "2026-08-01T09:15:00+00:00",
"unsubscribed_at": null,
"confirmed_at": null,
"consent_source": "signup_form",
"consent_attested_at": "2026-08-01T09:15:00+00:00",
"soft_bounce_count": 0,
"created_at": "2026-08-01T09:15:00+00:00",
"updated_at": "2026-08-09T14:02:00+00:00"
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/lists/{list}/contacts
Attach contacts to a list
Requires scope contacts:write
Ids belonging to another team are silently skipped and reported in the `skipped` count.
Path parameters
-
listinteger Required - List id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
contact_idsarray of integer Required
Response
-
dataobject -
data.list_idinteger -
data.attachedinteger -
data.skippedinteger - Ids that did not resolve to a contact on your team.
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/lists/:list/contacts \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contact_ids":[42,43]}'
Request body
{
"contact_ids": [
42,
43
]
}
Response 200
{
"data": {
"list_id": 1,
"attached": 1,
"skipped": 1
}
}
DELETE
/lists/{list}/contacts/{contact}
Remove a contact from a list
Requires scope contacts:write
Detaches the membership only. The contact itself is untouched.
Path parameters
-
listinteger Required - List id.
-
contactinteger Required - Contact id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.list_idinteger -
data.contact_idinteger -
data.detachedboolean
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X DELETE https://tweak.email/api/v1/lists/:list/contacts/:contact \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"list_id": 7,
"contact_id": 42,
"detached": true
}
}
GET
/contact-fields
List contact fields
Requires scope contacts:read
Your team's custom contact fields: the schema the app edits under Settings → Contact Fields. Values live in each contact's `metadata` under the field's `key`; segment rules name the field `custom.<key>`, templates personalise with `{{key}}`.
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
Response
-
dataarray of object -
data.idinteger -
data.namestring -
data.keystring - The `metadata` key values are stored under. Fixed once created.
-
data.typestring -
textnumberdateboolean -
data.positioninteger -
data.metadata_keystring - Same as `key`.
-
data.merge_tagstring -
data.segment_fieldstring - The field name in a segment rule condition.
-
data.created_atstring or null -
data.updated_atstring or null -
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/contact-fields \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 12,
"name": "Plan tier",
"key": "plan_tier",
"type": "text",
"position": 1,
"metadata_key": "plan_tier",
"merge_tag": "{{plan_tier}}",
"segment_field": "custom.plan_tier",
"created_at": "2026-08-01T09:15:00+00:00",
"updated_at": "2026-08-01T09:15:00+00:00"
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/contact-fields
Create a contact field
Requires scope contacts:write
The key is derived from the name unless you give one. Keys of built-in fields (such as `email`, `first_name`, `company`) are reserved, a key can exist once per team, and a team can define up to 30 fields. Name, key or type problems are a 422 naming the field.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
namestring Required -
typestring - How values are compared in segment rules: text, number, date (YYYY-MM-DD) or boolean.
-
textnumberdateboolean -
keystring - Optional; derived from the name when left out ("Plan tier" becomes `plan_tier`). Use it to match the metadata keys you already send.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.keystring - The `metadata` key values are stored under. Fixed once created.
-
data.typestring -
textnumberdateboolean -
data.positioninteger -
data.metadata_keystring - Same as `key`.
-
data.merge_tagstring -
data.segment_fieldstring - The field name in a segment rule condition.
-
data.created_atstring or null -
data.updated_atstring or null
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/contact-fields \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Plan tier","type":"text","key":"plan_tier"}'
Request body
{
"name": "Plan tier",
"type": "text",
"key": "plan_tier"
}
Response 201
{
"data": {
"id": 12,
"name": "Plan tier",
"key": "plan_tier",
"type": "text",
"position": 1,
"metadata_key": "plan_tier",
"merge_tag": "{{plan_tier}}",
"segment_field": "custom.plan_tier",
"created_at": "2026-08-01T09:15:00+00:00",
"updated_at": "2026-08-01T09:15:00+00:00"
}
}
GET
/contact-fields/{field}
Fetch a contact field
Requires scope contacts:read
Path parameters
-
fieldinteger Required - Contact field id.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.keystring - The `metadata` key values are stored under. Fixed once created.
-
data.typestring -
textnumberdateboolean -
data.positioninteger -
data.metadata_keystring - Same as `key`.
-
data.merge_tagstring -
data.segment_fieldstring - The field name in a segment rule condition.
-
data.created_atstring or null -
data.updated_atstring or null
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/contact-fields/:field \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 12,
"name": "Plan tier",
"key": "plan_tier",
"type": "text",
"position": 1,
"metadata_key": "plan_tier",
"merge_tag": "{{plan_tier}}",
"segment_field": "custom.plan_tier",
"created_at": "2026-08-01T09:15:00+00:00",
"updated_at": "2026-08-01T09:15:00+00:00"
}
}
PATCH
/contact-fields/{field}
Rename a contact field
Requires scope contacts:write
Only the name can change. The key is what stored values and saved templates refer to, and the type is what saved segment rules were checked against, so sending a different `key` or `type` is a 422.
Path parameters
-
fieldinteger Required - Contact field id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
namestring Required -
keystring - Accepted only when it is the field's current key (so the field as returned can be sent back); a different key is a 422. Keys are fixed once created.
-
typestring - Accepted only when it is the field's current type; a different type is a 422. Types are fixed once created.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.keystring - The `metadata` key values are stored under. Fixed once created.
-
data.typestring -
textnumberdateboolean -
data.positioninteger -
data.metadata_keystring - Same as `key`.
-
data.merge_tagstring -
data.segment_fieldstring - The field name in a segment rule condition.
-
data.created_atstring or null -
data.updated_atstring or null
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X PATCH https://tweak.email/api/v1/contact-fields/:field \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Plan","key":"plan_tier","type":"text"}'
Request body
{
"name": "Plan",
"key": "plan_tier",
"type": "text"
}
Response 200
{
"data": {
"id": 12,
"name": "Plan tier",
"key": "plan_tier",
"type": "text",
"position": 1,
"metadata_key": "plan_tier",
"merge_tag": "{{plan_tier}}",
"segment_field": "custom.plan_tier",
"created_at": "2026-08-01T09:15:00+00:00",
"updated_at": "2026-08-01T09:15:00+00:00"
}
}
DELETE
/contact-fields/{field}
Delete a contact field
Requires scope contacts:write
Removes the definition only: values already stored on contacts stay in their metadata, and creating a field with the same key again makes them usable again. A segment rule on the field stops being valid until it is.
Path parameters
-
fieldinteger Required - Contact field id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.idinteger -
data.deletedboolean
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X DELETE https://tweak.email/api/v1/contact-fields/:field \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 42,
"deleted": true
}
}
GET
/segments
List segments
Requires scope contacts:read
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
Response
-
dataarray of object -
data.idinteger -
data.namestring -
data.definitionobject - Every key is optional and the keys combine with AND; an empty definition matches every active contact. A key not listed here is refused with 422 naming it, so a misspelt rule cannot silently widen the audience. Conditions on custom fields, AND / OR groups and exclusions go in `rules`.
-
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/segments \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 5,
"name": "Engaged in Copenhagen",
"definition": {
"tag_ids": [
3
],
"date_from": "2026-01-01",
"date_to": null,
"search": null,
"company": null,
"location": "Copenhagen",
"engagement": {
"type": "opened",
"days": 90
},
"rules": {
"version": 1,
"match": "all",
"timezone": "Europe/Copenhagen",
"groups": [
{
"match": "all",
"conditions": [
{
"field": "custom.plan",
"operator": "is",
"value": "trial"
},
{
"field": "custom.signup_date",
"operator": "in_last_days",
"value": 14
}
]
},
{
"match": "any",
"conditions": [
{
"field": "country",
"operator": "is",
"value": "Denmark"
},
{
"field": "custom.seats",
"operator": "gte",
"value": 10
}
]
}
],
"exclude": {
"segment_ids": [
5
],
"tag_ids": [
7
]
}
}
}
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/segments
Create a segment
Requires scope contacts:write
A definition key the API does not know is refused with 422 naming the key, rather than ignored, and so is a top-level field other than `name` and `definition` (for example `rules` sent beside `definition` instead of inside it).
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
namestring Required -
definitionobject - Every key is optional and the keys combine with AND; an empty definition matches every active contact. A key not listed here is refused with 422 naming it, so a misspelt rule cannot silently widen the audience. Conditions on custom fields, AND / OR groups and exclusions go in `rules`.
-
definition.tag_idsarray of integer - Contacts carrying any of these tags.
-
definition.date_fromstring or null - Subscribed on or after this date.
-
definition.date_tostring or null - Subscribed on or before this date.
-
definition.searchstring or null - Matches email, first name, or last name.
-
definition.companystring or null - Matches the contact metadata `company` field.
-
definition.locationstring or null - Matches metadata city, country, or location.
-
definition.engagementobject or null - Restrict to contacts by email engagement over a trailing window. Machine opens (Apple MPP and bot prefetches) are excluded. Note that only the SendGrid integration flags them, so on other providers positive open conditions may still be over-inclusive.
-
definition.rulesobject or null - Conditions on contact fields, grouped, plus exclusions. ANDed with the other definition keys. Built-in fields are `email`, `first_name`, `last_name`, `company`, `city`, `country`, `location`, `date_added`, `tags` and `engagement`; a custom contact field is `custom.<key>`, typed by its definition (see `GET /segments/fields`). Text comparisons ignore case and surrounding spaces. `is_not`, `not_contains` and `neq` also match contacts with no value. A value that does not fit the field's type (text in a number field, a date not written YYYY-MM-DD) is never matched by a comparison. An excluded segment is resolved as it is defined when the audience is resolved, and a segment that others exclude cannot be deleted.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.definitionobject - Every key is optional and the keys combine with AND; an empty definition matches every active contact. A key not listed here is refused with 422 naming it, so a misspelt rule cannot silently widen the audience. Conditions on custom fields, AND / OR groups and exclusions go in `rules`.
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/segments \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Engaged in Copenhagen","definition":{"tag_ids":[3],"date_from":"2026-01-01","date_to":null,"search":null,"company":null,"location":"Copenhagen","engagement":{"type":"opened","days":90},"rules":{"version":1,"match":"all","timezone":"Europe/Copenhagen","groups":[{"match":"all","conditions":[{"field":"custom.plan","operator":"is","value":"trial"},{"field":"custom.signup_date","operator":"in_last_days","value":14}]},{"match":"any","conditions":[{"field":"country","operator":"is","value":"Denmark"},{"field":"custom.seats","operator":"gte","value":10}]}],"exclude":{"segment_ids":[5],"tag_ids":[7]}}}}'
Request body
{
"name": "Engaged in Copenhagen",
"definition": {
"tag_ids": [
3
],
"date_from": "2026-01-01",
"date_to": null,
"search": null,
"company": null,
"location": "Copenhagen",
"engagement": {
"type": "opened",
"days": 90
},
"rules": {
"version": 1,
"match": "all",
"timezone": "Europe/Copenhagen",
"groups": [
{
"match": "all",
"conditions": [
{
"field": "custom.plan",
"operator": "is",
"value": "trial"
},
{
"field": "custom.signup_date",
"operator": "in_last_days",
"value": 14
}
]
},
{
"match": "any",
"conditions": [
{
"field": "country",
"operator": "is",
"value": "Denmark"
},
{
"field": "custom.seats",
"operator": "gte",
"value": 10
}
]
}
],
"exclude": {
"segment_ids": [
5
],
"tag_ids": [
7
]
}
}
}
}
Response 201
{
"data": {
"id": 5,
"name": "Engaged in Copenhagen",
"definition": {
"tag_ids": [
3
],
"date_from": "2026-01-01",
"date_to": null,
"search": null,
"company": null,
"location": "Copenhagen",
"engagement": {
"type": "opened",
"days": 90
},
"rules": {
"version": 1,
"match": "all",
"timezone": "Europe/Copenhagen",
"groups": [
{
"match": "all",
"conditions": [
{
"field": "custom.plan",
"operator": "is",
"value": "trial"
},
{
"field": "custom.signup_date",
"operator": "in_last_days",
"value": 14
}
]
},
{
"match": "any",
"conditions": [
{
"field": "country",
"operator": "is",
"value": "Denmark"
},
{
"field": "custom.seats",
"operator": "gte",
"value": 10
}
]
}
],
"exclude": {
"segment_ids": [
5
],
"tag_ids": [
7
]
}
}
}
}
}
GET
/segments/fields
List segment fields
Requires scope contacts:read
The fields a rule-tree condition can use: the built-in fields plus your team's custom contact fields, each with its type and the operators that type accepts. Define a custom field with `POST /contact-fields` before a rule uses it. Tag ids in a tags condition or an exclusion must be your team's; another id is a 422 naming it.
Response
-
dataarray of object -
data.fieldstring -
data.labelstring -
data.typestring -
textnumberdatebooleantagsengagement -
data.customboolean -
data.operatorsarray of string
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/segments/fields \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"field": "custom.plan",
"label": "Plan",
"type": "text",
"custom": true,
"operators": [
"is",
"is_not",
"contains",
"not_contains",
"is_empty",
"is_not_empty"
]
}
]
}
POST
/segments/preview
Preview an unsaved segment definition
Requires scope contacts:read
Read-only. Returns the resolved contact count plus a 10-record sample, so a definition can be iterated on before it is committed. The filters go inside `definition`: a request without it, or with any other top-level field (such as `rules` on its own), is a 422 rather than a preview of every contact. `{"definition": {}}` previews every contact on purpose.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
definitionobject Required - Every key is optional and the keys combine with AND; an empty definition matches every active contact. A key not listed here is refused with 422 naming it, so a misspelt rule cannot silently widen the audience. Conditions on custom fields, AND / OR groups and exclusions go in `rules`.
-
definition.tag_idsarray of integer - Contacts carrying any of these tags.
-
definition.date_fromstring or null - Subscribed on or after this date.
-
definition.date_tostring or null - Subscribed on or before this date.
-
definition.searchstring or null - Matches email, first name, or last name.
-
definition.companystring or null - Matches the contact metadata `company` field.
-
definition.locationstring or null - Matches metadata city, country, or location.
-
definition.engagementobject or null - Restrict to contacts by email engagement over a trailing window. Machine opens (Apple MPP and bot prefetches) are excluded. Note that only the SendGrid integration flags them, so on other providers positive open conditions may still be over-inclusive.
-
definition.rulesobject or null - Conditions on contact fields, grouped, plus exclusions. ANDed with the other definition keys. Built-in fields are `email`, `first_name`, `last_name`, `company`, `city`, `country`, `location`, `date_added`, `tags` and `engagement`; a custom contact field is `custom.<key>`, typed by its definition (see `GET /segments/fields`). Text comparisons ignore case and surrounding spaces. `is_not`, `not_contains` and `neq` also match contacts with no value. A value that does not fit the field's type (text in a number field, a date not written YYYY-MM-DD) is never matched by a comparison. An excluded segment is resolved as it is defined when the audience is resolved, and a segment that others exclude cannot be deleted.
Response
-
dataobject -
data.countinteger - Active contacts the definition resolves to.
-
data.filtersobject - Every key is optional and the keys combine with AND; an empty definition matches every active contact. A key not listed here is refused with 422 naming it, so a misspelt rule cannot silently widen the audience. Conditions on custom fields, AND / OR groups and exclusions go in `rules`.
-
data.samplearray of object
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/segments/preview \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"definition":{"tag_ids":[3],"date_from":"2026-01-01","date_to":null,"search":null,"company":null,"location":"Copenhagen","engagement":{"type":"opened","days":90},"rules":{"version":1,"match":"all","timezone":"Europe/Copenhagen","groups":[{"match":"all","conditions":[{"field":"custom.plan","operator":"is","value":"trial"},{"field":"custom.signup_date","operator":"in_last_days","value":14}]},{"match":"any","conditions":[{"field":"country","operator":"is","value":"Denmark"},{"field":"custom.seats","operator":"gte","value":10}]}],"exclude":{"segment_ids":[5],"tag_ids":[7]}}}}'
Request body
{
"definition": {
"tag_ids": [
3
],
"date_from": "2026-01-01",
"date_to": null,
"search": null,
"company": null,
"location": "Copenhagen",
"engagement": {
"type": "opened",
"days": 90
},
"rules": {
"version": 1,
"match": "all",
"timezone": "Europe/Copenhagen",
"groups": [
{
"match": "all",
"conditions": [
{
"field": "custom.plan",
"operator": "is",
"value": "trial"
},
{
"field": "custom.signup_date",
"operator": "in_last_days",
"value": 14
}
]
},
{
"match": "any",
"conditions": [
{
"field": "country",
"operator": "is",
"value": "Denmark"
},
{
"field": "custom.seats",
"operator": "gte",
"value": 10
}
]
}
],
"exclude": {
"segment_ids": [
5
],
"tag_ids": [
7
]
}
}
}
}
Response 200
{
"data": {
"count": 312,
"filters": {
"tag_ids": [
3
],
"date_from": "2026-01-01",
"date_to": null,
"search": null,
"company": null,
"location": "Copenhagen",
"engagement": {
"type": "opened",
"days": 90
},
"rules": {
"version": 1,
"match": "all",
"timezone": "Europe/Copenhagen",
"groups": [
{
"match": "all",
"conditions": [
{
"field": "custom.plan",
"operator": "is",
"value": "trial"
},
{
"field": "custom.signup_date",
"operator": "in_last_days",
"value": 14
}
]
},
{
"match": "any",
"conditions": [
{
"field": "country",
"operator": "is",
"value": "Denmark"
},
{
"field": "custom.seats",
"operator": "gte",
"value": 10
}
]
}
],
"exclude": {
"segment_ids": [
5
],
"tag_ids": [
7
]
}
}
},
"sample": [
{
"id": 42,
"email": "jane@example.com",
"first_name": "Jane",
"last_name": "Okonkwo",
"status": "active",
"metadata": {
"company": "Acme",
"city": "Copenhagen"
},
"subscribed_at": "2026-08-01T09:15:00+00:00",
"unsubscribed_at": null,
"confirmed_at": null,
"consent_source": "signup_form",
"consent_attested_at": "2026-08-01T09:15:00+00:00",
"soft_bounce_count": 0,
"created_at": "2026-08-01T09:15:00+00:00",
"updated_at": "2026-08-09T14:02:00+00:00"
}
]
}
}
GET
/segments/{segment}
Fetch a segment
Requires scope contacts:read
Path parameters
-
segmentinteger Required - Segment id.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.definitionobject - Every key is optional and the keys combine with AND; an empty definition matches every active contact. A key not listed here is refused with 422 naming it, so a misspelt rule cannot silently widen the audience. Conditions on custom fields, AND / OR groups and exclusions go in `rules`.
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/segments/:segment \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 5,
"name": "Engaged in Copenhagen",
"definition": {
"tag_ids": [
3
],
"date_from": "2026-01-01",
"date_to": null,
"search": null,
"company": null,
"location": "Copenhagen",
"engagement": {
"type": "opened",
"days": 90
},
"rules": {
"version": 1,
"match": "all",
"timezone": "Europe/Copenhagen",
"groups": [
{
"match": "all",
"conditions": [
{
"field": "custom.plan",
"operator": "is",
"value": "trial"
},
{
"field": "custom.signup_date",
"operator": "in_last_days",
"value": 14
}
]
},
{
"match": "any",
"conditions": [
{
"field": "country",
"operator": "is",
"value": "Denmark"
},
{
"field": "custom.seats",
"operator": "gte",
"value": 10
}
]
}
],
"exclude": {
"segment_ids": [
5
],
"tag_ids": [
7
]
}
}
}
}
}
PATCH
/segments/{segment}
Update a segment
Requires scope contacts:write
Takes `name` and `definition`; any other top-level field is a 422 naming it.
Path parameters
-
segmentinteger Required - Segment id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
namestring Required -
definitionobject - Every key is optional and the keys combine with AND; an empty definition matches every active contact. A key not listed here is refused with 422 naming it, so a misspelt rule cannot silently widen the audience. Conditions on custom fields, AND / OR groups and exclusions go in `rules`.
-
definition.tag_idsarray of integer - Contacts carrying any of these tags.
-
definition.date_fromstring or null - Subscribed on or after this date.
-
definition.date_tostring or null - Subscribed on or before this date.
-
definition.searchstring or null - Matches email, first name, or last name.
-
definition.companystring or null - Matches the contact metadata `company` field.
-
definition.locationstring or null - Matches metadata city, country, or location.
-
definition.engagementobject or null - Restrict to contacts by email engagement over a trailing window. Machine opens (Apple MPP and bot prefetches) are excluded. Note that only the SendGrid integration flags them, so on other providers positive open conditions may still be over-inclusive.
-
definition.rulesobject or null - Conditions on contact fields, grouped, plus exclusions. ANDed with the other definition keys. Built-in fields are `email`, `first_name`, `last_name`, `company`, `city`, `country`, `location`, `date_added`, `tags` and `engagement`; a custom contact field is `custom.<key>`, typed by its definition (see `GET /segments/fields`). Text comparisons ignore case and surrounding spaces. `is_not`, `not_contains` and `neq` also match contacts with no value. A value that does not fit the field's type (text in a number field, a date not written YYYY-MM-DD) is never matched by a comparison. An excluded segment is resolved as it is defined when the audience is resolved, and a segment that others exclude cannot be deleted.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.definitionobject - Every key is optional and the keys combine with AND; an empty definition matches every active contact. A key not listed here is refused with 422 naming it, so a misspelt rule cannot silently widen the audience. Conditions on custom fields, AND / OR groups and exclusions go in `rules`.
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X PATCH https://tweak.email/api/v1/segments/:segment \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Engaged in Copenhagen","definition":{"tag_ids":[3],"date_from":"2026-01-01","date_to":null,"search":null,"company":null,"location":"Copenhagen","engagement":{"type":"opened","days":90},"rules":{"version":1,"match":"all","timezone":"Europe/Copenhagen","groups":[{"match":"all","conditions":[{"field":"custom.plan","operator":"is","value":"trial"},{"field":"custom.signup_date","operator":"in_last_days","value":14}]},{"match":"any","conditions":[{"field":"country","operator":"is","value":"Denmark"},{"field":"custom.seats","operator":"gte","value":10}]}],"exclude":{"segment_ids":[5],"tag_ids":[7]}}}}'
Request body
{
"name": "Engaged in Copenhagen",
"definition": {
"tag_ids": [
3
],
"date_from": "2026-01-01",
"date_to": null,
"search": null,
"company": null,
"location": "Copenhagen",
"engagement": {
"type": "opened",
"days": 90
},
"rules": {
"version": 1,
"match": "all",
"timezone": "Europe/Copenhagen",
"groups": [
{
"match": "all",
"conditions": [
{
"field": "custom.plan",
"operator": "is",
"value": "trial"
},
{
"field": "custom.signup_date",
"operator": "in_last_days",
"value": 14
}
]
},
{
"match": "any",
"conditions": [
{
"field": "country",
"operator": "is",
"value": "Denmark"
},
{
"field": "custom.seats",
"operator": "gte",
"value": 10
}
]
}
],
"exclude": {
"segment_ids": [
5
],
"tag_ids": [
7
]
}
}
}
}
Response 200
{
"data": {
"id": 5,
"name": "Engaged in Copenhagen",
"definition": {
"tag_ids": [
3
],
"date_from": "2026-01-01",
"date_to": null,
"search": null,
"company": null,
"location": "Copenhagen",
"engagement": {
"type": "opened",
"days": 90
},
"rules": {
"version": 1,
"match": "all",
"timezone": "Europe/Copenhagen",
"groups": [
{
"match": "all",
"conditions": [
{
"field": "custom.plan",
"operator": "is",
"value": "trial"
},
{
"field": "custom.signup_date",
"operator": "in_last_days",
"value": 14
}
]
},
{
"match": "any",
"conditions": [
{
"field": "country",
"operator": "is",
"value": "Denmark"
},
{
"field": "custom.seats",
"operator": "gte",
"value": 10
}
]
}
],
"exclude": {
"segment_ids": [
5
],
"tag_ids": [
7
]
}
}
}
}
}
DELETE
/segments/{segment}
Delete a segment
Requires scope contacts:write
Path parameters
-
segmentinteger Required - Segment id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.idinteger -
data.deletedboolean
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X DELETE https://tweak.email/api/v1/segments/:segment \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 42,
"deleted": true
}
}
POST
/segments/{segment}/preview
Preview a saved segment
Requires scope contacts:read
Read-only: resolved count plus a sample.
Path parameters
-
segmentinteger Required - Segment id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.countinteger - Active contacts the definition resolves to.
-
data.filtersobject - Every key is optional and the keys combine with AND; an empty definition matches every active contact. A key not listed here is refused with 422 naming it, so a misspelt rule cannot silently widen the audience. Conditions on custom fields, AND / OR groups and exclusions go in `rules`.
-
data.samplearray of object
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/segments/:segment/preview \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"count": 312,
"filters": {
"tag_ids": [
3
],
"date_from": "2026-01-01",
"date_to": null,
"search": null,
"company": null,
"location": "Copenhagen",
"engagement": {
"type": "opened",
"days": 90
},
"rules": {
"version": 1,
"match": "all",
"timezone": "Europe/Copenhagen",
"groups": [
{
"match": "all",
"conditions": [
{
"field": "custom.plan",
"operator": "is",
"value": "trial"
},
{
"field": "custom.signup_date",
"operator": "in_last_days",
"value": 14
}
]
},
{
"match": "any",
"conditions": [
{
"field": "country",
"operator": "is",
"value": "Denmark"
},
{
"field": "custom.seats",
"operator": "gte",
"value": 10
}
]
}
],
"exclude": {
"segment_ids": [
5
],
"tag_ids": [
7
]
}
}
},
"sample": [
{
"id": 42,
"email": "jane@example.com",
"first_name": "Jane",
"last_name": "Okonkwo",
"status": "active",
"metadata": {
"company": "Acme",
"city": "Copenhagen"
},
"subscribed_at": "2026-08-01T09:15:00+00:00",
"unsubscribed_at": null,
"confirmed_at": null,
"consent_source": "signup_form",
"consent_attested_at": "2026-08-01T09:15:00+00:00",
"soft_bounce_count": 0,
"created_at": "2026-08-01T09:15:00+00:00",
"updated_at": "2026-08-09T14:02:00+00:00"
}
]
}
}
Campaigns
Campaign authoring and sending
GET
/campaigns
List campaigns
Requires scope campaigns:read
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
-
statusstring - Filter by campaign status.
Response
-
dataarray of object -
data.idinteger -
data.namestring -
data.subjectstring or null -
data.preheaderstring or null -
data.from_namestring or null -
data.from_emailstring or null -
data.reply_tostring or null -
data.statusstring -
draftscheduledscreeningheldqueuingsendingpausedsentpartialcancelledfailed -
data.audienceobject -
data.template_idinteger or null -
data.ab_testobject - `winner_metric` is `opens` or `clicks`, the same values the create and update endpoints accept. `type` is `subject`, `content`, `both` or `send_time`; `send_time_mode` (`winner` or `report`), `timezone` and `remainder_send_at` are only set for a send-time test.
-
data.total_recipientsinteger -
data.sent_countinteger -
data.failed_countinteger -
data.failure_reasonstring or null -
data.scheduled_atstring or null -
data.sent_atstring or null -
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/campaigns \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 118,
"name": "August product update",
"subject": "What's new this month",
"preheader": "Three things we shipped",
"from_name": "Jane at Acme",
"from_email": "hello@acme.com",
"reply_to": "support@acme.com",
"status": "sent",
"audience": {
"source": "list",
"contact_list_id": 1,
"filters": null
},
"template_id": 12,
"ab_test": {
"enabled": false,
"percentage": 20,
"winner_metric": "opens",
"delay_minutes": 240,
"winner_variant_id": null,
"type": "subject",
"send_time_mode": null,
"timezone": null,
"remainder_send_at": null
},
"total_recipients": 12480,
"sent_count": 12463,
"failed_count": 17,
"failure_reason": null,
"scheduled_at": null,
"sent_at": "2026-08-09T10:00:00+00:00"
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/campaigns
Create a campaign
Requires scope campaigns:write
Created as a draft; only `name` is required. A draft without a subject is stored with an empty one, and sending is refused until it has one. Set the body separately via the content endpoint.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
namestring Required -
subjectstring or null - Optional on a draft. Omitted or `null`, it is stored as an empty subject, and a send is refused until one is set.
-
preheaderstring or null -
from_namestring or null -
from_emailstring - Sent as-is from a fully verified sending domain. On tweak.email without one, the message goes out from your team address on the shared sender domain with this address as Reply-To. Third-party providers require a verified domain.
-
reply_tostring -
audience_sourcestring -
listbigquery -
contact_list_idinteger or null -
segment_idinteger or null - Copies the segment's filter definition onto the campaign. Takes precedence over `audience_filters`.
-
audience_filtersobject - Every key is optional and the keys combine with AND; an empty definition matches every active contact. A key not listed here is refused with 422 naming it, so a misspelt rule cannot silently widen the audience. Conditions on custom fields, AND / OR groups and exclusions go in `rules`.
-
audience_filters.tag_idsarray of integer - Contacts carrying any of these tags.
-
audience_filters.date_fromstring or null - Subscribed on or after this date.
-
audience_filters.date_tostring or null - Subscribed on or before this date.
-
audience_filters.searchstring or null - Matches email, first name, or last name.
-
audience_filters.companystring or null - Matches the contact metadata `company` field.
-
audience_filters.locationstring or null - Matches metadata city, country, or location.
-
audience_filters.engagementobject or null - Restrict to contacts by email engagement over a trailing window. Machine opens (Apple MPP and bot prefetches) are excluded. Note that only the SendGrid integration flags them, so on other providers positive open conditions may still be over-inclusive.
-
audience_filters.rulesobject or null - Conditions on contact fields, grouped, plus exclusions. ANDed with the other definition keys. Built-in fields are `email`, `first_name`, `last_name`, `company`, `city`, `country`, `location`, `date_added`, `tags` and `engagement`; a custom contact field is `custom.<key>`, typed by its definition (see `GET /segments/fields`). Text comparisons ignore case and surrounding spaces. `is_not`, `not_contains` and `neq` also match contacts with no value. A value that does not fit the field's type (text in a number field, a date not written YYYY-MM-DD) is never matched by a comparison. An excluded segment is resolved as it is defined when the audience is resolved, and a segment that others exclude cannot be deleted.
-
template_idinteger or null - Seeds the body from this template when the campaign has none yet.
-
ab_test_enabledboolean -
ab_test_percentageinteger -
ab_winner_metricstring - `opens` or `clicks`. The singular forms are accepted too; responses always use the plural.
-
opensclicksopenclick -
ab_test_delay_minutesinteger
Response
-
dataobject -
data.idinteger -
data.namestring -
data.subjectstring or null -
data.preheaderstring or null -
data.from_namestring or null -
data.from_emailstring or null -
data.reply_tostring or null -
data.statusstring -
draftscheduledscreeningheldqueuingsendingpausedsentpartialcancelledfailed -
data.audienceobject -
data.template_idinteger or null -
data.ab_testobject - `winner_metric` is `opens` or `clicks`, the same values the create and update endpoints accept. `type` is `subject`, `content`, `both` or `send_time`; `send_time_mode` (`winner` or `report`), `timezone` and `remainder_send_at` are only set for a send-time test.
-
data.total_recipientsinteger -
data.sent_countinteger -
data.failed_countinteger -
data.failure_reasonstring or null -
data.scheduled_atstring or null -
data.sent_atstring or null
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/campaigns \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"August product update","subject":"What's new this month","preheader":"Three things we shipped","from_name":"Jane at Acme","from_email":"hello@acme.com","reply_to":"support@acme.com","audience_source":"list","contact_list_id":7,"segment_id":5}'
Request body
{
"name": "August product update",
"subject": "What's new this month",
"preheader": "Three things we shipped",
"from_name": "Jane at Acme",
"from_email": "hello@acme.com",
"reply_to": "support@acme.com",
"audience_source": "list",
"contact_list_id": 7,
"segment_id": 5
}
Response 201
{
"data": {
"id": 118,
"name": "August product update",
"subject": "What's new this month",
"preheader": "Three things we shipped",
"from_name": "Jane at Acme",
"from_email": "hello@acme.com",
"reply_to": "support@acme.com",
"status": "sent",
"audience": {
"source": "list",
"contact_list_id": 1,
"filters": null
},
"template_id": 12,
"ab_test": {
"enabled": false,
"percentage": 20,
"winner_metric": "opens",
"delay_minutes": 240,
"winner_variant_id": null,
"type": "subject",
"send_time_mode": null,
"timezone": null,
"remainder_send_at": null
},
"total_recipients": 12480,
"sent_count": 12463,
"failed_count": 17,
"failure_reason": null,
"scheduled_at": null,
"sent_at": "2026-08-09T10:00:00+00:00"
}
}
GET
/campaigns/{campaign}
Fetch a campaign
Requires scope campaigns:read
Path parameters
-
campaigninteger Required - Campaign id.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.subjectstring or null -
data.preheaderstring or null -
data.from_namestring or null -
data.from_emailstring or null -
data.reply_tostring or null -
data.statusstring -
draftscheduledscreeningheldqueuingsendingpausedsentpartialcancelledfailed -
data.audienceobject -
data.template_idinteger or null -
data.ab_testobject - `winner_metric` is `opens` or `clicks`, the same values the create and update endpoints accept. `type` is `subject`, `content`, `both` or `send_time`; `send_time_mode` (`winner` or `report`), `timezone` and `remainder_send_at` are only set for a send-time test.
-
data.total_recipientsinteger -
data.sent_countinteger -
data.failed_countinteger -
data.failure_reasonstring or null -
data.scheduled_atstring or null -
data.sent_atstring or null
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/campaigns/:campaign \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 118,
"name": "August product update",
"subject": "What's new this month",
"preheader": "Three things we shipped",
"from_name": "Jane at Acme",
"from_email": "hello@acme.com",
"reply_to": "support@acme.com",
"status": "sent",
"audience": {
"source": "list",
"contact_list_id": 1,
"filters": null
},
"template_id": 12,
"ab_test": {
"enabled": false,
"percentage": 20,
"winner_metric": "opens",
"delay_minutes": 240,
"winner_variant_id": null,
"type": "subject",
"send_time_mode": null,
"timezone": null,
"remainder_send_at": null
},
"total_recipients": 12480,
"sent_count": 12463,
"failed_count": 17,
"failure_reason": null,
"scheduled_at": null,
"sent_at": "2026-08-09T10:00:00+00:00"
}
}
PATCH
/campaigns/{campaign}
Update a campaign
Requires scope campaigns:write
Refused with 422 once the campaign is screening, sending, or sent.
Path parameters
-
campaigninteger Required - Campaign id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
namestring Required -
subjectstring or null - Optional on a draft. Omitted or `null`, it is stored as an empty subject, and a send is refused until one is set.
-
preheaderstring or null -
from_namestring or null -
from_emailstring - Sent as-is from a fully verified sending domain. On tweak.email without one, the message goes out from your team address on the shared sender domain with this address as Reply-To. Third-party providers require a verified domain.
-
reply_tostring -
audience_sourcestring -
listbigquery -
contact_list_idinteger or null -
segment_idinteger or null - Copies the segment's filter definition onto the campaign. Takes precedence over `audience_filters`.
-
audience_filtersobject - Every key is optional and the keys combine with AND; an empty definition matches every active contact. A key not listed here is refused with 422 naming it, so a misspelt rule cannot silently widen the audience. Conditions on custom fields, AND / OR groups and exclusions go in `rules`.
-
audience_filters.tag_idsarray of integer - Contacts carrying any of these tags.
-
audience_filters.date_fromstring or null - Subscribed on or after this date.
-
audience_filters.date_tostring or null - Subscribed on or before this date.
-
audience_filters.searchstring or null - Matches email, first name, or last name.
-
audience_filters.companystring or null - Matches the contact metadata `company` field.
-
audience_filters.locationstring or null - Matches metadata city, country, or location.
-
audience_filters.engagementobject or null - Restrict to contacts by email engagement over a trailing window. Machine opens (Apple MPP and bot prefetches) are excluded. Note that only the SendGrid integration flags them, so on other providers positive open conditions may still be over-inclusive.
-
audience_filters.rulesobject or null - Conditions on contact fields, grouped, plus exclusions. ANDed with the other definition keys. Built-in fields are `email`, `first_name`, `last_name`, `company`, `city`, `country`, `location`, `date_added`, `tags` and `engagement`; a custom contact field is `custom.<key>`, typed by its definition (see `GET /segments/fields`). Text comparisons ignore case and surrounding spaces. `is_not`, `not_contains` and `neq` also match contacts with no value. A value that does not fit the field's type (text in a number field, a date not written YYYY-MM-DD) is never matched by a comparison. An excluded segment is resolved as it is defined when the audience is resolved, and a segment that others exclude cannot be deleted.
-
template_idinteger or null - Seeds the body from this template when the campaign has none yet.
-
ab_test_enabledboolean -
ab_test_percentageinteger -
ab_winner_metricstring - `opens` or `clicks`. The singular forms are accepted too; responses always use the plural.
-
opensclicksopenclick -
ab_test_delay_minutesinteger
Response
-
dataobject -
data.idinteger -
data.namestring -
data.subjectstring or null -
data.preheaderstring or null -
data.from_namestring or null -
data.from_emailstring or null -
data.reply_tostring or null -
data.statusstring -
draftscheduledscreeningheldqueuingsendingpausedsentpartialcancelledfailed -
data.audienceobject -
data.template_idinteger or null -
data.ab_testobject - `winner_metric` is `opens` or `clicks`, the same values the create and update endpoints accept. `type` is `subject`, `content`, `both` or `send_time`; `send_time_mode` (`winner` or `report`), `timezone` and `remainder_send_at` are only set for a send-time test.
-
data.total_recipientsinteger -
data.sent_countinteger -
data.failed_countinteger -
data.failure_reasonstring or null -
data.scheduled_atstring or null -
data.sent_atstring or null
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X PATCH https://tweak.email/api/v1/campaigns/:campaign \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"August product update","subject":"What's new this month","preheader":"Three things we shipped","from_name":"Jane at Acme","from_email":"hello@acme.com","reply_to":"support@acme.com","audience_source":"list","contact_list_id":7,"segment_id":5}'
Request body
{
"name": "August product update",
"subject": "What's new this month",
"preheader": "Three things we shipped",
"from_name": "Jane at Acme",
"from_email": "hello@acme.com",
"reply_to": "support@acme.com",
"audience_source": "list",
"contact_list_id": 7,
"segment_id": 5
}
Response 200
{
"data": {
"id": 118,
"name": "August product update",
"subject": "What's new this month",
"preheader": "Three things we shipped",
"from_name": "Jane at Acme",
"from_email": "hello@acme.com",
"reply_to": "support@acme.com",
"status": "sent",
"audience": {
"source": "list",
"contact_list_id": 1,
"filters": null
},
"template_id": 12,
"ab_test": {
"enabled": false,
"percentage": 20,
"winner_metric": "opens",
"delay_minutes": 240,
"winner_variant_id": null,
"type": "subject",
"send_time_mode": null,
"timezone": null,
"remainder_send_at": null
},
"total_recipients": 12480,
"sent_count": 12463,
"failed_count": 17,
"failure_reason": null,
"scheduled_at": null,
"sent_at": "2026-08-09T10:00:00+00:00"
}
}
DELETE
/campaigns/{campaign}
Delete a campaign
Requires scope campaigns:write
Path parameters
-
campaigninteger Required - Campaign id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.idinteger -
data.deletedboolean
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X DELETE https://tweak.email/api/v1/campaigns/:campaign \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 42,
"deleted": true
}
}
PUT
/campaigns/{campaign}/content
Set campaign content
Requires scope campaigns:write
Supplying `template_id` copies that template's body in, so a later edit to the template cannot change a campaign somebody already reviewed.
Path parameters
-
campaigninteger Required - Campaign id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
html_contentstring or null -
plain_contentstring or null - Derived from the HTML at send time when omitted.
-
blocks_jsonarray or null - The visual editor's block document, if you build content with it.
-
template_idinteger or null - Copies this template's body in.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.subjectstring or null -
data.preheaderstring or null -
data.from_namestring or null -
data.from_emailstring or null -
data.reply_tostring or null -
data.statusstring -
draftscheduledscreeningheldqueuingsendingpausedsentpartialcancelledfailed -
data.audienceobject -
data.template_idinteger or null -
data.ab_testobject - `winner_metric` is `opens` or `clicks`, the same values the create and update endpoints accept. `type` is `subject`, `content`, `both` or `send_time`; `send_time_mode` (`winner` or `report`), `timezone` and `remainder_send_at` are only set for a send-time test.
-
data.total_recipientsinteger -
data.sent_countinteger -
data.failed_countinteger -
data.failure_reasonstring or null -
data.scheduled_atstring or null -
data.sent_atstring or null
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X PUT https://tweak.email/api/v1/campaigns/:campaign/content \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"html_content":"<p>Hi {{first_name|there}}, here is what we shipped this month.</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>","plain_content":null,"blocks_json":null,"template_id":null}'
Request body
{
"html_content": "<p>Hi {{first_name|there}}, here is what we shipped this month.</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>",
"plain_content": null,
"blocks_json": null,
"template_id": null
}
Response 200
{
"data": {
"id": 118,
"name": "August product update",
"subject": "What's new this month",
"preheader": "Three things we shipped",
"from_name": "Jane at Acme",
"from_email": "hello@acme.com",
"reply_to": "support@acme.com",
"status": "sent",
"audience": {
"source": "list",
"contact_list_id": 1,
"filters": null
},
"template_id": 12,
"ab_test": {
"enabled": false,
"percentage": 20,
"winner_metric": "opens",
"delay_minutes": 240,
"winner_variant_id": null,
"type": "subject",
"send_time_mode": null,
"timezone": null,
"remainder_send_at": null
},
"total_recipients": 12480,
"sent_count": 12463,
"failed_count": 17,
"failure_reason": null,
"scheduled_at": null,
"sent_at": "2026-08-09T10:00:00+00:00"
}
}
POST
/campaigns/{campaign}/variants
Replace the A/B variant set
Requires scope campaigns:write
Variants are replaced wholesale, and A/B testing is switched on. Without `type` this sets up a subject-line test, as it always has. `type: content` or `both` gives each variant its own `html_content` (a variant without one sends the campaign's content); `type: send_time` gives each of two or three groups a `send_at`. A send-time test is started with the send endpoint, which schedules it for its first group's time; the schedule endpoint refuses it.
Path parameters
-
campaigninteger Required - Campaign id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
typestring - What the variants differ in. Defaults to `subject`, which needs a `subject` on every variant.
-
subjectcontentbothsend_time -
send_time_modestring - Send-time tests only. `winner` (default): the groups are a sample, and the rest of the audience gets the winning time on the next sending day. `report`: the whole audience is split across the groups, and nothing else is sent.
-
winnerreport -
timezonestring - Send-time tests only. The timezone the rest of the audience's send time is kept in (the winning group's local time). Defaults to UTC.
-
variantsarray of object Required - Two to four variants; a send-time test takes two or three groups.
-
variants.labelstring Required -
variants.subjectstring - Required for `subject` and `both` tests. Ignored for a send-time test, which sends the campaign's subject.
-
variants.from_namestring -
variants.preheaderstring or null - Content and `both` tests: this variant's preview text.
-
variants.html_contentstring or null - Content and `both` tests: the HTML this variant sends. Without it the variant sends the campaign's content. It is held to the same send checks and screening as the campaign's.
-
variants.plain_contentstring or null - Derived from this variant's HTML at send time when omitted.
-
variants.blocks_jsonarray or null - The visual editor's block document for this variant, stored with `html_content`.
-
variants.send_atstring - Send-time tests: when this group goes out. Must be in the future, at least 15 minutes from the other groups, and within 7 days of the first; otherwise the request is a 422 and nothing is saved.
Response
-
dataarray of object -
data.idinteger -
data.labelstring -
data.subjectstring -
data.from_namestring or null -
data.preheaderstring or null -
data.has_own_contentboolean - True when the variant sends a design of its own (content and `both` tests).
-
data.send_atstring or null - A send-time group's time.
-
data.is_winnerboolean -
data.sentinteger -
data.openedinteger -
data.clickedinteger -
data.open_ratenumber -
data.click_ratenumber -
data.campaign_idinteger - Not on `/report/variants`, which is per campaign already.
-
data.sent_countinteger - Deprecated: use `sent`. The count stored when the winner was picked, 0 before. Not on `/report/variants`.
-
data.open_countinteger - Deprecated: use `opened`. Stored when the winner was picked, 0 before. Not on `/report/variants`.
-
data.click_countinteger - Deprecated: use `clicked`. Stored when the winner was picked, 0 before. Not on `/report/variants`.
-
summaryobject or null - Report endpoint only. `verdict` is `clear`, `too_close`, `too_small` (a compared variant has fewer than 100 recipients) or `no_data`; `note` says the same in a sentence; `decision` is what was recorded when the winner was picked.
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/campaigns/:campaign/variants \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"type":"subject","send_time_mode":"winner","timezone":"Europe/Copenhagen","variants":[{"label":"A","subject":"Three things we shipped in August","from_name":"Jane at Acme"},{"label":"B","subject":"Your August update from Acme","from_name":"Acme"}]}'
Request body
{
"type": "subject",
"send_time_mode": "winner",
"timezone": "Europe/Copenhagen",
"variants": [
{
"label": "A",
"subject": "Three things we shipped in August",
"from_name": "Jane at Acme"
},
{
"label": "B",
"subject": "Your August update from Acme",
"from_name": "Acme"
}
]
}
Response 200
{
"data": [
{
"id": 31,
"label": "A",
"subject": "Three things we shipped in August",
"from_name": "Jane at Acme",
"preheader": null,
"has_own_content": false,
"send_at": null,
"is_winner": true,
"sent": 1248,
"opened": 512,
"clicked": 97,
"open_rate": 41,
"click_rate": 7.8,
"campaign_id": 118,
"sent_count": 1248,
"open_count": 512,
"click_count": 97
}
],
"summary": {
"type": "subject",
"metric": "open",
"verdict": "too_close",
"significant": false,
"z": 1.12,
"leader": "B",
"note": "Too close to call: Variant B is ahead on open rate, but the difference from Variant A could be chance.",
"decision": null
}
}
POST
/campaigns/{campaign}/preflight
Dry-run the send checks
Requires scope campaigns:read
Read-only. Returns every reason a send would currently be refused, plus the estimated recipient count.
Path parameters
-
campaigninteger Required - Campaign id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.campaign_idinteger -
data.statusstring -
data.launchableboolean -
data.blockersarray of string -
data.estimated_recipientsinteger or null - Null for a BigQuery audience, which is resolved at send time.
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/campaigns/:campaign/preflight \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"campaign_id": 118,
"status": "draft",
"launchable": false,
"blockers": [
"The subject line is empty."
],
"estimated_recipients": 12480
}
}
POST
/campaigns/{campaign}/send
Send a campaign
Requires scope campaigns:send
Hands the campaign to abuse screening, which releases it to the send pipeline. Returns 422 with a `blockers` array if any send gate fails.
Send an `Idempotency-Key` header: a retried send is the one mistake in this API that cannot be undone.
Path parameters
-
campaigninteger Required - Campaign id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.subjectstring or null -
data.preheaderstring or null -
data.from_namestring or null -
data.from_emailstring or null -
data.reply_tostring or null -
data.statusstring -
draftscheduledscreeningheldqueuingsendingpausedsentpartialcancelledfailed -
data.audienceobject -
data.template_idinteger or null -
data.ab_testobject - `winner_metric` is `opens` or `clicks`, the same values the create and update endpoints accept. `type` is `subject`, `content`, `both` or `send_time`; `send_time_mode` (`winner` or `report`), `timezone` and `remainder_send_at` are only set for a send-time test.
-
data.total_recipientsinteger -
data.sent_countinteger -
data.failed_countinteger -
data.failure_reasonstring or null -
data.scheduled_atstring or null -
data.sent_atstring or null
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/campaigns/:campaign/send \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 118,
"name": "August product update",
"subject": "What's new this month",
"preheader": "Three things we shipped",
"from_name": "Jane at Acme",
"from_email": "hello@acme.com",
"reply_to": "support@acme.com",
"status": "sent",
"audience": {
"source": "list",
"contact_list_id": 1,
"filters": null
},
"template_id": 12,
"ab_test": {
"enabled": false,
"percentage": 20,
"winner_metric": "opens",
"delay_minutes": 240,
"winner_variant_id": null,
"type": "subject",
"send_time_mode": null,
"timezone": null,
"remainder_send_at": null
},
"total_recipients": 12480,
"sent_count": 12463,
"failed_count": 17,
"failure_reason": null,
"scheduled_at": null,
"sent_at": "2026-08-09T10:00:00+00:00"
}
}
POST
/campaigns/{campaign}/schedule
Schedule a campaign
Requires scope campaigns:send
Runs the same gates as an immediate send. A send-time A/B test is refused here (`send_time_test`): its groups go out at their own times, so start it with the send endpoint.
Path parameters
-
campaigninteger Required - Campaign id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
send_atstring Required - Must be in the future. Interpreted as UTC unless an offset is given.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.subjectstring or null -
data.preheaderstring or null -
data.from_namestring or null -
data.from_emailstring or null -
data.reply_tostring or null -
data.statusstring -
draftscheduledscreeningheldqueuingsendingpausedsentpartialcancelledfailed -
data.audienceobject -
data.template_idinteger or null -
data.ab_testobject - `winner_metric` is `opens` or `clicks`, the same values the create and update endpoints accept. `type` is `subject`, `content`, `both` or `send_time`; `send_time_mode` (`winner` or `report`), `timezone` and `remainder_send_at` are only set for a send-time test.
-
data.total_recipientsinteger -
data.sent_countinteger -
data.failed_countinteger -
data.failure_reasonstring or null -
data.scheduled_atstring or null -
data.sent_atstring or null
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/campaigns/:campaign/schedule \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"send_at":"2027-03-02T09:00:00+01:00"}'
Request body
{
"send_at": "2027-03-02T09:00:00+01:00"
}
Response 200
{
"data": {
"id": 118,
"name": "August product update",
"subject": "What's new this month",
"preheader": "Three things we shipped",
"from_name": "Jane at Acme",
"from_email": "hello@acme.com",
"reply_to": "support@acme.com",
"status": "sent",
"audience": {
"source": "list",
"contact_list_id": 1,
"filters": null
},
"template_id": 12,
"ab_test": {
"enabled": false,
"percentage": 20,
"winner_metric": "opens",
"delay_minutes": 240,
"winner_variant_id": null,
"type": "subject",
"send_time_mode": null,
"timezone": null,
"remainder_send_at": null
},
"total_recipients": 12480,
"sent_count": 12463,
"failed_count": 17,
"failure_reason": null,
"scheduled_at": null,
"sent_at": "2026-08-09T10:00:00+00:00"
}
}
POST
/campaigns/{campaign}/cancel
Cancel a campaign
Requires scope campaigns:send
Only a draft, scheduled, or paused campaign can be cancelled: once chunks are dispatched the messages are already gone.
Path parameters
-
campaigninteger Required - Campaign id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.subjectstring or null -
data.preheaderstring or null -
data.from_namestring or null -
data.from_emailstring or null -
data.reply_tostring or null -
data.statusstring -
draftscheduledscreeningheldqueuingsendingpausedsentpartialcancelledfailed -
data.audienceobject -
data.template_idinteger or null -
data.ab_testobject - `winner_metric` is `opens` or `clicks`, the same values the create and update endpoints accept. `type` is `subject`, `content`, `both` or `send_time`; `send_time_mode` (`winner` or `report`), `timezone` and `remainder_send_at` are only set for a send-time test.
-
data.total_recipientsinteger -
data.sent_countinteger -
data.failed_countinteger -
data.failure_reasonstring or null -
data.scheduled_atstring or null -
data.sent_atstring or null
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/campaigns/:campaign/cancel \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 118,
"name": "August product update",
"subject": "What's new this month",
"preheader": "Three things we shipped",
"from_name": "Jane at Acme",
"from_email": "hello@acme.com",
"reply_to": "support@acme.com",
"status": "sent",
"audience": {
"source": "list",
"contact_list_id": 1,
"filters": null
},
"template_id": 12,
"ab_test": {
"enabled": false,
"percentage": 20,
"winner_metric": "opens",
"delay_minutes": 240,
"winner_variant_id": null,
"type": "subject",
"send_time_mode": null,
"timezone": null,
"remainder_send_at": null
},
"total_recipients": 12480,
"sent_count": 12463,
"failed_count": 17,
"failure_reason": null,
"scheduled_at": null,
"sent_at": "2026-08-09T10:00:00+00:00"
}
}
POST
/campaigns/{campaign}/test
Send test messages
Requires scope campaigns:send
Up to 5 addresses. Counts against the plan's email allowance, because these are real sends. An address that could not be sent to is listed under `failed`.
Path parameters
-
campaigninteger Required - Campaign id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
emailsarray of string Required
Response
-
dataobject -
data.sentarray of string -
data.failedarray of object
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
- 503
- A service this endpoint depends on is temporarily unavailable, for example while sending is paused. Nothing was done; retry later.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/campaigns/:campaign/test \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"emails":["jane@acme.com"]}'
Request body
{
"emails": [
"jane@acme.com"
]
}
Response 200
{
"data": {
"sent": [
"jane@acme.com"
],
"failed": []
}
}
Reporting
Delivery events and campaign performance
GET
/campaigns/{campaign}/report
Campaign performance
Requires scope events:read
Opens exclude machine/bot opens (Apple MPP), so the rates reflect human engagement.
Path parameters
-
campaigninteger Required - Campaign id.
Response
-
dataobject -
data.campaign_idinteger -
data.namestring -
data.subjectstring or null -
data.statusstring -
data.sent_atstring or null -
data.metricsobject
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/campaigns/:campaign/report \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"campaign_id": 118,
"name": "August product update",
"subject": "What's new this month",
"status": "sent",
"sent_at": "2026-08-09T10:00:00+00:00",
"metrics": {
"recipients": 12480,
"sent": 12463,
"delivered": 12301,
"opened": 5238,
"clicked": 1104,
"bounced": 162,
"unsubscribed": 38,
"complained": 3,
"delivery_rate": 98.7,
"open_rate": 42.6,
"click_rate": 9,
"ctor": 21.1,
"bounce_rate": 1.3,
"unsubscribe_rate": 0.3,
"complaint_rate": 0.02
}
}
}
GET
/campaigns/{campaign}/report/links
Per-link click breakdown
Requires scope events:read
Path parameters
-
campaigninteger Required - Campaign id.
Response
-
dataarray of object -
data.urlstring -
data.clicksinteger - Human clicks, with detected bot traffic removed.
-
data.uniqueinteger -
data.botsinteger
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/campaigns/:campaign/report/links \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"url": "https://acme.com/changelog",
"clicks": 412,
"unique": 388,
"bots": 27
}
]
}
GET
/campaigns/{campaign}/report/variants
Per-variant A/B results
Requires scope events:read
Unique opens and clicks per variant (or send-time group), with a `summary` that names the leading variant and says whether its lead is clear: both compared variants sent to at least 100 recipients and a two-proportion z-test at 95 % confidence. Otherwise the verdict is `too_close` or `too_small`.
Path parameters
-
campaigninteger Required - Campaign id.
Response
-
dataarray of object -
data.idinteger -
data.labelstring -
data.subjectstring -
data.from_namestring or null -
data.preheaderstring or null -
data.has_own_contentboolean - True when the variant sends a design of its own (content and `both` tests).
-
data.send_atstring or null - A send-time group's time.
-
data.is_winnerboolean -
data.sentinteger -
data.openedinteger -
data.clickedinteger -
data.open_ratenumber -
data.click_ratenumber -
data.campaign_idinteger - Not on `/report/variants`, which is per campaign already.
-
data.sent_countinteger - Deprecated: use `sent`. The count stored when the winner was picked, 0 before. Not on `/report/variants`.
-
data.open_countinteger - Deprecated: use `opened`. Stored when the winner was picked, 0 before. Not on `/report/variants`.
-
data.click_countinteger - Deprecated: use `clicked`. Stored when the winner was picked, 0 before. Not on `/report/variants`.
-
summaryobject or null - Report endpoint only. `verdict` is `clear`, `too_close`, `too_small` (a compared variant has fewer than 100 recipients) or `no_data`; `note` says the same in a sentence; `decision` is what was recorded when the winner was picked.
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/campaigns/:campaign/report/variants \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 31,
"label": "A",
"subject": "Three things we shipped in August",
"from_name": "Jane at Acme",
"preheader": null,
"has_own_content": false,
"send_at": null,
"is_winner": true,
"sent": 1248,
"opened": 512,
"clicked": 97,
"open_rate": 41,
"click_rate": 7.8,
"campaign_id": 118,
"sent_count": 1248,
"open_count": 512,
"click_count": 97
}
],
"summary": {
"type": "subject",
"metric": "open",
"verdict": "too_close",
"significant": false,
"z": 1.12,
"leader": "B",
"note": "Too close to call: Variant B is ahead on open rate, but the difference from Variant A could be chance.",
"decision": null
}
}
GET
/campaigns/{campaign}/recipients
Per-recipient delivery detail
Requires scope events:read
Who received the campaign and whether they opened or clicked.
Path parameters
-
campaigninteger Required - Campaign id.
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
-
filterstring - Narrow to a delivery outcome.
-
allopenedclickedbouncedpendingsent
Response
-
dataarray of object -
data.contact_idinteger or null -
data.emailstring or null -
data.statusstring -
data.sent_atstring or null -
data.opened_atstring or null -
data.clicked_atstring or null -
data.error_messagestring or null -
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/campaigns/:campaign/recipients \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"contact_id": 42,
"email": "jane@example.com",
"status": "sent",
"sent_at": "2026-08-09 10:00:02",
"opened_at": "2026-08-09 11:42:17",
"clicked_at": null,
"error_message": null
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
GET
/events
List delivery events
Requires scope events:read
The read side of the event pipeline, bounded by a 180-day retention window. Machine opens are excluded unless explicitly requested.
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
-
eventstring - Filter by event type.
-
deliveredbounceddeferreddroppedspam_reportunsubscribedopenedclickedqueuedsent -
emailstring - Filter by recipient address.
-
campaign_idinteger - Filter by campaign.
-
contact_idinteger - Filter by contact.
-
sincestring - ISO 8601 lower bound.
-
untilstring - ISO 8601 upper bound.
-
include_machine_opensboolean - Include Apple MPP and bot prefetch opens.
Response
-
dataarray of object -
data.idinteger -
data.emailstring -
data.eventstring -
data.campaign_idinteger or null -
data.contact_idinteger or null -
data.providerstring or null - "tweak.email" for mail sent through the built-in sender, otherwise the provider you connected (for example "sendgrid").
-
data.sourcestring or null -
data.is_machine_openboolean -
data.message_idstring or null - The `message_id` /send returned, on the events of a transactional message; null otherwise.
-
data.metadataobject -
data.created_atstring or null -
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/events \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 90211,
"email": "jane@example.com",
"event": "clicked",
"campaign_id": 118,
"contact_id": 42,
"provider": "tweak.email",
"source": "webhook",
"is_machine_open": false,
"message_id": null,
"metadata": {
"url": "https://acme.com/changelog"
},
"created_at": "2026-08-09T10:04:12+00:00"
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/events
Ingest delivery events
Requires scope events:write
For mail you send outside tweak.email: report its delivery events (delivered, bounced, opened, clicked, unsubscribed and the other types listed) so they count in your reports and suppressions. Only these delivery event types are accepted; this is not a way to send custom product events. To start a sequence from your own backend, add a tag to the contact (`POST /contacts/{contact}/tags`) and use a sequence triggered by that tag.
Up to 1,000 per call. Events flow through the same pipeline as provider webhooks: campaign stats update, suppressions are created, contact statuses sync.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
eventsarray of object Required -
events.emailstring Required -
events.eventstring Required - A delivery event type. Nothing else is accepted.
-
deliveredbounceddeferreddroppedspam_reportunsubscribedopenedclickedqueuedsent -
events.campaign_idinteger or null - Ignored unless it is one of your campaigns.
-
events.contact_idinteger or null - Ignored unless it is one of your contacts.
-
events.providerstring - Your name for the system that sent the message.
-
events.sourcestring - Defaults to `api`.
-
events.metadataobject
Response
-
dataobject -
data.processedinteger -
statusstring - Deprecated: read `data` instead. Kept for existing integrations.
-
processedinteger - Deprecated: read `data.processed` instead.
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/events \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"events":[{"email":"jane@example.com","event":"delivered","campaign_id":null,"contact_id":42,"provider":"own-smtp","source":"api","metadata":{"smtp_response":"250 2.0.0 OK"}}]}'
Request body
{
"events": [
{
"email": "jane@example.com",
"event": "delivered",
"campaign_id": null,
"contact_id": 42,
"provider": "own-smtp",
"source": "api",
"metadata": {
"smtp_response": "250 2.0.0 OK"
}
}
]
}
Response 200
{
"data": {
"processed": 2
},
"status": "ok",
"processed": 2
}
POST
/conversions
Report a conversion
Requires scope events:write
A purchase, booking or sign-up an email led to. It is credited to `campaign_id` when that is one of your campaigns; otherwise to the campaign whose link the address clicked most recently within 7 days before `occurred_at`; otherwise to no campaign (`attribution: none`). Conversions appear in the campaign report in the app.
Send the same `order_id` again and nothing is counted twice: the first record is returned unchanged with a 200. A conversion without an `order_id` is recorded every time it is reported.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
emailstring Required - The address of the person who converted.
-
campaign_idinteger or null - Credit this campaign. Ignored unless it is one of your campaigns; the last click then decides.
-
valuenumber or null - What the conversion was worth, such as the order total.
-
currencystring or null - Three-letter currency code of `value`. Revenue is reported per currency, never added across currencies.
-
order_idstring or null - Your reference for the order. A conversion with the same `order_id` is recorded once.
-
occurred_atstring or null - When it happened. Defaults to now; cannot be in the future.
Response
- 201
- The conversion was recorded.
- 200
- A conversion with this `order_id` was already on record; it is returned unchanged.
-
dataobject -
data.idinteger -
data.emailstring -
data.campaign_idinteger or null - The campaign the conversion is credited to, or null.
-
data.contact_idinteger or null - The contact with this address, when there is one.
-
data.valuenumber or null -
data.currencystring or null -
data.order_idstring or null -
data.sourcestring - How the conversion was reported.
-
apipixelshopify -
data.attributionstring - `explicit`: you named the campaign. `last_click`: the campaign of the address's last click. `none`: no campaign.
-
explicitlast_clicknone -
data.occurred_atstring or null -
data.created_atstring or null
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/conversions \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email":"jane@example.com","campaign_id":12,"value":499,"currency":"DKK","order_id":"4417","occurred_at":"2026-08-09T10:04:12+00:00"}'
Request body
{
"email": "jane@example.com",
"campaign_id": 12,
"value": 499,
"currency": "DKK",
"order_id": "4417",
"occurred_at": "2026-08-09T10:04:12+00:00"
}
Response 201
{
"data": {
"id": 318,
"email": "jane@example.com",
"campaign_id": 12,
"contact_id": 42,
"value": 499,
"currency": "DKK",
"order_id": "4417",
"source": "api",
"attribution": "last_click",
"occurred_at": "2026-08-09T10:04:12+00:00",
"created_at": "2026-08-09T10:04:15+00:00"
}
}
Templates
Reusable email templates
GET
/templates
List templates
Requires scope campaigns:read
Includes the platform's system starter templates alongside your own.
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
-
scopestring - Which templates to return.
-
allsystemteam -
categorystring - Filter by category.
Response
-
dataarray of object -
data.idinteger -
data.namestring -
data.categorystring or null -
data.stylestring or null -
data.descriptionstring or null -
data.is_systemboolean -
data.html_contentstring or null - Only returned when fetching a single template.
-
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/templates \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 12,
"name": "Monthly newsletter",
"category": "newsletter",
"style": "clean",
"description": "One column, a hero image and three stories",
"is_system": false,
"html_content": "<p>Hello {{first_name|there}}</p>"
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/templates
Create a template
Requires scope campaigns:write
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
namestring Required -
categorystring -
promonewsletterwelcomelauncheventtransactionalgeneralseasonal -
stylestring -
cleanmoderneditorialboldcommercepersonaldarkseasonalcustom -
descriptionstring -
html_contentstring -
blocks_jsonarray or null - The visual editor's block document, if you build content with it.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.categorystring or null -
data.stylestring or null -
data.descriptionstring or null -
data.is_systemboolean -
data.html_contentstring or null - Only returned when fetching a single template.
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/templates \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Monthly newsletter","category":"newsletter","style":"clean","description":"One column, a hero image and three stories","html_content":"<p>Hello {{first_name|there}}</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>","blocks_json":null}'
Request body
{
"name": "Monthly newsletter",
"category": "newsletter",
"style": "clean",
"description": "One column, a hero image and three stories",
"html_content": "<p>Hello {{first_name|there}}</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>",
"blocks_json": null
}
Response 201
{
"data": {
"id": 12,
"name": "Monthly newsletter",
"category": "newsletter",
"style": "clean",
"description": "One column, a hero image and three stories",
"is_system": false,
"html_content": "<p>Hello {{first_name|there}}</p>"
}
}
GET
/templates/{template}
Fetch a template
Requires scope campaigns:read
Unlike the listing, this includes the full body.
Path parameters
-
templateinteger Required - Template id.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.categorystring or null -
data.stylestring or null -
data.descriptionstring or null -
data.is_systemboolean -
data.html_contentstring or null - Only returned when fetching a single template.
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/templates/:template \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 12,
"name": "Monthly newsletter",
"category": "newsletter",
"style": "clean",
"description": "One column, a hero image and three stories",
"is_system": false,
"html_content": "<p>Hello {{first_name|there}}</p>"
}
}
PATCH
/templates/{template}
Update a template
Requires scope campaigns:write
System templates cannot be modified.
Path parameters
-
templateinteger Required - Template id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
namestring Required -
categorystring -
promonewsletterwelcomelauncheventtransactionalgeneralseasonal -
stylestring -
cleanmoderneditorialboldcommercepersonaldarkseasonalcustom -
descriptionstring -
html_contentstring -
blocks_jsonarray or null - The visual editor's block document, if you build content with it.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.categorystring or null -
data.stylestring or null -
data.descriptionstring or null -
data.is_systemboolean -
data.html_contentstring or null - Only returned when fetching a single template.
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X PATCH https://tweak.email/api/v1/templates/:template \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Monthly newsletter","category":"newsletter","style":"clean","description":"One column, a hero image and three stories","html_content":"<p>Hello {{first_name|there}}</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>","blocks_json":null}'
Request body
{
"name": "Monthly newsletter",
"category": "newsletter",
"style": "clean",
"description": "One column, a hero image and three stories",
"html_content": "<p>Hello {{first_name|there}}</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>",
"blocks_json": null
}
Response 200
{
"data": {
"id": 12,
"name": "Monthly newsletter",
"category": "newsletter",
"style": "clean",
"description": "One column, a hero image and three stories",
"is_system": false,
"html_content": "<p>Hello {{first_name|there}}</p>"
}
}
DELETE
/templates/{template}
Delete a template
Requires scope campaigns:write
Path parameters
-
templateinteger Required - Template id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.idinteger -
data.deletedboolean
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X DELETE https://tweak.email/api/v1/templates/:template \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 42,
"deleted": true
}
}
Sequences
Automated sequences and enrolment
GET
/sequences
List sequences
Requires scope campaigns:read
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
Response
-
dataarray of object -
data.idinteger -
data.namestring -
data.descriptionstring or null -
data.statusstring -
data.trigger_typestring or null - `tag_added` sequences start when the trigger tag is added to a contact, including through `POST /contacts/{contact}/tags`.
-
data.trigger_tag_idinteger or null -
data.trigger_list_idsarray of integer - For the signup trigger: the lists it is limited to; empty means any list.
-
data.exit_conditionsarray of object -
data.emailsarray of object - On a single sequence: the e-mail steps in order (id, position, subject, delay_days, delay_hours).
-
data.stepsarray of object - On a single sequence: the main path of the step tree. E-mail bodies are not included.
-
data.step_problemsarray of string - On a single sequence: what has to be fixed before it can be activated. Empty when the steps are ready.
-
data.subscribers_countinteger -
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/sequences \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 3,
"name": "Onboarding",
"description": "Five emails over the first two weeks",
"status": "active",
"trigger_type": "tag_added",
"trigger_tag_id": 7,
"trigger_list_ids": [],
"exit_conditions": [
{
"kind": "tag",
"tag_id": 9
}
],
"emails": [
{
"id": 11,
"position": 0,
"subject": "Welcome aboard",
"delay_days": 0,
"delay_hours": 0
}
],
"steps": [
{
"id": 11,
"ref": "welcome",
"type": "email",
"subject": "Welcome aboard",
"html_content": "<p>Hi {{first_name|there}}</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>",
"plain_content": null,
"delay_days": 0,
"delay_hours": 0,
"wait": {
"mode": "until",
"days": 2,
"hours": 0,
"weekdays": [
1,
3
],
"time": "09:00",
"timezone": "Europe/Copenhagen"
},
"condition": {
"kind": "tag",
"tag_id": 9,
"list_id": 4,
"segment_id": 5,
"rule": {
"field": "custom.orders_count",
"type": "number",
"operator": "gte",
"value": 1
},
"timezone": "Europe/Copenhagen",
"step_id": 11,
"step_ref": "welcome",
"within_hours": 72
},
"yes": [
{
"type": "exit"
}
],
"no": [
{
"type": "email",
"subject": "In case you missed it",
"html_content": "<p>A quick reminder.</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>"
}
]
}
],
"step_problems": [
"Step 3: the \"no\" path is empty. Add a step to it, or an exit step to end the sequence there."
],
"subscribers_count": 380
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/sequences
Create a sequence
Requires scope campaigns:write
Creates a draft that sends nothing; it is activated in the app, after the same checks as a campaign launch. Give the steps either as `emails` (a plain list of e-mails, each with its delay since the previous step) or as `steps`, the tree: `email`, `wait`, `condition` (with a `yes` and a `no` path) and `exit` steps. A condition or exit is the last step of its path, and conditions nest at most 3 deep. A condition about an earlier e-mail names it by `step_id`, or by `step_ref`: the `ref` you gave that e-mail earlier in the same request.
`exit_conditions` take a contact out of the sequence as soon as one is true (a tag, a list, a saved segment, a contact-field rule, or a click in any of its e-mails); unsubscribing always does. The response lists in `step_problems` what still has to be fixed before the sequence can be activated.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
namestring Required -
descriptionstring or null -
trigger_typestring -
manualsignuptag_added -
trigger_tag_idinteger or null - For `tag_added`: the tag that enrols; null for any tag.
-
trigger_list_idsarray or null - For `signup`: limit it to signups to these lists.
-
exit_conditionsarray or null - Up to 10. Kinds: `tag`, `list`, `segment`, `field`, `clicked` (any e-mail of the sequence).
-
emailsarray of object - The linear shape: e-mails in order, each with `subject`, `html_content` (with an unsubscribe link), and optionally `plain_content`, `delay_days`, `delay_hours` and, on update, `id`.
-
stepsarray of object - The tree shape: the main path, with each condition's `yes` and `no` paths inside it. At most 60 steps in all.
-
steps.idinteger - On update: the existing step this node keeps.
-
steps.refstring - Your own name for the step within this request, for a later condition's `step_ref`.
-
steps.typestring -
emailwaitconditionexit -
steps.subjectstring - E-mail: the subject line.
-
steps.html_contentstring - E-mail: the body, with an `{{unsubscribe_url}}` link. Not included in responses.
-
steps.plain_contentstring or null - E-mail: the text part; generated from the HTML when left out.
-
steps.delay_daysinteger - E-mail: days to wait after the contact reaches this step.
-
steps.delay_hoursinteger - E-mail: additional hours, 0 to 23.
-
steps.waitobject - `duration`: `days` and `hours` (at least one hour in all). `until`: the next chosen weekday (`weekdays`, ISO 1 = Monday to 7 = Sunday; none means any day) at `time` (HH:MM) on the clock of `timezone`, across daylight-saving changes.
-
steps.conditionobject - What a condition step or an exit condition checks. `tag`: has `tag_id`. `list`: is subscribed to `list_id`. `segment`: matches the saved segment `segment_id`. `field`: matches `rule`, one condition in the segment rule format (see `GET /segments/fields`), custom fields included. Condition steps only: `opened` or `clicked` the e-mail `step_id` (or `step_ref`) within `within_hours` of it being sent (0: by the time the contact reaches the condition); contacts wait at the condition until they engage or the time is up. Exit conditions only: `clicked`, a click in any e-mail of the sequence.
-
steps.yesarray of object - Condition: the steps for contacts it is true for, in this same shape.
-
steps.noarray of object - Condition: the steps for everyone else, in this same shape.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.descriptionstring or null -
data.statusstring -
data.trigger_typestring or null - `tag_added` sequences start when the trigger tag is added to a contact, including through `POST /contacts/{contact}/tags`.
-
data.trigger_tag_idinteger or null -
data.trigger_list_idsarray of integer - For the signup trigger: the lists it is limited to; empty means any list.
-
data.exit_conditionsarray of object -
data.emailsarray of object - On a single sequence: the e-mail steps in order (id, position, subject, delay_days, delay_hours).
-
data.stepsarray of object - On a single sequence: the main path of the step tree. E-mail bodies are not included.
-
data.step_problemsarray of string - On a single sequence: what has to be fixed before it can be activated. Empty when the steps are ready.
-
data.subscribers_countinteger
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/sequences \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Welcome series","trigger_type":"signup","exit_conditions":[{"kind":"tag","tag_id":9}],"steps":[{"ref":"welcome","type":"email","subject":"Welcome aboard","html_content":"<p>Hi {{first_name|there}}</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>","delay_days":0},{"type":"condition","condition":{"kind":"clicked","step_ref":"welcome","within_hours":72},"yes":[{"type":"email","subject":"Glad you had a look","html_content":"<p>Here is what to try next.</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>"}],"no":[{"type":"wait","wait":{"mode":"until","weekdays":[2],"time":"09:00","timezone":"Europe/Copenhagen"}},{"type":"email","subject":"In case you missed it","html_content":"<p>A quick reminder.</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>"}]}]}'
Request body
{
"name": "Welcome series",
"trigger_type": "signup",
"exit_conditions": [
{
"kind": "tag",
"tag_id": 9
}
],
"steps": [
{
"ref": "welcome",
"type": "email",
"subject": "Welcome aboard",
"html_content": "<p>Hi {{first_name|there}}</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>",
"delay_days": 0
},
{
"type": "condition",
"condition": {
"kind": "clicked",
"step_ref": "welcome",
"within_hours": 72
},
"yes": [
{
"type": "email",
"subject": "Glad you had a look",
"html_content": "<p>Here is what to try next.</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>"
}
],
"no": [
{
"type": "wait",
"wait": {
"mode": "until",
"weekdays": [
2
],
"time": "09:00",
"timezone": "Europe/Copenhagen"
}
},
{
"type": "email",
"subject": "In case you missed it",
"html_content": "<p>A quick reminder.</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>"
}
]
}
]
}
Response 201
{
"data": {
"id": 3,
"name": "Onboarding",
"description": "Five emails over the first two weeks",
"status": "active",
"trigger_type": "tag_added",
"trigger_tag_id": 7,
"trigger_list_ids": [],
"exit_conditions": [
{
"kind": "tag",
"tag_id": 9
}
],
"emails": [
{
"id": 11,
"position": 0,
"subject": "Welcome aboard",
"delay_days": 0,
"delay_hours": 0
}
],
"steps": [
{
"id": 11,
"ref": "welcome",
"type": "email",
"subject": "Welcome aboard",
"html_content": "<p>Hi {{first_name|there}}</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>",
"plain_content": null,
"delay_days": 0,
"delay_hours": 0,
"wait": {
"mode": "until",
"days": 2,
"hours": 0,
"weekdays": [
1,
3
],
"time": "09:00",
"timezone": "Europe/Copenhagen"
},
"condition": {
"kind": "tag",
"tag_id": 9,
"list_id": 4,
"segment_id": 5,
"rule": {
"field": "custom.orders_count",
"type": "number",
"operator": "gte",
"value": 1
},
"timezone": "Europe/Copenhagen",
"step_id": 11,
"step_ref": "welcome",
"within_hours": 72
},
"yes": [
{
"type": "exit"
}
],
"no": [
{
"type": "email",
"subject": "In case you missed it",
"html_content": "<p>A quick reminder.</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>"
}
]
}
],
"step_problems": [
"Step 3: the \"no\" path is empty. Add a step to it, or an exit step to end the sequence there."
],
"subscribers_count": 380
}
}
GET
/sequences/{sequence}
Fetch a sequence
Requires scope campaigns:read
`emails` lists the e-mail steps in order, as before conditions existed; `steps` is the whole tree. `step_problems` lists what still has to be fixed before the sequence can be activated.
Path parameters
-
sequenceinteger Required - Sequence id.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.descriptionstring or null -
data.statusstring -
data.trigger_typestring or null - `tag_added` sequences start when the trigger tag is added to a contact, including through `POST /contacts/{contact}/tags`.
-
data.trigger_tag_idinteger or null -
data.trigger_list_idsarray of integer - For the signup trigger: the lists it is limited to; empty means any list.
-
data.exit_conditionsarray of object -
data.emailsarray of object - On a single sequence: the e-mail steps in order (id, position, subject, delay_days, delay_hours).
-
data.stepsarray of object - On a single sequence: the main path of the step tree. E-mail bodies are not included.
-
data.step_problemsarray of string - On a single sequence: what has to be fixed before it can be activated. Empty when the steps are ready.
-
data.subscribers_countinteger
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/sequences/:sequence \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 3,
"name": "Onboarding",
"description": "Five emails over the first two weeks",
"status": "active",
"trigger_type": "tag_added",
"trigger_tag_id": 7,
"trigger_list_ids": [],
"exit_conditions": [
{
"kind": "tag",
"tag_id": 9
}
],
"emails": [
{
"id": 11,
"position": 0,
"subject": "Welcome aboard",
"delay_days": 0,
"delay_hours": 0
}
],
"steps": [
{
"id": 11,
"ref": "welcome",
"type": "email",
"subject": "Welcome aboard",
"html_content": "<p>Hi {{first_name|there}}</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>",
"plain_content": null,
"delay_days": 0,
"delay_hours": 0,
"wait": {
"mode": "until",
"days": 2,
"hours": 0,
"weekdays": [
1,
3
],
"time": "09:00",
"timezone": "Europe/Copenhagen"
},
"condition": {
"kind": "tag",
"tag_id": 9,
"list_id": 4,
"segment_id": 5,
"rule": {
"field": "custom.orders_count",
"type": "number",
"operator": "gte",
"value": 1
},
"timezone": "Europe/Copenhagen",
"step_id": 11,
"step_ref": "welcome",
"within_hours": 72
},
"yes": [
{
"type": "exit"
}
],
"no": [
{
"type": "email",
"subject": "In case you missed it",
"html_content": "<p>A quick reminder.</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>"
}
]
}
],
"step_problems": [
"Step 3: the \"no\" path is empty. Add a step to it, or an exit step to end the sequence there."
],
"subscribers_count": 380
}
}
PATCH
/sequences/{sequence}
Update a sequence
Requires scope campaigns:write
Fields you leave out keep their value. Sending `steps` (or `emails`) replaces the whole step tree: a node with the `id` of one of the sequence's steps, of the same type, updates that step and keeps the contacts on it; an e-mail node with an `id` may leave out its content to keep it. Steps you leave out are removed, and contacts waiting on one move to the next kept step on the same path, or finish the sequence when there is none. A contact never receives the same e-mail twice.
An active sequence keeps sending while it changes, so its paths must stay complete: otherwise the request is refused with 422 `sequence_incomplete` and a `problems` list.
Path parameters
-
sequenceinteger Required - Sequence id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
namestring Required -
descriptionstring or null -
trigger_typestring -
manualsignuptag_added -
trigger_tag_idinteger or null - For `tag_added`: the tag that enrols; null for any tag.
-
trigger_list_idsarray or null - For `signup`: limit it to signups to these lists.
-
exit_conditionsarray or null - Up to 10. Kinds: `tag`, `list`, `segment`, `field`, `clicked` (any e-mail of the sequence).
-
emailsarray of object - The linear shape: e-mails in order, each with `subject`, `html_content` (with an unsubscribe link), and optionally `plain_content`, `delay_days`, `delay_hours` and, on update, `id`.
-
stepsarray of object - The tree shape: the main path, with each condition's `yes` and `no` paths inside it. At most 60 steps in all.
-
steps.idinteger - On update: the existing step this node keeps.
-
steps.refstring - Your own name for the step within this request, for a later condition's `step_ref`.
-
steps.typestring -
emailwaitconditionexit -
steps.subjectstring - E-mail: the subject line.
-
steps.html_contentstring - E-mail: the body, with an `{{unsubscribe_url}}` link. Not included in responses.
-
steps.plain_contentstring or null - E-mail: the text part; generated from the HTML when left out.
-
steps.delay_daysinteger - E-mail: days to wait after the contact reaches this step.
-
steps.delay_hoursinteger - E-mail: additional hours, 0 to 23.
-
steps.waitobject - `duration`: `days` and `hours` (at least one hour in all). `until`: the next chosen weekday (`weekdays`, ISO 1 = Monday to 7 = Sunday; none means any day) at `time` (HH:MM) on the clock of `timezone`, across daylight-saving changes.
-
steps.conditionobject - What a condition step or an exit condition checks. `tag`: has `tag_id`. `list`: is subscribed to `list_id`. `segment`: matches the saved segment `segment_id`. `field`: matches `rule`, one condition in the segment rule format (see `GET /segments/fields`), custom fields included. Condition steps only: `opened` or `clicked` the e-mail `step_id` (or `step_ref`) within `within_hours` of it being sent (0: by the time the contact reaches the condition); contacts wait at the condition until they engage or the time is up. Exit conditions only: `clicked`, a click in any e-mail of the sequence.
-
steps.yesarray of object - Condition: the steps for contacts it is true for, in this same shape.
-
steps.noarray of object - Condition: the steps for everyone else, in this same shape.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.descriptionstring or null -
data.statusstring -
data.trigger_typestring or null - `tag_added` sequences start when the trigger tag is added to a contact, including through `POST /contacts/{contact}/tags`.
-
data.trigger_tag_idinteger or null -
data.trigger_list_idsarray of integer - For the signup trigger: the lists it is limited to; empty means any list.
-
data.exit_conditionsarray of object -
data.emailsarray of object - On a single sequence: the e-mail steps in order (id, position, subject, delay_days, delay_hours).
-
data.stepsarray of object - On a single sequence: the main path of the step tree. E-mail bodies are not included.
-
data.step_problemsarray of string - On a single sequence: what has to be fixed before it can be activated. Empty when the steps are ready.
-
data.subscribers_countinteger
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X PATCH https://tweak.email/api/v1/sequences/:sequence \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Welcome series","trigger_type":"signup","exit_conditions":[{"kind":"tag","tag_id":9}],"steps":[{"ref":"welcome","type":"email","subject":"Welcome aboard","html_content":"<p>Hi {{first_name|there}}</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>","delay_days":0},{"type":"condition","condition":{"kind":"clicked","step_ref":"welcome","within_hours":72},"yes":[{"type":"email","subject":"Glad you had a look","html_content":"<p>Here is what to try next.</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>"}],"no":[{"type":"wait","wait":{"mode":"until","weekdays":[2],"time":"09:00","timezone":"Europe/Copenhagen"}},{"type":"email","subject":"In case you missed it","html_content":"<p>A quick reminder.</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>"}]}]}'
Request body
{
"name": "Welcome series",
"trigger_type": "signup",
"exit_conditions": [
{
"kind": "tag",
"tag_id": 9
}
],
"steps": [
{
"ref": "welcome",
"type": "email",
"subject": "Welcome aboard",
"html_content": "<p>Hi {{first_name|there}}</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>",
"delay_days": 0
},
{
"type": "condition",
"condition": {
"kind": "clicked",
"step_ref": "welcome",
"within_hours": 72
},
"yes": [
{
"type": "email",
"subject": "Glad you had a look",
"html_content": "<p>Here is what to try next.</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>"
}
],
"no": [
{
"type": "wait",
"wait": {
"mode": "until",
"weekdays": [
2
],
"time": "09:00",
"timezone": "Europe/Copenhagen"
}
},
{
"type": "email",
"subject": "In case you missed it",
"html_content": "<p>A quick reminder.</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>"
}
]
}
]
}
Response 200
{
"data": {
"id": 3,
"name": "Onboarding",
"description": "Five emails over the first two weeks",
"status": "active",
"trigger_type": "tag_added",
"trigger_tag_id": 7,
"trigger_list_ids": [],
"exit_conditions": [
{
"kind": "tag",
"tag_id": 9
}
],
"emails": [
{
"id": 11,
"position": 0,
"subject": "Welcome aboard",
"delay_days": 0,
"delay_hours": 0
}
],
"steps": [
{
"id": 11,
"ref": "welcome",
"type": "email",
"subject": "Welcome aboard",
"html_content": "<p>Hi {{first_name|there}}</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>",
"plain_content": null,
"delay_days": 0,
"delay_hours": 0,
"wait": {
"mode": "until",
"days": 2,
"hours": 0,
"weekdays": [
1,
3
],
"time": "09:00",
"timezone": "Europe/Copenhagen"
},
"condition": {
"kind": "tag",
"tag_id": 9,
"list_id": 4,
"segment_id": 5,
"rule": {
"field": "custom.orders_count",
"type": "number",
"operator": "gte",
"value": 1
},
"timezone": "Europe/Copenhagen",
"step_id": 11,
"step_ref": "welcome",
"within_hours": 72
},
"yes": [
{
"type": "exit"
}
],
"no": [
{
"type": "email",
"subject": "In case you missed it",
"html_content": "<p>A quick reminder.</p><p><a href=\"{{unsubscribe_url}}\">Unsubscribe</a></p>"
}
]
}
],
"step_problems": [
"Step 3: the \"no\" path is empty. Add a step to it, or an exit step to end the sequence there."
],
"subscribers_count": 380
}
}
GET
/sequences/{sequence}/subscribers
List subscribers
Requires scope campaigns:read
Path parameters
-
sequenceinteger Required - Sequence id.
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
Response
-
dataarray of object -
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/sequences/:sequence/subscribers \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/sequences/{sequence}/subscribers
Enrol contacts
Requires scope contacts:write
Accepts contact ids or email addresses. This is how you trigger onboarding from your own signup flow.
Path parameters
-
sequenceinteger Required - Sequence id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
contact_idsarray of integer -
emailsarray of string
Response
-
dataobject -
data.sequence_idinteger -
data.matchedinteger -
data.enrolledinteger -
data.skippedinteger - Matched but not eligible: already enrolled, unsubscribed, or bounced.
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/sequences/:sequence/subscribers \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"emails":["jane@example.com"]}'
Request body
{
"emails": [
"jane@example.com"
]
}
Response 200
{
"data": {
"sequence_id": 3,
"matched": 2,
"enrolled": 1,
"skipped": 1
}
}
DELETE
/sequences/{sequence}/subscribers/{contact}
Remove a contact from a sequence
Requires scope contacts:write
Stops any pending steps. `removed` is false when the contact was not enrolled.
Path parameters
-
sequenceinteger Required - Sequence id.
-
contactinteger Required - Contact id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.sequence_idinteger -
data.contact_idinteger -
data.removedboolean
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X DELETE https://tweak.email/api/v1/sequences/:sequence/subscribers/:contact \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"sequence_id": 3,
"contact_id": 42,
"removed": true
}
}
Waitlists
Waitlists and signups
GET
/waitlists
List waitlists
Requires scope contacts:read
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
Response
-
dataarray of object -
data.idinteger -
data.namestring -
data.slugstring -
data.statusstring -
activepausedclosed -
data.public_urlstring -
data.signups_countinteger -
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/waitlists \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 2,
"name": "Beta access",
"slug": "beta-access",
"status": "active",
"public_url": "https://tweak.email/w/beta-access",
"signups_count": 1840
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
GET
/waitlists/{waitlist}
Fetch a waitlist
Requires scope contacts:read
Path parameters
-
waitlistinteger Required - Waitlist id.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.slugstring -
data.statusstring -
activepausedclosed -
data.public_urlstring -
data.signups_countinteger
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/waitlists/:waitlist \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 2,
"name": "Beta access",
"slug": "beta-access",
"status": "active",
"public_url": "https://tweak.email/w/beta-access",
"signups_count": 1840
}
}
GET
/waitlists/{waitlist}/signups
List signups
Requires scope contacts:read
Path parameters
-
waitlistinteger Required - Waitlist id.
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
Response
-
dataarray of object -
data.idinteger -
data.emailstring -
data.namestring or null -
data.positioninteger or null -
data.statusstring -
waitinginvitedconverted -
data.referral_codestring -
data.referrals_countinteger -
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/waitlists/:waitlist/signups \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 501,
"email": "jane@example.com",
"name": "Jane Okonkwo",
"position": 17,
"status": "waiting",
"referral_code": "K7P2QX",
"referrals_count": 2
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/waitlists/{waitlist}/signups
Add a signup
Requires scope contacts:write
Queue position is assigned server-side. A signup is added to the waitlist's linked contact list only with `marketing_consent`.
Path parameters
-
waitlistinteger Required - Waitlist id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
emailstring Required -
namestring -
referral_codestring - The referring signup's code, if this signup came through a referral.
-
metadataobject -
marketing_consentboolean - True only when the person ticked a box asking for your news and offers by email as well as joining the waitlist. When the waitlist is linked to a contact list, only these signups are added to it, and they are sent a confirmation email first. Left out or false, the person is on the waitlist only and is sent nothing.
-
marketing_consent_textstring - The exact wording of the box the person ticked. Stored with its hash as their consent record.
Response
- 201
- Signed up.
- 200
- The address was already on the waitlist; its existing signup is returned.
-
dataobject -
data.idinteger -
data.emailstring -
data.namestring or null -
data.positioninteger or null -
data.statusstring -
waitinginvitedconverted -
data.referral_codestring -
data.referrals_countinteger
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/waitlists/:waitlist/signups \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email":"jane@example.com","name":"Jane Okonkwo","referral_code":"K7P2QX","metadata":{"source":"launch-page"},"marketing_consent":true,"marketing_consent_text":"Also send me news and offers from Acme by email. I can unsubscribe at any time."}'
Request body
{
"email": "jane@example.com",
"name": "Jane Okonkwo",
"referral_code": "K7P2QX",
"metadata": {
"source": "launch-page"
},
"marketing_consent": true,
"marketing_consent_text": "Also send me news and offers from Acme by email. I can unsubscribe at any time."
}
Response 201
{
"data": {
"id": 501,
"email": "jane@example.com",
"name": "Jane Okonkwo",
"position": 17,
"status": "waiting",
"referral_code": "K7P2QX",
"referrals_count": 2
}
}
POST
/waitlists/{waitlist}/invite
Invite signups
Requires scope contacts:write
Either specific ids, or `count` to take the next N from the front of the queue.
Path parameters
-
waitlistinteger Required - Waitlist id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
signup_idsarray of integer -
countinteger - Invite the next N by queue position. Use instead of `signup_ids`.
Response
-
dataobject -
data.waitlist_idinteger -
data.invitedinteger -
data.signup_idsarray of integer
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/waitlists/:waitlist/invite \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"signup_ids":[501,502]}'
Request body
{
"signup_ids": [
501,
502
]
}
Response 200
{
"data": {
"waitlist_id": 2,
"invited": 2,
"signup_ids": [
501,
502
]
}
}
Suppressions
The do-not-mail list
GET
/suppressions
List suppressions
Requires scope suppressions:read
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
-
reasonstring - Filter by reason.
-
hard_bouncesoft_bouncespam_reportunsubscribemanual -
emailstring - Exact address match.
Response
-
dataarray of object -
data.idinteger -
data.emailstring -
data.reasonstring -
hard_bouncesoft_bouncespam_reportunsubscribemanual -
data.sourcestring or null - Where the suppression came from, for example `api` for one added through the API.
-
data.campaign_idinteger or null -
data.metadataobject or null -
data.created_atstring or null -
data.updated_atstring or null -
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/suppressions \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 77,
"email": "former-customer@example.com",
"reason": "manual",
"source": "api",
"campaign_id": null,
"metadata": {
"note": "Asked by phone not to be emailed"
},
"created_at": "2026-08-09T10:04:12+00:00",
"updated_at": "2026-08-09T10:04:12+00:00"
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/suppressions
Add a suppression
Requires scope suppressions:write
Upserts on address.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
emailstring Required -
reasonstring Required -
hard_bouncespam_reportunsubscribemanual -
metadataobject
Response
- 201
- The address was added.
- 200
- The address was already suppressed; its reason and metadata were updated.
-
dataobject -
data.idinteger -
data.emailstring -
data.reasonstring -
hard_bouncesoft_bouncespam_reportunsubscribemanual -
data.sourcestring or null - Where the suppression came from, for example `api` for one added through the API.
-
data.campaign_idinteger or null -
data.metadataobject or null -
data.created_atstring or null -
data.updated_atstring or null
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/suppressions \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email":"former-customer@example.com","reason":"manual","metadata":{"note":"Asked by phone not to be emailed"}}'
Request body
{
"email": "former-customer@example.com",
"reason": "manual",
"metadata": {
"note": "Asked by phone not to be emailed"
}
}
Response 201
{
"data": {
"id": 77,
"email": "former-customer@example.com",
"reason": "manual",
"source": "api",
"campaign_id": null,
"metadata": {
"note": "Asked by phone not to be emailed"
},
"created_at": "2026-08-09T10:04:12+00:00",
"updated_at": "2026-08-09T10:04:12+00:00"
}
}
DELETE
/suppressions
Remove a suppression
Requires scope suppressions:write
The address becomes eligible for future sends.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
emailstring Required
Response
-
dataobject -
data.emailstring -
data.statusstring -
removednot_found -
statusstring - Deprecated: read `data.status` instead.
-
removednot_found
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X DELETE https://tweak.email/api/v1/suppressions \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email":"former-customer@example.com"}'
Request body
{
"email": "former-customer@example.com"
}
Response 200
{
"data": {
"email": "former-customer@example.com",
"status": "removed"
},
"status": "removed"
}
Transactional
One-off transactional sending
POST
/send
Send a transactional message
Requires scope transactional:send
Honours suppressions, sender-domain verification, and the plan's email allowance. Platform-wide suppressions (confirmed hard bounces and complaints) cannot be bypassed. Until a team owner or admin has accepted the Data Processing Agreement in the app, only the team's own members can be e-mailed; other recipients get a 403 with `dpa_required: true`.
A 200 means the message was accepted for delivery (`status: queued`), not that it reached the inbox. It returns a `message_id`; the message's `email.delivered`, `email.bounced` and `email.complained` webhooks and its events in `GET /events` carry the same `message_id` and your `metadata`. An open may be reported without them. A field the endpoint does not support (such as `tags`, `headers` or `cc`) is a 422 naming it, never silently dropped.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
tostring Required -
to_namestring or null -
from_emailstring Required - Sent as-is from a fully verified sending domain. On tweak.email without one, the message goes out from your team address on the shared sender domain with this address as Reply-To. Third-party providers require a verified domain.
-
from_namestring or null -
reply_tostring or null -
subjectstring Required - Merge tags are substituted here too.
-
htmlstring - Required unless template_id is given.
-
textstring or null - Derived from the HTML when omitted.
-
template_idinteger - One of your templates, or a system template. Required unless html is given.
-
variablesobject - Values for {{merge_tags}} in the subject and body.
-
ignore_suppressionboolean - Waives your own suppression list for a genuinely operational message, such as a security alert. Never waives platform-wide suppressions. Leave it out for anything else.
-
metadataobject or null - Your own reference data for the message, such as an order number: up to 20 string values, keys of up to 40 letters, digits, `_`, `-` or `.`. Returned with the message's delivery webhooks and events; never put in the email.
Response
-
dataobject -
data.statusstring - `queued`: accepted for delivery. Delivery itself is reported by the `email.delivered` or `email.bounced` webhook. `sandboxed`: checked but not sent.
-
queuedsandboxed -
data.message_idstring or null - Our id for this message, carried by its delivery webhooks and events. Null in sandbox mode.
-
data.tostring -
data.subjectstring - With merge tags substituted.
-
data.metadataobject - The metadata stored with the message.
-
data.acceptedboolean - True when the message was accepted for delivery; false in sandbox mode.
-
data.deliveredboolean - Deprecated: the same as `accepted`. It never meant the message reached the inbox. It will be removed in a later version.
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
- 502
- The message could not be handed over for delivery. Nothing was sent; retry shortly.
- 503
- A service this endpoint depends on is temporarily unavailable, for example while sending is paused. Nothing was done; retry later.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/send \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"to":"jane@example.com","to_name":"Jane Okonkwo","from_email":"receipts@acme.com","from_name":"Acme","reply_to":"support@acme.com","subject":"Your receipt for order {{order_id}}","html":"<p>Hi {{first_name}}, thanks for order {{order_id}}. Your total was {{total}}.</p>","variables":{"first_name":"Jane","order_id":"4417","total":"€49.00"},"metadata":{"order_id":"4417"}}'
Request body
{
"to": "jane@example.com",
"to_name": "Jane Okonkwo",
"from_email": "receipts@acme.com",
"from_name": "Acme",
"reply_to": "support@acme.com",
"subject": "Your receipt for order {{order_id}}",
"html": "<p>Hi {{first_name}}, thanks for order {{order_id}}. Your total was {{total}}.</p>",
"variables": {
"first_name": "Jane",
"order_id": "4417",
"total": "€49.00"
},
"metadata": {
"order_id": "4417"
}
}
Response 200
{
"data": {
"status": "queued",
"message_id": "msg_01jd4x7v3k9q2m8r5t6w0y1z2a",
"to": "jane@example.com",
"subject": "Your receipt for order 4417",
"metadata": {
"order_id": "4417"
},
"accepted": true,
"delivered": true
}
}
AI
Copy polish, subject lines, and deliverability scoring
POST
/ai/polish
Polish email copy
Requires scope ai:write
Rewrites for a requested tone and goal, and returns concrete suggestions plus a quality score. Counts against the plan's monthly AI allowance.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
contentstring Required -
tonestring -
professionalcasualfriendlyformalpersuasive -
goalstring -
clarityengagementconversionbrevitywarmth
Response
-
dataobject -
data.idinteger -
data.tweaked_contentstring -
data.ai_suggestionsarray of string -
data.quality_scorenumber -
data.model_usedstring or null -
data.tokens_usedinteger
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
- 503
- A service this endpoint depends on is temporarily unavailable, for example while sending is paused. Nothing was done; retry later.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/ai/polish \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"content":"Hey, we have got a new feature you might like. Check it out when you get a chance.","tone":"friendly","goal":"engagement"}'
Request body
{
"content": "Hey, we have got a new feature you might like. Check it out when you get a chance.",
"tone": "friendly",
"goal": "engagement"
}
Response 200
{
"data": {
"id": 9001,
"tweaked_content": "Good news: the feature you asked for is here. Take a look, it takes two minutes to set up.",
"ai_suggestions": [
"Lead with the benefit, not the announcement."
],
"quality_score": 82,
"model_used": null,
"tokens_used": 412
}
}
POST
/ai/subject-lines
Generate and score subject lines
Requires scope ai:write
Set `use_history` to ground the scoring in this team's own historical open rates rather than generic heuristics.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
subjectstring Required -
use_historyboolean - Ground scoring in this team's real historical open rates.
Response
-
dataobject -
data.idinteger -
data.variationsarray of object -
data.winning_subjectstring -
data.original_scorenumber -
data.best_scorenumber
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
- 503
- A service this endpoint depends on is temporarily unavailable, for example while sending is paused. Nothing was done; retry later.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/ai/subject-lines \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"subject":"Our August update","use_history":true}'
Request body
{
"subject": "Our August update",
"use_history": true
}
Response 200
{
"data": {
"id": 9002,
"variations": [
{
"subject": "Three things we shipped in August",
"score": 71
}
],
"winning_subject": "Three things we shipped in August",
"original_score": 54,
"best_score": 71
}
}
POST
/ai/deliverability
Score a message for deliverability
Requires scope ai:write
Returns a spam score, specific issues, and a pass/warn/fail verdict. Useful as a pre-send check in CI.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
contentstring Required -
subjectstring -
use_account_signalsboolean - Weight the assessment by your account's real bounce, complaint, and domain-auth signals. Defaults to true.
Response
-
dataobject -
data.idinteger -
data.spam_scorenumber - 0–100; lower is better.
-
data.issuesarray of object -
data.checks_passedarray of object -
data.verdictstring -
passwarnfail
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
- 503
- A service this endpoint depends on is temporarily unavailable, for example while sending is paused. Nothing was done; retry later.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/ai/deliverability \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"content":"<p>Hi {{first_name|there}}, your invoice for August is ready.</p>","subject":"Your invoice is ready","use_account_signals":true}'
Request body
{
"content": "<p>Hi {{first_name|there}}, your invoice for August is ready.</p>",
"subject": "Your invoice is ready",
"use_account_signals": true
}
Response 200
{
"data": {
"id": 9003,
"spam_score": 12,
"issues": [],
"checks_passed": [
{
"check": "unsubscribe_link"
}
],
"verdict": "pass"
}
}
GET
/ai/usage
Remaining AI and email allowance
Response
-
dataobject -
data.period_startstring -
data.period_endstring -
data.ai_tweaksobject -
data.subject_testsobject -
data.emailsobject
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/ai/usage \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"period_start": "2026-08-09T10:00:00+00:00",
"period_end": "2026-08-09T10:00:00+00:00",
"ai_tweaks": {},
"subject_tests": {},
"emails": {}
}
}
Webhooks
Outbound event subscriptions
GET
/webhooks
List webhook endpoints
Requires scope webhooks:read
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
Response
-
dataarray of object -
data.idinteger -
data.urlstring -
data.descriptionstring or null -
data.eventsarray of string -
data.is_activeboolean -
data.last_delivered_atstring or null -
data.consecutive_failuresinteger -
data.secretstring - Returned only on creation and rotation.
-
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/webhooks \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 4,
"url": "https://example.com/hooks/tweak",
"description": "CRM sync",
"events": [
"contact.unsubscribed",
"email.bounced"
],
"is_active": true,
"last_delivered_at": null,
"consecutive_failures": 0,
"secret": "whsec_3Fq9sLk2mVn8XyZa1bC4dE5fG6hJ7kL8"
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/webhooks
Create a webhook endpoint
Requires scope webhooks:write
The response is the only time the signing secret is returned. Payloads are signed as `Tweak-Signature: t={timestamp},v1={hmac}` where the HMAC is SHA-256 over `{timestamp}.{raw body}`. A URL on localhost, a private, loopback, link-local, multicast or reserved address, an IP address written in a non-standard form (`2130706433`, `0x7f000001`, `127.1`), or a URL with a user name or password in it is a 422 with `code: unsafe_webhook_url`. Deliveries pause while the team's plan does not include the API.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
urlstring Required - Must be publicly routable: localhost, private, loopback, link-local, multicast and reserved addresses, IP addresses in a non-standard numeric form, and URLs carrying a user name or password are refused with 422 (`code: unsafe_webhook_url`). The host is checked again, after DNS, on every delivery, and the delivery connects to the address that was checked.
-
descriptionstring -
eventsarray of string Required - Event types, or ["*"] for all.
Response
-
dataobject -
data.idinteger -
data.urlstring -
data.descriptionstring or null -
data.eventsarray of string -
data.is_activeboolean -
data.last_delivered_atstring or null -
data.consecutive_failuresinteger -
data.secretstring - Returned only on creation and rotation.
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/webhooks \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/hooks/tweak","description":"CRM sync","events":["contact.unsubscribed","email.bounced"]}'
Request body
{
"url": "https://example.com/hooks/tweak",
"description": "CRM sync",
"events": [
"contact.unsubscribed",
"email.bounced"
]
}
Response 201
{
"data": {
"id": 4,
"url": "https://example.com/hooks/tweak",
"description": "CRM sync",
"events": [
"contact.unsubscribed",
"email.bounced"
],
"is_active": true,
"last_delivered_at": null,
"consecutive_failures": 0,
"secret": "whsec_3Fq9sLk2mVn8XyZa1bC4dE5fG6hJ7kL8"
}
}
GET
/webhooks/event-types
List subscribable event types
Requires scope webhooks:read
Response
-
dataarray of object -
data.typestring -
data.descriptionstring
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/webhooks/event-types \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"type": "contact.unsubscribed",
"description": "A contact unsubscribed"
}
]
}
GET
/webhooks/{endpoint}
Fetch a webhook endpoint
Requires scope webhooks:read
Path parameters
-
endpointinteger Required - Webhook endpoint id.
Response
-
dataobject -
data.idinteger -
data.urlstring -
data.descriptionstring or null -
data.eventsarray of string -
data.is_activeboolean -
data.last_delivered_atstring or null -
data.consecutive_failuresinteger -
data.secretstring - Returned only on creation and rotation.
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/webhooks/:endpoint \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 4,
"url": "https://example.com/hooks/tweak",
"description": "CRM sync",
"events": [
"contact.unsubscribed",
"email.bounced"
],
"is_active": true,
"last_delivered_at": null,
"consecutive_failures": 0,
"secret": "whsec_3Fq9sLk2mVn8XyZa1bC4dE5fG6hJ7kL8"
}
}
PATCH
/webhooks/{endpoint}
Update a webhook endpoint
Requires scope webhooks:write
Path parameters
-
endpointinteger Required - Webhook endpoint id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
urlstring -
descriptionstring or null -
eventsarray of string -
is_activeboolean - Re-enabling an endpoint also resets its failure count.
Response
-
dataobject -
data.idinteger -
data.urlstring -
data.descriptionstring or null -
data.eventsarray of string -
data.is_activeboolean -
data.last_delivered_atstring or null -
data.consecutive_failuresinteger -
data.secretstring - Returned only on creation and rotation.
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X PATCH https://tweak.email/api/v1/webhooks/:endpoint \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/hooks/tweak","description":"CRM sync","events":["*"],"is_active":true}'
Request body
{
"url": "https://example.com/hooks/tweak",
"description": "CRM sync",
"events": [
"*"
],
"is_active": true
}
Response 200
{
"data": {
"id": 4,
"url": "https://example.com/hooks/tweak",
"description": "CRM sync",
"events": [
"contact.unsubscribed",
"email.bounced"
],
"is_active": true,
"last_delivered_at": null,
"consecutive_failures": 0,
"secret": "whsec_3Fq9sLk2mVn8XyZa1bC4dE5fG6hJ7kL8"
}
}
DELETE
/webhooks/{endpoint}
Delete a webhook endpoint
Requires scope webhooks:write
Path parameters
-
endpointinteger Required - Webhook endpoint id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.idinteger -
data.deletedboolean
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X DELETE https://tweak.email/api/v1/webhooks/:endpoint \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 42,
"deleted": true
}
}
GET
/webhooks/{endpoint}/deliveries
Delivery history
Requires scope webhooks:read
What was sent and what your endpoint answered, for debugging.
Path parameters
-
endpointinteger Required - Webhook endpoint id.
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
Response
-
dataarray of object -
data.idinteger -
data.event_typestring -
data.event_idstring -
data.payloadobject - The body that was sent, as in `WebhookEvent`.
-
data.response_statusinteger or null -
data.response_bodystring or null - The start of what the endpoint answered: up to 500 characters of a 2xx answer, up to 200 of any other; null when it sent none.
-
data.attemptinteger -
data.succeededboolean -
data.errorstring or null -
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/webhooks/:endpoint/deliveries \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 8812,
"event_type": "email.bounced",
"event_id": "evt_3Fq9sLk2mVn8XyZa1bC4dE5f",
"payload": {},
"response_status": 200,
"response_body": "ok",
"attempt": 1,
"succeeded": true,
"error": null
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/webhooks/{endpoint}/test
Send a test event
Requires scope webhooks:write
Lets you verify signature checking without provoking a real bounce.
Path parameters
-
endpointinteger Required - Webhook endpoint id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.queuedboolean -
data.event_idstring
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/webhooks/:endpoint/test \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"queued": true,
"event_id": "evt_test_9xQ2mLk4Rt7VbN1c"
}
}
POST
/webhooks/{endpoint}/rotate-secret
Rotate the signing secret
Requires scope webhooks:write
Returns the new secret once.
Path parameters
-
endpointinteger Required - Webhook endpoint id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.idinteger -
data.urlstring -
data.descriptionstring or null -
data.eventsarray of string -
data.is_activeboolean -
data.last_delivered_atstring or null -
data.consecutive_failuresinteger -
data.secretstring - Returned only on creation and rotation.
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/webhooks/:endpoint/rotate-secret \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 4,
"url": "https://example.com/hooks/tweak",
"description": "CRM sync",
"events": [
"contact.unsubscribed",
"email.bounced"
],
"is_active": true,
"last_delivered_at": null,
"consecutive_failures": 0,
"secret": "whsec_3Fq9sLk2mVn8XyZa1bC4dE5fG6hJ7kL8"
}
}
API keys
Credential management
GET
/api-keys
List API keys
Requires scope keys:manage
Secrets are never returned; only a masked prefix.
Query parameters
-
per_pageinteger default 25 - Records per page (1–100, default 25).
-
cursorstring - The `next_cursor` (or `prev_cursor`) value from a previous response of the same listing, unchanged. Any other value is refused with 422 rather than silently restarting at the first page.
Response
-
dataarray of object -
data.idinteger -
data.namestring -
data.masked_keystring -
data.scopesarray of string -
data.last_used_atstring or null -
data.expires_atstring or null -
data.revoked_atstring or null -
per_pageinteger -
next_cursorstring or null - Pass as `?cursor=` for the next page. Null on the last page.
-
prev_cursorstring or null -
next_page_urlstring or null -
prev_page_urlstring or null -
has_moreboolean
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/api-keys \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"id": 4,
"name": "CRM sync",
"masked_key": "lt_a1B2c3D...9xYz",
"scopes": [
"contacts:read",
"contacts:write"
],
"last_used_at": "2026-08-09T10:04:12+00:00",
"expires_at": null,
"revoked_at": null
}
],
"per_page": 25,
"next_cursor": "eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null,
"next_page_url": "https://tweak.email/api/v1/contacts?cursor=eyJjb250YWN0cy5pZCI6NDIsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_page_url": null,
"has_more": true
}
POST
/api-keys
Mint an API key
Requires scope keys:manage
The secret is returned exactly once. A key cannot grant scopes it does not itself hold, and cannot create a key that outlives it: when the minting key expires, the new key expires no later (it gets the same expiry when you give none, and a later `expires_at` is a 422). An empty `scopes` list is a 422. Sent with an `Idempotency-Key`, a retry returns the same key rather than minting a second one.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Body
-
namestring Required -
scopesarray of string - Omitted, the new key gets every scope, which only a key holding every scope may grant. Name the scopes the integration needs; an empty list is a 422.
-
expires_atstring or null - Must be in the future, and no later than the expiry of the key making the request. Omitted, the new key gets that key's expiry, or none when it has none.
Response
-
dataobject -
data.idinteger -
data.namestring -
data.masked_keystring -
data.scopesarray of string -
data.last_used_atstring or null -
data.expires_atstring or null -
data.revoked_atstring or null -
data.keystring - The secret. Returned exactly once.
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X POST https://tweak.email/api/v1/api-keys \
-H "Authorization: Bearer $TWEAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"CRM sync","scopes":["contacts:read","contacts:write"],"expires_at":"2027-01-01T00:00:00+00:00"}'
Request body
{
"name": "CRM sync",
"scopes": [
"contacts:read",
"contacts:write"
],
"expires_at": "2027-01-01T00:00:00+00:00"
}
Response 201
{
"data": {
"id": 4,
"name": "CRM sync",
"masked_key": "lt_a1B2c3D...9xYz",
"scopes": [
"contacts:read",
"contacts:write"
],
"last_used_at": "2026-08-09T10:04:12+00:00",
"expires_at": null,
"revoked_at": null,
"key": "lt_a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6q7R8s9T0u1V2w9xYz"
}
}
GET
/api-keys/scopes
List available scopes
Response
-
dataarray of object -
data.scopestring -
data.descriptionstring
Errors
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl https://tweak.email/api/v1/api-keys/scopes \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": [
{
"scope": "contacts:read",
"description": "Read contacts, lists, tags, segments, and contact fields"
}
]
}
DELETE
/api-keys/{key}
Revoke an API key
Requires scope keys:manage
Revoked rather than deleted, so the audit record survives. A key may revoke itself, or a key whose scopes it holds all of; revoking a broader key is a 403.
Path parameters
-
keyinteger Required - API key id.
Headers
-
Idempotency-Keystring - A value you choose (up to 255 characters) and keep the same across retries of one operation. For 24 hours, a retry with the same key and body replays the first successful response, marked `Idempotency-Replayed: true`, instead of executing again. The same key with a different body is a 422 (`idempotency_key_reused`). Keys are shared by the whole team and bound to the API key that first used them: another API key of the team presenting the same Idempotency-Key also gets that 422, even with the same body, so give each integration its own keys. A retry while the first request is still running is a 409. Failed requests are not kept, so they can be retried with the same key.
Response
-
dataobject -
data.idinteger -
data.revokedboolean
Errors
- 400
- The body was sent as JSON (`Content-Type: application/json`) but is not valid JSON, or not a JSON object (`code: invalid_json`). Nothing was done.
- 403
- The key lacks a required scope (`code: missing_scope`), or the team's plan does not include API access (`code: plan_required`, with `required_plan` and, after a free trial, `trial_ended_at`).
- 404
- No such record for this team.
- 422
- The request was understood but could not be applied.
Every endpoint can also return 401 (bad credential) and 429 (rate limited, see Retry-After). A write sent with an Idempotency-Key can also return 409 while the first request with that key is still running.
Request
curl -X DELETE https://tweak.email/api/v1/api-keys/:key \
-H "Authorization: Bearer $TWEAK_API_KEY"
Response 200
{
"data": {
"id": 4,
"revoked": true
}
}