# Criar uma campanha

Source: https://won.dev/pt-BR/docs/email/campaigns-create

`POST https://api.won.dev/v1/email/campaigns`

Cria uma cadência de até seis e-mails para uma lista de pessoas e, com `start: true`, começa a enviá-la. Envia das caixas dos domínios de envio do próprio remetente (`POST /email/domains`), poucos e-mails por caixa por dia, no horário comercial de cada destinatário; cada destinatário recebe a cadência inteira da mesma caixa, e a cadência para para uma pessoa assim que ela responde, dá bounce ou se descadastra. Campanhas e e-mails são grátis: o que os domínios do remetente enviam é pago com os domínios. Uma campanha envia por dia o que o `daily_limit` dela permite, dentro do que os domínios enviam juntos, que todas as campanhas do remetente dividem. Use `dry_run: true` primeiro: ele confere os textos e a lista, mostra o primeiro e-mail como os primeiros destinatários o receberiam e quanto tempo a campanha leva com os domínios que o remetente tem, sem criar nada. Iniciar falha com `no_domains` enquanto o remetente não tiver nenhum. Com um cabeçalho `Idempotency-Key`, uma nova tentativa nunca cria uma segunda campanha. Também dá para adicionar destinatários depois com `POST /email/campaigns/{id}/recipients`.

- **Cobrança:** A chamada é grátis, e os e-mails também: eles saem dos domínios de envio do remetente, pagos por mês; veja [Domínios de envio](/pt-BR/docs/email#domains).

Uma chave de teste (`won_test_...`) roda isto no [sandbox](/pt-BR/docs/email#sandbox): nada é enviado e nada é cobrado.

## Parâmetros [#parameters]

Os parâmetros vão no corpo JSON. Requisições `POST` também aceitam o cabeçalho `Idempotency-Key`; veja [Enviar uma requisição duas vezes](/pt-BR/docs/email#idempotency).

| Parâmetro | Tipo | Obrigatório | Descrição (texto original da API) |
| --- | --- | --- | --- |
| `sender_id` | string | sim | The sender the emails are for, from `POST /email/senders`. |
| `name` | string | sim | A name for your own reference. Recipients never see it. |
| `steps` | object[] | sim | The emails of the sequence, in order. Two to four work best. |
| `steps[].delay_days` | integer | não | Sending days to wait after the step before. Default 3. Ignored on the first step. |
| `steps[].subject` | string | não | The subject line. Required on the first step. Leave it out on a follow-up to send it as a reply in the thread of the first email, which is what gets answers. |
| `steps[].body` | string | sim | The text, as plain text. Placeholders: `{{first_name}}`, `{{last_name}}`, `{{company}}`, your own from `variables`, and `{{sender_first_name}}` and `{{sender_name}}` for the name of the mailbox that writes. `{{first_name\|there}}` falls back to "there". Do not add a signature block with your company and address or an unsubscribe line: every email ends with them. |
| `steps[].weight` | integer | não | With `variants`: this version's share of the recipients, relative to the others. Default: `1`. |
| `steps[].variants` | object[] | não | Other versions of this step, to test against it. Each recipient gets one version, always the same one. `GET /email/campaigns/{id}` shows how each did. |
| `steps[].variants[].subject` | string | não | The subject line. Required on the first step. Leave it out on a follow-up to send it as a reply in the thread of the first email, which is what gets answers. |
| `steps[].variants[].body` | string | sim | The text, as plain text. Placeholders: `{{first_name}}`, `{{last_name}}`, `{{company}}`, your own from `variables`, and `{{sender_first_name}}` and `{{sender_name}}` for the name of the mailbox that writes. `{{first_name\|there}}` falls back to "there". Do not add a signature block with your company and address or an unsubscribe line: every email ends with them. |
| `steps[].variants[].weight` | integer | não | With `variants`: this version's share of the recipients, relative to the others. Default: `1`. |
| `recipients` | object[] | não | Up to 1000 people to write to. Each is checked: bad addresses, people on a suppression list and people in regions the sender has not declared are left out and listed in the answer. |
| `recipients[].email` | string | não | The person's work email. |
| `recipients[].contact_id` | string | não | A person ID this account was given in the last 90 days, such as `per_8f3k2m9x4p1q`, instead of `email`: from a contact search, a people search, or any endpoint that returns a person. Their email, name, company and country on file are used. A person found without an email needs one first: `POST /enrich/people/email/find` with `person_id`. |
| `recipients[].first_name` | string | não | The person's first name, for `{{first_name}}`. |
| `recipients[].last_name` | string | não | The person's last name, for `{{last_name}}`. |
| `recipients[].company` | string | não | The company the person works at, for `{{company}}`. |
| `recipients[].country` | string | não | Where the person is, as an ISO code such as `US`. It decides their office hours and which rules apply. Guessed from the address when left out. An address that shows a country itself, such as one ending in `.de`, stays under that country's rules whatever is given here. |
| `recipients[].timezone` | string | não | The person's IANA time zone, when you know it better than the country says. |
| `recipients[].variables` | object | não | Values for your own placeholders, such as `{ "product": "mesh chairs" }` for `{{product}}`. Names are lowercase letters, digits and underscores. |
| `recipients[].metadata` | object | não | Your own keys and values, such as `{"customer_id": "c_812"}`: up to 20 keys of at most 40 characters, each value a string of at most 500. Returned with the recipient, and in the events about them over the campaign's keys of the same name. |
| `schedule` | object | não | When emails go out. The hours are read in each recipient's own time zone when their country or time zone is known. |
| `schedule.timezone` | string | não | IANA time zone the hours are read in for a recipient whose own is not known. Default `America/New_York`. |
| `schedule.days` | (`sun` \| `mon` \| `tue` \| `wed` \| `thu` \| `fri` \| `sat`)[] | não | Days emails go out on. Default Monday to Friday. |
| `schedule.start_hour` | integer | não | First hour emails go out in. Default 9. |
| `schedule.end_hour` | integer | não | Emails go out before this hour. Default 17. |
| `daily_limit` | integer | não | The most emails the campaign sends on one day. It never sends more than the sender's domains may send, 45 a day each at full speed, which the sender's campaigns share. Default: `50`. |
| `stop_on_company_reply` | boolean | não | When one person at a company answers, stop writing to the others at that company. Default: `true`. |
| `track_opens` | boolean | não | Count opens with an invisible image. Off by default: it lowers inbox placement, and mail programs that fetch images themselves make the numbers unreliable. Default: `false`. |
| `track_clicks` | boolean | não | Count clicks by sending links through our redirect. Off by default, for the same reason. Default: `false`. |
| `metadata` | object | não | Your own keys and values, such as `{"customer_id": "c_812"}`: up to 20 keys of at most 40 characters, each value a string of at most 500. Returned as given, and in the events about it. |
| `start` | boolean | não | Start sending right away. Otherwise the campaign is a `draft` until `POST /email/campaigns/{id}/start`. Default: `false`. |
| `dry_run` | boolean | não | Check everything and show a preview, without creating anything. Problems in the texts are listed instead of failing the call. Default: `false`. |

## Resposta [#response]

Com `dry_run: true` nada é criado nem alterado: a resposta tem os mesmos campos e diz o que aconteceria. Os erros estão descritos em [Erros](/pt-BR/docs/errors).

| Campo | Tipo | Descrição (texto original da API) |
| --- | --- | --- |
| `data` | object | The campaign, and what the checks found in its list and its texts. |
| `data.dry_run` | boolean | True when nothing was created: the answer to `dry_run: true`. |
| `data.campaign` | object \| null | The campaign. Null on a dry run: nothing was created. |
| `data.campaign.id` | string | Campaign ID, such as `cmp_7p1q8w3e5r4k2m9x`. |
| `data.campaign.name` | string |  |
| `data.campaign.sender_id` | string | The sender it is from. It sends from that sender's domains. |
| `data.campaign.status` | `draft` \| `active` \| `paused` \| `completed` \| `canceled` \| `suspended` | `draft` until started. `active` sends. `paused` waits for `resume`. `completed`, `canceled` and `suspended` are final. |
| `data.campaign.pause_reason` | `manual` \| `no_domains` \| `list_quality` \| `sending_suspended` \| null | Why it is paused: `manual`, `no_domains` (the sender's last sending domain ended; it goes on by itself once a new one is ready), `list_quality` (too many invalid addresses; resuming accepts the list as it is), `sending_suspended` (the sender was suspended). |
| `data.campaign.waiting` | `daily_limit` \| `ramping` \| `no_domains` \| null | Why an active campaign is not sending right now although people are due: `daily_limit` (it, or its sender's domains, sent all they may today), `ramping` (the same, while a domain is still on its way up to full speed), `no_domains` (its sender has no domain that can send yet). Null when it sends, or nobody is due. |
| `data.campaign.steps` | object[] | The sequence, in order. |
| `data.campaign.steps[].delay_days` | integer | Sending days to wait after the email before. 0 on the first step. |
| `data.campaign.steps[].versions` | object[] | The text of the step. More than one when versions are tested against each other. |
| `data.campaign.steps[].versions[].subject` | string \| null | Null on a follow-up that goes out as a reply in the thread of the first email. |
| `data.campaign.steps[].versions[].body` | string |  |
| `data.campaign.steps[].versions[].weight` | integer | Its share of the recipients, relative to the other versions. |
| `data.campaign.steps[].versions[].stats` | object | How this version did. |
| `data.campaign.steps[].versions[].stats.sent` | integer |  |
| `data.campaign.steps[].versions[].stats.opened` | integer | Emails opened at least once. Counted only when `track_opens` is on. |
| `data.campaign.steps[].versions[].stats.clicked` | integer |  |
| `data.campaign.steps[].versions[].stats.replied` | integer | Replies that came after this email and before the next one. |
| `data.campaign.schedule` | object | When emails go out: on these days, between these hours, in the recipient's time. |
| `data.campaign.schedule.timezone` | string | IANA time zone the hours are read in when a recipient's own is not known. |
| `data.campaign.schedule.days` | (`sun` \| `mon` \| `tue` \| `wed` \| `thu` \| `fri` \| `sat`)[] |  |
| `data.campaign.schedule.start_hour` | integer |  |
| `data.campaign.schedule.end_hour` | integer |  |
| `data.campaign.daily_limit` | integer | The most emails the campaign sends on one day. What its sender's domains can send is the limit above it. |
| `data.campaign.stop_on_company_reply` | boolean | One person at a company answers: nobody else at that company gets another email. |
| `data.campaign.track_opens` | boolean |  |
| `data.campaign.track_clicks` | boolean |  |
| `data.campaign.metadata` | object | Your own keys and values, as you gave them. Empty when none were. |
| `data.campaign.stats` | object | Where the campaign stands. |
| `data.campaign.stats.recipients` | integer | People in the campaign. |
| `data.campaign.stats.waiting` | integer | Still being checked, or waiting for their first email. |
| `data.campaign.stats.in_sequence` | integer | Got at least one email and have more to come. |
| `data.campaign.stats.finished` | integer | Got every email and did not answer. |
| `data.campaign.stats.replied` | integer |  |
| `data.campaign.stats.bounced` | integer |  |
| `data.campaign.stats.unsubscribed` | integer |  |
| `data.campaign.stats.excluded` | integer | Left out or stopped: invalid address, suppressed, or stopped by you. |
| `data.campaign.stats.emails_sent` | integer |  |
| `data.campaign.stats.emails_opened` | integer |  |
| `data.campaign.stats.emails_clicked` | integer |  |
| `data.campaign.test` | boolean | Made with a test key: sending and replies are simulated. |
| `data.campaign.created_at` | string | When it was created, as an ISO 8601 time in UTC. |
| `data.campaign.started_at` | string \| null |  |
| `data.campaign.completed_at` | string \| null |  |
| `data.recipients` | object | What became of the recipients in this request. |
| `data.recipients.accepted` | integer | Addresses taken into the campaign. |
| `data.recipients.duplicates` | integer | Addresses that were in the campaign already. Nothing changed for them. |
| `data.recipients.rejected` | integer | Addresses left out. `results` says why for each. |
| `data.recipients.results` | object[] | One entry for each address that was rejected, was a duplicate, or was accepted with a warning. Addresses accepted without remark are only counted. |
| `data.recipients.results[].email` | string \| null |  |
| `data.recipients.results[].status` | `accepted` \| `duplicate` \| `rejected` |  |
| `data.recipients.results[].recipient_id` | string \| null |  |
| `data.recipients.results[].reason` | string \| null | Why it was rejected: `invalid_address`, `blocked_mailbox`, `duplicate_in_request`, `suppressed`, `complained`, `undeliverable`, `active_in_other_campaign`, `region_blocked`, `region_not_declared`, `personal_mailbox_in_region`, `missing_variable`, `contact_not_found` or `campaign_full`. |
| `data.recipients.results[].message` | string \| null | The same in a sentence, with what to do about it. |
| `data.recipients.results[].warnings` | string[] | For an accepted address: `shared_mailbox` (such as info@, read by whoever is on duty) or `personal_mailbox` (a private mail service). |
| `data.content` | object | What the checks found in the texts. |
| `data.content.problems` | object[] | What must be fixed. Only a dry run lists them; a real call fails with `content_rejected`. |
| `data.content.problems[].step` | integer | The step, counted from 1. |
| `data.content.problems[].version` | integer | The version of the step, counted from 1. |
| `data.content.problems[].field` | `subject` \| `body` |  |
| `data.content.problems[].code` | string |  |
| `data.content.problems[].message` | string |  |
| `data.content.advice` | object[] | What would make the emails more likely to reach an inbox and be answered. |
| `data.content.advice[].step` | integer | The step, counted from 1. |
| `data.content.advice[].version` | integer | The version of the step, counted from 1. |
| `data.content.advice[].field` | `subject` \| `body` |  |
| `data.content.advice[].code` | string |  |
| `data.content.advice[].message` | string |  |
| `data.content.variables` | object[] | The placeholders your texts use beyond the sender's own. `required` ones have no fallback: a recipient without a value is left out. |
| `data.content.variables[].name` | string |  |
| `data.content.variables[].required` | boolean |  |
| `data.preview` | object[] | On a dry run: the first email as the first recipients would get it, in the first version of the step when it has `variants`. The name in `{{sender_first_name}}` is an example; each recipient is written to by one of our mailboxes under its own name. |
| `data.preview[].to` | string |  |
| `data.preview[].subject` | string |  |
| `data.preview[].body` | string |  |
| `data.estimate` | object | How long the campaign takes, with the domains the sender has. |
| `data.estimate.emails` | integer | Emails if nobody answers: recipients times steps. |
| `data.estimate.per_day` | integer | What the campaign sends a day: its `daily_limit`, or less when the sender's domains send less at full speed. 0 while the sender has none. |
| `data.estimate.days` | integer \| null | About how many days until the last email, at `per_day`. Null while the sender has no sending domain. |
| `data.estimate.domains_for_a_week` | integer | Sending domains it takes for everybody to get the first email within 7 days, at full speed, and with `daily_limit` high enough. Compare with what the sender has: `GET /email/domains?sender_id=`. |
| `notice` | string \| null | A plain sentence when there is something to know about this answer. Null otherwise. |
| `usage` | object | Nothing is charged here. The balance, for reference. |
| `usage.cost` | number | What this call cost, in US dollars. |
| `usage.balance` | number | The balance left after this call, in US dollars. |
| `usage.replayed` | boolean | True when this is a repeat of a request from the last 24 hours. Repeats are free. |

## Exemplo [#example]

```bash
curl https://api.won.dev/v1/email/campaigns \
  -H "Authorization: Bearer $WON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "sender_id": "snd_4k2m9x7p1q8w3e5r",
  "name": "US chair importers, November",
  "steps": [
    {
      "subject": "Office chairs for {{company}}",
      "body": "Hi {{first_name|there}},\n\nI saw that {{company}} imports office seating. We make mesh task chairs in Leeds and ship to the US in four weeks.\n\nWould a price list be useful?\n\n{{sender_first_name}}"
    },
    {
      "delay_days": 3,
      "body": "Hi {{first_name|there}},\n\nJust checking that my note reached the right person. Who looks after seating suppliers at {{company}}?\n\n{{sender_first_name}}"
    }
  ],
  "recipients": [
    {
      "email": "dana.whitfield@harborline-imports.example",
      "first_name": "Dana",
      "company": "Harborline Imports",
      "country": "US"
    },
    {
      "email": "info@coastal-office.example",
      "company": "Coastal Office Supply"
    }
  ],
  "daily_limit": 30,
  "start": false
}'
```

```json
{
  "data": {
    "dry_run": false,
    "campaign": {
      "id": "cmp_7p1q8w3e5r4k2m9x",
      "name": "US chair importers, November",
      "sender_id": "snd_4k2m9x7p1q8w3e5r",
      "status": "draft",
      "pause_reason": null,
      "waiting": null,
      "steps": [
        {
          "delay_days": 0,
          "versions": [
            {
              "subject": "Office chairs for {{company}}",
              "body": "Hi {{first_name|there}},\n\nI saw that {{company}} imports office seating. We make mesh task chairs in Leeds and ship to the US in four weeks.\n\nWould a price list be useful?\n\n{{sender_first_name}}",
              "weight": 1,
              "stats": {
                "sent": 0,
                "opened": 0,
                "clicked": 0,
                "replied": 0
              }
            }
          ]
        },
        {
          "delay_days": 3,
          "versions": [
            {
              "subject": null,
              "body": "Hi {{first_name|there}},\n\nJust checking that my note reached the right person. Who looks after seating suppliers at {{company}}?\n\n{{sender_first_name}}",
              "weight": 1,
              "stats": {
                "sent": 0,
                "opened": 0,
                "clicked": 0,
                "replied": 0
              }
            }
          ]
        }
      ],
      "schedule": {
        "timezone": "America/New_York",
        "days": [
          "mon",
          "tue",
          "wed",
          "thu",
          "fri"
        ],
        "start_hour": 9,
        "end_hour": 17
      },
      "daily_limit": 30,
      "stop_on_company_reply": true,
      "track_opens": false,
      "track_clicks": false,
      "metadata": {
        "customer_id": "c_812"
      },
      "stats": {
        "recipients": 2,
        "waiting": 2,
        "in_sequence": 0,
        "finished": 0,
        "replied": 0,
        "bounced": 0,
        "unsubscribed": 0,
        "excluded": 0,
        "emails_sent": 0,
        "emails_opened": 0,
        "emails_clicked": 0
      },
      "test": false,
      "created_at": "2026-11-18T14:03:10.000Z",
      "started_at": null,
      "completed_at": null
    },
    "recipients": {
      "accepted": 2,
      "duplicates": 0,
      "rejected": 0,
      "results": [
        {
          "email": "info@coastal-office.example",
          "status": "accepted",
          "recipient_id": "rcp_5r4k2m9x7p1q8w3e",
          "reason": null,
          "message": null,
          "warnings": [
            "shared_mailbox"
          ]
        }
      ]
    },
    "content": {
      "problems": [],
      "advice": [],
      "variables": [
        {
          "name": "company",
          "required": true
        },
        {
          "name": "first_name",
          "required": false
        }
      ]
    },
    "preview": [],
    "estimate": {
      "emails": 4,
      "per_day": 30,
      "days": 4,
      "domains_for_a_week": 1
    }
  },
  "notice": null,
  "usage": {
    "cost": 0,
    "balance": 48.08,
    "replayed": false
  }
}
```