Skip to Content
SendlySendly
API ReferenceCampaigns

Create a campaign

POST
/api/v1/campaigns

Create a campaign in DRAFT. Creating never sends — POST /api/v1/campaigns/{id}/send is the only operation that puts mail on the wire — so a campaign can be built up and reviewed before it costs anything.

The from address is checked against this project's verified domains before the campaign is written, so a campaign never exists with a sender it cannot use.

segment_id is required when audience_type is SEGMENT; audience_condition is required when it is FILTERED. Both answer 422 when missing.

audience_condition is checked when the campaign is written: a filter on a field contacts cannot be filtered on, or an operator that field does not have, answers 400 naming it. A list is not a filter field — to mail a list, send audience_type: "LIST" with a top-level list_id.

Requires the campaigns:write scope — Create, edit, and organize your campaigns.

headerAuthorizationBearer <API Key>

API key authentication. Use a sk_* (FULL) or pk_* (SENDING_ONLY) key as the bearer token. Public keys (pk_*) are restricted to the email-send endpoints and the self-serve list subscribe/unsubscribe pair; every other endpoint — event tracking included — answers 403 for them. In scope terms (used by /api/v1/* operations): FULL keys hold every scope; SENDING_ONLY keys hold only emails:send.

Idempotency-Key?string

Replay-safety key (24h TTL). Reuse it only to retry the identical request.

Length1 <= length <= 255
application/json
  1. body

Body for POST /api/v1/campaigns. segment_id is required when audience_type is SEGMENT, audience_condition when it is FILTERED, and list_id when it is LIST.

name*string
Length1 <= length <= 200
description?string
Lengthlength <= 500
subject*string
Length1 <= length
body*string
Length1 <= length
from*string

Sender address. Its domain must be verified for this project.

Formatemail
from_name?|
Lengthlength <= 100
reply_to?|
Formatemail
email_category?string
Default"MARKETING"
Value in"TRANSACTIONAL""MARKETING""SELF_MANAGED_UNSUBSCRIBE"
audience_type*string

ALL — every subscribed contact. FILTERED — the contacts matching audience_condition. SEGMENT — the members of segment_id. LIST — the CONFIRMED members of list_id, which is the only audience that honours double opt-in: a member who never confirmed, or who unsubscribed, is not mailed.

Value in"ALL""FILTERED""SEGMENT""LIST"
audience_condition?

A filter condition: one or more groups combined with logic.

segment_id?string
Formatuuid
list_id?string

Required when audience_type is LIST. Only that list's CONFIRMED members receive the campaign.

Formatuuid
topic_id?|

The subject this campaign is about. A contact who unsubscribed from the topic is excluded WHATEVER the audience type — a topic opt-out is a standing answer, not an audience filter, so it cannot be routed around by selecting a different audience. Ignored for TRANSACTIONAL campaigns, which a marketing preference does not cancel.

Formatuuid

Response Body

Campaign created

application/json
  1. response

A campaign as exposed on the v1 API.

id*string
Formatuuid
name*string
status*string
Value in"DRAFT""SCHEDULED""SENDING""PAUSED""SENT""CANCELLED"
subject*string
audience_type*string
Value in"ALL""FILTERED""SEGMENT""LIST"
list_id*|
Formatuuid
topic_id*|
Formatuuid
scheduled_at*|
Formatdate-time
sent_at*|
Formatdate-time
created_at*string
Formatdate-time
stats*
Example Request
curl -X POST 'https://api.sendly.now/api/v1/campaigns' \  -H 'Content-Type: application/json' \  -d '{  "name": "string",  "subject": "string",  "body": "string",  "from": "user@example.com",  "audience_type": "ALL"}'
Example Response
{  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",  "name": "string",  "status": "DRAFT",  "subject": "string",  "audience_type": "ALL",  "list_id": "430bbdbc-9d7f-4d06-a273-67ca4ba4ae4b",  "topic_id": "646807af-5da6-43aa-83d3-8ac1d15ab4e5",  "scheduled_at": "2019-08-24T14:15:22Z",  "sent_at": "2019-08-24T14:15:22Z",  "created_at": "2019-08-24T14:15:22Z",  "stats": {    "total_recipients": 0,    "sent": 0,    "delivered": 0,    "opened": 0,    "clicked": 0,    "bounced": 0  }}