# Comprar domínios de envio

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

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

Compra domínios de envio para um remetente: cada um vem com 3 caixas que já estão aquecidas, envia só para esse remetente e soma 45 e-mails por dia ao que ele pode enviar. Nada para configurar: nem DNS, nem caixa para entrar, e as respostas são lidas por nós. Um domínio custa US$ 0,9 por dia, 30 dias de cada vez a partir da data de renovação. Todos os domínios renovam no mesmo dia do mês, então o primeiro período vai de hoje até esse dia: de 15 a 45 dias, pagos agora. Cada um renova sozinho com o seu saldo 3 dias antes de `period_end`; se o saldo não cobrir, a cobrança é tentada de novo até a véspera, e depois o domínio é devolvido. Sem `confirm: true` ele só faz o orçamento do preço, da data e de quantos há em estoque, e não muda nada. Um domínio novo fica pronto em minutos (`domain.ready`) e envia 15 e-mails no primeiro dia, chegando à velocidade máxima em 5 dias. As campanhas do remetente pausadas por `no_domains` continuam sozinhas assim que ele fica pronto. Falha com `out_of_stock` quando não há domínios suficientes à venda, antes de cobrar qualquer coisa. Até 10 de uma vez. Uma chave de teste só recebe o orçamento: no sandbox, todo remetente já tem um domínio simulado. Cada chamada que confirma compra de novo: envie um `Idempotency-Key` para que uma nova tentativa seja segura.

- **Cobrança:** `email_domain_day` US$ 0,9: um domínio de envio por um dia. Com `confirm: true` os dias até `period_end` são cobrados na hora, e depois 30 de cada vez, 3 dias antes de cada renovação. Sem isso, a chamada só faz o orçamento, de graça.

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 to buy them for, such as `snd_4k2m9x7p1q8w3e5r`. They never send for another. |
| `count` | integer | não | How many domains, 1 to 10. Default: `1`. |
| `confirm` | boolean | não | True buys them and charges this period. False, the default, only quotes it. Default: `false`. |
| `max_cost` | number | não | Spending cap for this call in US dollars. If the call could cost more, it fails with `budget_exceeded` before anything is charged. |

## Resposta [#response]

Os erros estão descritos em [Erros](/pt-BR/docs/errors).

| Campo | Tipo | Descrição (texto original da API) |
| --- | --- | --- |
| `data` | object | The domains and their price. |
| `data.confirmed` | boolean | True when the domains were bought. False on a quote: nothing changed. |
| `data.sender_id` | string |  |
| `data.count` | integer | How many domains. |
| `data.price` | number | What they cost now, together, in US dollars: this period, up to `period_end`. |
| `data.price_per_domain` | number | What one costs for this period, in US dollars. |
| `data.days` | integer | Days this period has, today included. |
| `data.period_end` | string | When this period ends and they renew, at `price_per_month` each, charged from your balance 3 days before. |
| `data.price_per_month` | number | What one domain costs for 30 days, from then on. |
| `data.daily_limit` | integer | What they add to the sender's day at full speed: 45 each. |
| `data.first_day_limit` | integer | What they send on their first day, together. |
| `data.days_to_full_speed` | integer | Days until they send at full speed. |
| `data.in_stock` | integer | How many domains can be bought right now. |
| `data.domains` | object[] | The domains bought, `setting_up` for a few minutes. Empty on a quote. |
| `data.domains[].id` | string | Domain ID, such as `dom_5r4k2m9x7p1q8w3e`. |
| `data.domains[].sender_id` | string | The sender it sends for. It never sends for another. |
| `data.domains[].domain` | string \| null | The domain name. Null for the minutes after it was paid for, until one is chosen and bought. |
| `data.domains[].status` | `setting_up` \| `ramping` \| `active` \| `paused` \| `ending` \| `released` \| `failed` | `setting_up` for the minutes it takes to buy it and set up its mailboxes. `ramping` while it sends a few emails a day more each day, for 5 days. `active` at full speed. `paused` while we hold it back. `ending` once it will not renew: it sends until 1 day before `period_end`. Final: `released` (its mailboxes are gone) and `failed` (it could not be bought; what it cost went back to the balance). |
| `data.domains[].end_reason` | `canceled` \| `unpaid` \| `replaced` \| `removed` \| null | Why it ends or ended: `canceled` by you, `unpaid` (the renewal could not be charged), `replaced` by a new domain, `removed` by us. Null while it renews. |
| `data.domains[].mailboxes` | object[] | Its mailboxes, 3 as a rule. Empty while it is set up. Replies to them are read for you: you never sign in to them. |
| `data.domains[].mailboxes[].address` | string | The address emails go out from, and replies come back to. |
| `data.domains[].mailboxes[].name` | string | The name it sends under, the one it was warmed up with. |
| `data.domains[].daily_limit` | integer | What its mailboxes may send today, together. |
| `data.domains[].full_daily_limit` | integer | What they send a day at full speed, together: 45. |
| `data.domains[].sent_today` | integer | Emails they sent since midnight UTC. Answers to replies are left out. |
| `data.domains[].full_speed_at` | string \| null | When it reaches full speed, while it is `ramping`. Null otherwise. |
| `data.domains[].price_per_month` | number | What a renewal costs, for 30 days, in US dollars. |
| `data.domains[].period_end` | string | When the paid period ends. The next one is charged from your balance a few days before, as an ISO 8601 time in UTC. |
| `data.domains[].renews` | boolean | Whether it renews at `period_end`. False once you canceled it. |
| `data.domains[].ends_at` | string \| null | When it stops sending and its mailboxes are given up, when it will not renew. Null while it renews. |
| `data.domains[].renewal_failed_at` | string \| null | When charging the renewal last failed for want of balance. It is tried again until the day before `period_end`, then the domain is given up. Null when nothing failed. |
| `data.domains[].stats` | object | The last 30 days. |
| `data.domains[].stats.sent` | integer | Emails sent. |
| `data.domains[].stats.bounced` | integer | Of them, how many bounced because the mailbox does not exist. |
| `data.domains[].stats.bounce_rate` | number | `bounced` over `sent`, 0 to 1. |
| `data.domains[].stats.complaints` | integer | Recipients who reported its emails as spam. |
| `data.domains[].test` | boolean | The simulated domain of a test key's sender: it never sends for real. |
| `data.domains[].created_at` | string | When it was bought, as an ISO 8601 time in UTC. |
| `data.domains[].ready_at` | string \| null | When its mailboxes could send. |
| `data.domains[].ended_at` | string \| null | When it was released, or failed. |
| `notice` | string \| null | A plain sentence when there is something to know about this answer. Null otherwise. |
| `usage` | object | What this call was charged, and the balance left. |
| `usage.cost` | number | What this call cost, in US dollars. |
| `usage.breakdown` | object[] | Every billing unit that came back, charged or not. Empty when nothing did. |
| `usage.breakdown[].unit` | `email_domain_day` | What is counted. |
| `usage.breakdown[].records` | integer | How many were returned and charged. |
| `usage.breakdown[].already_paid` | integer | How many more were returned for free, because this organization paid for them in the last 30 days. |
| `usage.breakdown[].cost` | number | What they 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/domains \
  -H "Authorization: Bearer $WON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "sender_id": "snd_4k2m9x7p1q8w3e5r",
  "count": 1,
  "confirm": true,
  "max_cost": 30
}'
```

```json
{
  "data": {
    "confirmed": true,
    "sender_id": "snd_4k2m9x7p1q8w3e5r",
    "count": 1,
    "price": 28.8,
    "price_per_domain": 28.8,
    "days": 32,
    "period_end": "2026-12-28T00:00:00.000Z",
    "price_per_month": 27,
    "daily_limit": 45,
    "first_day_limit": 15,
    "days_to_full_speed": 5,
    "in_stock": 24,
    "domains": [
      {
        "id": "dom_5r4k2m9x7p1q8w3e",
        "sender_id": "snd_4k2m9x7p1q8w3e5r",
        "domain": null,
        "status": "setting_up",
        "end_reason": null,
        "mailboxes": [],
        "daily_limit": 0,
        "full_daily_limit": 45,
        "sent_today": 0,
        "full_speed_at": null,
        "price_per_month": 27,
        "period_end": "2026-12-28T00:00:00.000Z",
        "renews": true,
        "ends_at": null,
        "renewal_failed_at": null,
        "stats": {
          "sent": 0,
          "bounced": 0,
          "bounce_rate": 0,
          "complaints": 0
        },
        "test": false,
        "created_at": "2026-11-26T10:15:02.000Z",
        "ready_at": null,
        "ended_at": null
      }
    ]
  },
  "notice": null,
  "usage": {
    "cost": 28.8,
    "breakdown": [
      {
        "unit": "email_domain_day",
        "records": 32,
        "already_paid": 0,
        "cost": 28.8
      }
    ],
    "balance": 19.28,
    "replayed": false
  }
}
```