The tweak.email API lets your own systems do what the app does: manage contacts, build and send campaigns, read reports, send transactional e-mail and use the AI tools. It is included in every paid plan: Starter, Pro and Business.
- API overview: a quick start and the main concepts.
- Full API reference: every endpoint, field and response.
- The same reference as an OpenAPI document, for generating a client, is at
/api/v1/openapi.json.
The basics
- Base URL:
https://tweak.email/api/v1 - Authentication: an API key in the
Authorization: BearerorX-Api-Keyheader. - Format: JSON in, JSON out. Responses put the record or list under
data. A create answers 201; an upsert answers 201 when it created the record and 200 when it updated one.
Rules worth knowing
- Contacts are upserted by e-mail address. Re-sending the same contact updates it rather than creating a duplicate. A contact who unsubscribed stays unsubscribed, whatever you send.
- Contact metadata is merged. On
POST /contacts,POST /contacts/bulkandPATCH /contacts/{id}, the keys you send overwrite the stored ones, a key sent asnullis removed (so is one sent as an empty string), and keys you leave out stay as they are. Send"metadata": nullto clear it all. - Deleted contacts are gone. A deleted contact no longer appears in any list or lookup, and deleting it again returns 404. Adding the same address again brings the contact back with the data you send; if it had unsubscribed or bounced, it keeps that status.
- Consent is required for new contacts. A request that creates a contact (or brings back a deleted one) needs
consent_attested: true, confirming the person agreed to hear from you and was not taken from a bought or scraped list. Updating a contact you already have does not need it, so a sync that only changes metadata can leave it out. InPOST /contacts/bulk, send it once for the whole batch or on each row that creates a contact; a batch that would create a contact without it is refused, naming each such row. - Tags by name or by id. Contacts take tags as
tag_idsor astags(names). A name your team has no tag for yet creates that tag.POST /contacts/{id}/tagstakes either, andDELETE /contacts/{id}/tags/{tag}takes a tag id or a tag name. - Custom fields are defined before they are used. Values you send in
metadataare stored as they are, but a segment rule on a custom field (custom.plan_tier) needs the field defined, with its type: in Settings → Contact Fields, or withPOST /contact-fields.GET /contact-fieldslists them. Only a field's name can be changed afterwards; deleting a field keeps the values stored on contacts. - Values for your contact fields are checked. When a metadata key is one of your contact fields, its value is stored in the field's type:
"1200"becomes the number 1200,"yes"becomes true, a date must be written as2026-11-15(or as a full ISO 8601 date-time such as2026-11-15T09:30:00Z, stored as its date). A value that cannot be converted, such as"ja"for a yes/no field,truefor a number field, or15/11/2026or2027-02-31for a date field, is refused with 422 naming the key (metadata.beta_user) and the type it needs. Other keys are stored as you send them. - Fields an endpoint does not take are refused. Every write (POST, PUT, PATCH and DELETE) answers 422
Unsupported field: …naming each body field the endpoint does not take, such as a misspeltfist_nameor ateam_id, rather than ignoring it. A sequence'sstatuscannot be set through the API either: sequences are activated in the app, after their checks. The API reference lists the fields each endpoint takes. Until 24 November 2026 most endpoints ignored such fields, so if an older integration sends extra fields, remove them. - Sends follow the same rules as the app: verified sending address, unsubscribe link, plan allowance, screening, and the first-send review. A refused send returns a
blockerslist.POST /campaigns/{id}/preflightruns the checks without sending. - Segment definitions are checked. A filter key the API does not know is refused with 422 naming the key, so a typo cannot quietly widen an audience to everyone. The same goes for the
rulestree, which holds conditions on built-in and custom fields, all / any groups and exclusions: an unknown field, an operator the field's type does not have, a value of the wrong type, or a tag or segment id that is not your team's is refused.GET /segments/fieldslists the fields and operators you can use. The filters go insidedefinition: a field the endpoint does not take, such asrulessent next todefinitioninstead of inside it, is refused with 422, andPOST /segments/previewwithoutdefinitionis refused rather than counting everyone. - Rule dates use your timezone. "In the last 14 days" starts at midnight in the rule tree's
timezone. When you leave it out, the API saves the timezone from the team owner's profile (Settings → Profile), much as the app uses the timezone of whoever builds the rule; without one, UTC. - Pagination uses cursors. Pass
next_cursorback as?cursor=untilhas_moreis false. A cursor that was changed, or that came from a different listing, is refused with 422 rather than starting again at the first page. - Idempotency. Send an
Idempotency-Keyheader on writes, especially sends; for 24 hours, a retry with the same key returns the first response instead of acting twice, marked withIdempotency-Replayed: true. That includes the one-time secret of a new API key or webhook, so a retry after a lost response gets the same key back rather than a second one. Using the same key with a different request body returns 422. Keys are shared by your whole team and bound to the API key that first used them: another of your keys sending the same Idempotency-Key gets the same 422, even with an identical body, so give each integration its own keys. Retrying while the first request is still running returns 409. - Rate limits are counted per key and depend on your plan: 120 requests a minute on Starter, 300 on Pro and 600 on Business. Settings → API shows your plan's limit. Every response carries
X-RateLimit-LimitandX-RateLimit-Remaining; a 429 response includesRetry-Afterand the coderate_limit_exceeded. Separately, failed authentications are limited: a key that keeps failing from one address, or an address that tries many different wrong keys in a minute, gets 429 with the codetoo_many_failed_auth_attemptsfor the rest of that minute. Keys that work from that address keep working, so one worker with an old key does not block the others.
Transactional e-mail
POST /send answers with status: "queued" and a message_id once the message has been accepted for delivery. That is not yet delivery: the email.delivered, email.bounced and email.complained webhooks for the message, and its events in GET /events, carry the same message_id. An open may be reported without it.
Add your own reference data in metadata, for example {"order_id": "4417"}: up to 20 text values. It comes back with the message's delivery webhooks and is never put in the e-mail. A field /send does not support, such as tags, headers or cc, is refused with 422 naming it rather than ignored.
The response still includes delivered: true for older integrations. It means the same as accepted (the message was accepted for delivery), is deprecated, and will be removed in a later version.
Delivery events and your own backend
POST /events is for mail you send outside tweak.email: report its delivery events (such as delivered, bounced, opened, clicked or unsubscribed) and they count in your reports and suppressions like any other. It accepts only those delivery event types, not events of your own such as "signed up" or "upgraded".
To act on something that happens in your own product, tag the contact instead: POST /contacts/{id}/tags adds a tag, and a sequence with the When tag is added trigger starts for that contact, exactly as when you add the tag in the app.
To report a purchase, a booking or a sign-up an e-mail led to, use POST /conversions with the person's address and, if you like, the value, the currency, your order number and the campaign it belongs to. An order number is only counted once. Campaign reports explains which campaign gets the credit.
Errors
Every error response has a code your program can check and a message to show, for example {"code": "missing_scope", "message": "This API key is missing a required scope.", ...}. Validation errors add errors, with the messages for each field. Responses that had an error field still have it, with the same text as message. The API reference lists the codes.
| Status | Meaning |
|---|---|
| 400 | The body was sent as JSON but is not valid JSON, or not a JSON object (invalid_json) |
| 401 | Missing, invalid, revoked or expired key (api_key_required, invalid_api_key, api_key_revoked, api_key_expired) |
| 403 | The key lacks the scope (missing_scope), or the plan does not include API access (plan_required) |
| 404 | No such record in your team (not_found) |
| 409 | A request with the same Idempotency-Key is still running; retry shortly |
| 422 | Validation failed (validation_failed), or a send check failed |
| 429 | Too many requests; wait and retry (rate_limit_exceeded, too_many_failed_auth_attempts) |
| 502 | A transactional message could not be handed over for delivery; nothing was sent, retry shortly (send_failed) |
| 503 | Sending (or the AI tools) is temporarily unavailable; retry later |
When the plan does not include the API
If your team's plan has no API access, for example after a free trial ends, every endpoint except GET /me answers 403 with the code plan_required, the plan you need in required_plan and, after a trial, the date it ended in trial_ended_at. GET /me keeps working and shows api_access: false. Your keys, webhook endpoints and settings are kept, and everything works again as soon as the team is on a paid plan.
Before your first API send
Until your team's first send has been reviewed, transactional and test e-mails sent through the API can only go to members of your team. Blocked calls return 403 with review_pending: true.
The same applies until a team owner or admin has accepted the Data Processing Agreement in the app: transactional e-mails to anyone but your team members return 403 with dpa_required: true, and campaign sends and schedules are refused with the DPA listed among their blockers.
To be told about events instead of asking for them, use webhooks.