Send a campaign

POST /api/v1/campaigns/{campaignId}/send Triggers the send now and answers 202 immediately. No body is needed. The send itself runs in the background, paced against the sending quota — the request never waits for it.
json
{"success": true, "data": {"campaignId": "…", "status": "send_requested"}}
To send later, use Schedule a campaign. A scheduledAt in this endpoint's body is still accepted, for callers written before the dedicated endpoint — but it only books a draft, and it is no longer the documented way to schedule.
Campaign statePOST /send
draft202 — the send is requested
scheduled202 — it goes now
paused409 — resume it in the app
sending409 — a send is already running
sent409 — it already went out
failed409 — not in a sendable state
no unsubscribe link in the content400 — nothing is emitted
unknown, or another organization404
The content is rendered before anything is emitted. It is the exact same check as POST /api/v1/render: a campaign whose HTML carries no {{unsubscribeUrl}} answers 400 and no send is created. Without it, every single send would fail later for a reason the API never shows you. Fix the template, recreate the campaign, then send.
Calling send twice never sends twice. A campaign that already went out answers 409 and no second send is started — retrying after a timeout is safe. If you want to send the same content again, create a new campaign.
Then poll GET /api/v1/campaigns/{campaignId}: status moves draft → sending → sent, and progress fills up along the way. There is no webhook to wait for.

Authorization

Role in the organizationThis endpoint
OWNERAllowed
ADMINAllowed
MEMBERRefused — 403
A key carries the role its creator holds in this organization — never a role on AgentsMail itself. See API keys.

Example

bash
curl -X POST -H "x-api-key: $AGENTMAIL_API_KEY" \
  "https://www.agentsmail.io/api/v1/campaigns/$CAMPAIGN_ID/send"

Response

  • 202 Accepted — the send is queued; follow it on the campaign.
  • 400 Bad Request — the content has no unsubscribe link, or fails the same check as POST /api/v1/render. Nothing is emitted.
  • 401 Unauthorized — missing or invalid key, or its owner left the organization.
  • 403 Forbidden — the key's owner is a member of the organization, not an admin.
  • 404 Not Found — no such resource, or it belongs to another organization. The API never confirms that an id exists to a caller who has no right to it.
  • 409 Conflict — the sending domain is not verified yet, or the campaign is paused, sending, sent or failed.
  • 429 Too Many Requests — over 120 requests in a minute for this key.

Response fields

FieldTypeDescription
successbooleanIndicates if the operation was successful
data.campaignIdstringThe campaign whose send was requested
data.statusstringsend_requested

Example response

json
{
  "success": true,
  "data": {
    "campaignId": "6c6c6c6c-5555-4aaa-8bbb-999900001111",
    "status": "send_requested"
  }
}

Agent recipe

A send is asynchronous: the call returns once the departure is accepted, not once the emails are out. Poll the campaign to follow it — and stop polling when sending is disabled, or the loop never converges.
js
await fetch(`${base}/campaigns/${campaignId}/send`, {method: 'POST', headers})

for (;;) {
  const {data} = await (
    await fetch(`${base}/campaigns/${campaignId}`, {headers})
  ).json()

  if (!data.sendingEnabled) throw new Error('sending is paused: polling would never end')
  if (data.status === 'sent' || data.status === 'failed') return data
  await new Promise((resolve) => setTimeout(resolve, 5000))
}
Never call this without explicit human approval for that specific campaign. Approval for one send never covers the next one.