Skip to main content
A campaign sends emails to a list of people or companies, from one of the workspace’s senders. It is the API equivalent of the campaigns of the app: a campaign created through the API opens in the app like one created there, and the other way round.
The campaign endpoints are in beta. Through the API, you can list the senders you can send from, read campaigns and their messages, create, edit and delete drafts, send messages you wrote for each recipient, review campaigns and edit their messages, remove recipients, launch or schedule them, cancel a schedule, and stop a campaign or some of its recipients.

Before you start

  • An API key.
  • A plan that includes campaigns. Campaigns with follow-ups need sequences on your plan too.
  • A sender, set up in the app: a Gmail account, or an address of your own domain, verified in the app. List message senders returns the senders you can send from: yours, those shared with the workspace, and every sender of the workspace for admins. Senders still waiting for verification are left out.

Send your first campaign

Send your first campaign to yourself: a person whose email address is yours, in your workspace. The steps below review the campaign before it sends, so you can read every message first.
1

Pick a sender

Note the id of the sender to send from. supportsSequences says whether it can send follow-ups, and provider whether it can send an unsubscribe link (custom_domain only).
2

Create the campaign and review it

The response is a 202 with the campaign processing, while its messages are generated. Check its warnings: they list the recipients that were skipped or have no email address.
3

Wait for the review

Poll every few seconds until the campaign is in_review. If its error is set, its messages could not all be generated.
4

Read the messages

Each message is what one recipient receives, with the variables filled in. Edit one with Update a message of a campaign if needed.
5

Launch it

The campaign is sending. Add { "scheduledAt": "2030-01-15T09:00:00+02:00" } as the body to schedule it instead.
Launching sends emails that can’t be unsent. An application or agent that launches campaigns for someone else should show them the campaign (its recipients, steps and send date) and get their approval first.

Campaign, step and message

  • A campaign is what the app calls a campaign: its recipients, its steps and its status. Its name is the subject of its first step, with each variable written {label}, as the app shows it.
  • A step is one email of the campaign: a template, written once with {{variables}}, and sent to every recipient. The first step is the first email; the next ones are follow-ups, sent a number of days after the previous step (delayDays, 1 to 365), in the same email thread or not (sameThread). A campaign with more than one step is what the app calls a sequence.
  • A message is the version of a step for one recipient, with the variables filled in. There is one message per recipient and per step.
For example, a campaign to 50 people with a first email and one follow-up has 2 steps and 100 messages. The first step reads Hi {{firstName}}, and the message to Alice reads Hi Alice.

Writing a step

The subject is plain text and the body is HTML, with variables written {{key}}, such as {{firstName}}. List the variables of a campaign returns every variable a campaign can use, with its token to write as given: the fields of its people or companies, and the text and numeric custom fields of its group, written {{customFieldValues.grp_<uuid>.<field name>}}. A variable without a value for a recipient is removed. Write \{{ for literal braces.
  • Plain text: set bodyFormat: "text" to write the body as plain text: a blank line starts a new paragraph, and a single newline is a line break. Bodies always read back as HTML.
  • HTML: the body follows the format of the app’s email editor. Other HTML, such as styles or tables, is simplified, and the response lists what changed in warnings.
  • Signature: end the body with <p>{{signature}}</p> to sign it with the sender’s signature, as returned by List message senders, and don’t write the signature yourself. A body without {{signature}} is sent unsigned. When you write back a body you read, the token keeps the step’s signature as it is, even if it was edited in the app.
  • Unsubscribe link: write <a href="{{unsubscribeLink}}">Unsubscribe</a> in the body. Only custom_domain senders accept it.
  • Copies: cc and bcc take up to 5 distinct addresses each.
Editing a draft with Update a campaign replaces all its steps, matched by position: read the campaign, change what you need, and send all its steps back.

Send messages you wrote

When you write each recipient’s email yourself, for instance with an LLM, pass the messages to Create a campaign in messages, with target: "launch" to send them, or target: "review" to read them first. They are sent as written, instead of being generated from a template.
  • One message per recipient and step, at most 100 per call. step is the position of the step the message belongs to.
  • Recipients: leave recipients out to send to the recipients of the messages. With recipients, a recipient without a message on a step gets that step’s template.
  • Steps: a step with a body is the template for the recipients without a message on it. A step without a body is written entirely by its messages, so it needs one for every recipient.
  • Subjects: a message without a subject takes the step’s, which then can’t have {{variables}}. A follow-up sent in the same thread takes the subject of the message that starts its thread.
  • Content is final: {{variables}} are rejected, apart from {{signature}} and {{unsubscribeLink}}. cc and bcc default to the step’s.
  • All or nothing: a message whose recipient you can’t access, isn’t among recipients, or has no email address answers 422, and nothing is created. The request body is limited to 500 KB, and answers 413 above.
For more than 100 messages, create the campaign from step templates with target: "review", then rewrite its messages with Update messages of a campaign in batch, 100 at a time, before launching it.
If you personalized messages, at create or during review, and move the campaign back to draft, the personalization is lost. The messages for every step are regenerated, the same way it works in the folk app.

Recipients

A campaign sends to people or to companies, never both, and to 1 to 5,000 recipients. Pick them from a list of ids ({ "type": "contacts", "ids": [...] }), or from the contacts of the campaign’s group ({ "type": "group", "entityType": "person" }), optionally filtered with the filter syntax of the people and companies endpoints. Recipients can’t change once the campaign is created, apart from removing them while it is a draft or in review. Recipients you can’t access are skipped, and recipients without an email address get no message: both are listed in the warnings of the response. Merged contacts resolve to the contact they were merged into.

Senders

Every step is sent from a sender of the workspace. Write it as { "id": "snd_…" } or { "email": "…" }, either once for every step (root sender), or on every step, not both. Without one, the campaign uses the sender you last used.
  • Gmail senders can only send campaigns with a single step: supportsSequences is false for them.
  • stopOnReply (default true) stops the remaining steps for a recipient who replied. With follow-ups, it needs a sender whose mailbox is connected in the app, so that replies are tracked: with any other sender, set it to false, or the campaign can’t go to review. The response warns about it.

Statuses

Each step has a status too: it reads scheduled once the campaign is launched, until it sends, then sending and sent. A request that the status of the campaign doesn’t allow answers 409, with a code such as CAMPAIGN_NOT_EDITABLE or CAMPAIGN_STATUS_CONFLICT.

Review

Reviewing a campaign generates its messages from its steps, as the app does before launch. Create the campaign with target: "review", or review a draft with POST /v1/campaigns/:campaignId/review. Both answer 202 with the campaign processing: it becomes in_review within seconds, to poll with GET /v1/campaigns/:campaignId. If generation fails, the campaign is in_review with an error. Every step needs a sender, a subject and a body, apart from follow-ups sent in the same thread, which take the subject of the first step, and steps written entirely by your messages, which need no body. While a campaign is in review:

Launch

Launching sends a campaign in review now, or schedules it. Launch it with POST /v1/campaigns/:campaignId/launch, with scheduledAt to schedule it, an ISO date and time with a timezone offset or Z. Campaigns send on the quarter hour (:00, :15, :30, :45): scheduledAt is rounded up to the next one, and the campaign returns the rounded time. Or create it with target: "launch" to review and launch it in one call. Send an Idempotency-Key with every launch: a retry with the same key answers the first response and sends nothing. A launch runs the checks of the app. A failed check answers an error and leaves the campaign in review: Once launched, the campaign goes through the spam check of the app: a campaign flagged as spam goes back to in_review with the error spam_detected. With target: "launch", create answers 202 with the campaign processing, which becomes sending or scheduled once its messages are generated, reading in_review for a moment while it launches. A check that fails then can’t answer an error, so the campaign stays in_review with an error instead, such as message_limit_reached: fix it, then launch it with POST /v1/campaigns/:campaignId/launch, which answers the error of the table above.
Two fields name what went wrong. The code of an error response says why a request failed, in capitals (MESSAGE_LIMIT_REACHED). The error of a campaign says what went wrong with the campaign itself, in lowercase (message_limit_reached), and stays on it until it is fixed.

After launch

Track a campaign with Get a campaign: each step counts its messageCount, sentCount and notSentCount, and the campaign is finished once every step was sent. There are no webhooks for campaigns yet: poll it. List the messages of a campaign filters by step, recipientId and status. A message is sent or not_sent:
  • notSentReason says why a message was not sent, such as recipient_no_email, stopped_after_reply or a bounce (bounce_invalid_address, …). The message lists the known values: handle unknown ones as send_failed.
  • unsubscribed is true once the recipient unsubscribed through the link of that message.

Change or stop a launched campaign

  • Scheduled: cancel its schedule to edit it. It goes back to in_review, editable and launchable again, and nothing is sent.
  • Scheduled or sending: stop it for good. Messages already sent stay sent, and those that are stopped are not sent, with notSentReason: "stopped".
    • Without a body, a scheduled campaign sends nothing, and a sending one sends none of the steps still waiting: the campaign is cancelled. The step being sent keeps sending to its remaining recipients, and once the last step is sending, this answers 409.
    • With recipientIds, every message of these recipients not sent yet is stopped, in the step being sent too. The others still receive theirs. Use it for those who replied elsewhere, or to stop the remaining messages of the step being sent.
  • Draft or in review: nothing was sent, so there is nothing to stop. Delete it, with its messages, or remove some of its recipients.