Skip to content
Internal: only for Sendwing’s own apps (the web app, admin). It may change at any time.

Create a campaign

POST
/api/organizations/{organizationId}/campaigns
curl --request POST \
--url https://api.sendwing.app/api/organizations/example/campaigns \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '{ "name": "example", "subject": "example", "previewText": "example", "fromName": "example", "fromEmail": "example", "replyTo": "example", "html": "example", "text": "example", "contentJson": "example", "contentVersion": 1, "markdown": "example", "audience": { "type": "all" }, "trackOpens": true, "trackClicks": true, "templateId": "example" }'

Creates a draft. Only name is required: the sender defaults to the workspace’s sending settings, and the audience to everyone subscribed. With templateId, the template’s subject, preview text and content are copied in; fields sent here win, and content sent here (markdown, html, text, contentJson, contentVersion) replaces the template’s as a whole. A design’s HTML is rendered from it; markdown comes back as saved.

organizationId
required
string

The workspace, like org_…. An OAuth access token works in the one the member picked when connecting, which GET /me returns.

Media typeapplication/json
object
name
required
string
>= 1 characters <= 200 characters
subject
Any of:
string
>= 1 characters <= 200 characters /^[^\r\n]*$/
previewText
Any of:
string
>= 1 characters <= 250 characters /^[^\r\n]*$/
fromName
Any of:
string
>= 1 characters <= 100 characters /^[^\r\n]*$/
fromEmail
string | null
replyTo
string | null
html
Any of:
string
>= 1 characters <= 500000 characters
text
Any of:
string
>= 1 characters <= 500000 characters
contentJson

The editor’s content, sent with contentVersion: an EmailDesign (2) without html, which is rendered from it, or the old editor’s document (1) with the html it rendered

Any of:
contentVersion
Any of:
Any of:
number
Allowed value: 1
markdown

The content as markdown, in place of contentJson: saved as the design it reads as. The MCP guide sendwing://guides/email says how to write it

string
>= 1 characters <= 200000 characters
audience
One of:
object
type
required
string
Allowed value: all
trackOpens
boolean
trackClicks
boolean
templateId

Like tpl_…

string

The draft

Media typeapplication/json
object
id
required

Like cmp_…

string
name
required

Internal name, never shown to contacts

string
status
required

draft until it’s sent or scheduled, and the only status where it can change; scheduled sends at scheduledAt; sending until every recipient is handled, then sent; canceled when stopped first

string
Allowed values: draft scheduled sending sent canceled
subject
required
string | null
previewText
required

The inbox snippet shown after the subject

string | null
fromName
required
string | null
fromEmail
required

On one of the workspace’s verified sending domains

string | null
replyTo
required
string | null
html

May use merge tags, like {{firstName}}. Lists leave out the content

string | null
text

The plain-text version; generated from html when null

string | null
contentJson

The editor’s content html was rendered from; null for HTML written by hand

Any of:
Any of:

A design of the email editor (contentVersion 2)

object
styles
required
object
backdrop
required

A colour like “#4f46e5”

string
default: #f4f4f5 /^#[0-9a-fA-F]{6}$/
background
required

A colour like “#4f46e5”

string
default: #ffffff /^#[0-9a-fA-F]{6}$/
textColor
required

A colour like “#4f46e5”

string
default: #1f2937 /^#[0-9a-fA-F]{6}$/
linkColor
required

A colour like “#4f46e5”

string
default: #2563eb /^#[0-9a-fA-F]{6}$/
brandColor
required

A colour like “#4f46e5”

string
default: #2563eb /^#[0-9a-fA-F]{6}$/
fontFamily
required
string
default: system
Allowed values: system arial verdana trebuchet georgia times courier
fontSize
required
integer
default: 16 >= 12 <= 24
sections
required
Array<object>
<= 100 items
object
id
required
string
/^[A-Za-z0-9_-]{1,64}$/
kind
required
string
default: content
Allowed values: content footer
layout
required
string
Allowed values: 1 2 3 4 1:2 2:1 1:3 3:1
columns
required
Array<Array>
background

A colour like “#4f46e5”

string
/^#[0-9a-fA-F]{6}$/
paddingTop
required
integer
default: 16 <= 120
paddingBottom
required
integer
default: 16 <= 120
paddingLeft
required
integer
0 <= 120
paddingRight
required
integer
0 <= 120
verticalAlign
required
string
default: top
Allowed values: top middle bottom
stackOnMobile
required
boolean
default: true
contentVersion

2 for a design, 1 for the old editor’s document

Any of:
integer
>= -9007199254740991 <= 9007199254740991
templateId
required

The template it started from, for reference; its content was copied

string | null
audience
required

Who receives the campaign

One of:
object
type
required
string
Allowed value: all
trackOpens
required
boolean
trackClicks
required
boolean
scheduledAt
required
Any of:
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
sendingStartedAt
required
Any of:
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
finishedAt
required

When it became sent or canceled

Any of:
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
recipientCount
required

How many contacts it’s sent to, counted when sending starts; null before

Any of:
integer
>= -9007199254740991 <= 9007199254740991
error
required

Why a scheduled campaign couldn’t start and went back to draft; cleared by the next send

string | null
paused
required

While set, a sending campaign sends nothing; resume it once the reason is fixed

Any of:
object
at
required
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
reason
required

sender_setup: the From domain’s setup was refused; plan_limit_exceeded: the workspace is over its plan’s contacts or members; monthly_email_limit: the plan’s emails for the month are used

Any of:
string
Allowed values: sender_setup plan_limit_exceeded monthly_email_limit
cancelWarnedAt
required

When the owners and admins were warned it’s been sending too long: it’s canceled 60 days after sendingStartedAt, and no sooner than 7 days after this

Any of:
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
createdBy
required

The user_… or key_… that created it

string | null
createdAt
required
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
updatedAt
required
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
markdown

The design as markdown, with ?include=markdown or when saved from markdown; null for content that isn’t a design

string | null

Example

{
"status": "draft",
"contentJson": {
"styles": {
"backdrop": "#f4f4f5",
"background": "#ffffff",
"textColor": "#1f2937",
"linkColor": "#2563eb",
"brandColor": "#2563eb",
"fontFamily": "system",
"fontSize": 16
},
"sections": [
{
"kind": "content",
"layout": "1",
"columns": [
[
{
"type": "heading",
"level": 1,
"content": [
{
"type": "text",
"marks": [
{
"type": "bold"
}
]
}
],
"align": "left"
}
]
],
"paddingTop": 16,
"paddingBottom": 16,
"paddingLeft": 0,
"paddingRight": 0,
"verticalAlign": "top",
"stackOnMobile": true
}
]
},
"audience": {
"type": "all"
},
"paused": {
"reason": "sender_setup"
}
}

The request isn’t valid; issues lists each problem

Media typeapplication/json
object
error
required

What went wrong, in words you can show people

string
issues

For a 400, each invalid field of the request; for a 422, what to fix first

Array<object>
object
path
required

The field, like events.0.name in the request or subject of what it acts on

string
message
required
string
requestId

For a 5xx: quote it when contacting support

string

Example generated

{
"error": "example",
"issues": [
{
"path": "example",
"message": "example"
}
],
"requestId": "example"
}

The API key or access token is missing, invalid or expired

Media typeapplication/json
object
error
required

What went wrong, in words you can show people

string
issues

For a 400, each invalid field of the request; for a 422, what to fix first

Array<object>
object
path
required

The field, like events.0.name in the request or subject of what it acts on

string
message
required
string
requestId

For a 5xx: quote it when contacting support

string

Example generated

{
"error": "example",
"issues": [
{
"path": "example",
"message": "example"
}
],
"requestId": "example"
}

The API key’s permissions, or the app’s scopes and the member’s role, don’t allow this

Media typeapplication/json
object
error
required

What went wrong, in words you can show people

string
issues

For a 400, each invalid field of the request; for a 422, what to fix first

Array<object>
object
path
required

The field, like events.0.name in the request or subject of what it acts on

string
message
required
string
requestId

For a 5xx: quote it when contacting support

string

Example generated

{
"error": "example",
"issues": [
{
"path": "example",
"message": "example"
}
],
"requestId": "example"
}

The request body is too large

Media typeapplication/json
object
error
required

What went wrong, in words you can show people

string
issues

For a 400, each invalid field of the request; for a 422, what to fix first

Array<object>
object
path
required

The field, like events.0.name in the request or subject of what it acts on

string
message
required
string
requestId

For a 5xx: quote it when contacting support

string

Example generated

{
"error": "example",
"issues": [
{
"path": "example",
"message": "example"
}
],
"requestId": "example"
}

Too many requests; wait for the seconds in Retry-After

Media typeapplication/json
object
error
required

What went wrong, in words you can show people

string
issues

For a 400, each invalid field of the request; for a 422, what to fix first

Array<object>
object
path
required

The field, like events.0.name in the request or subject of what it acts on

string
message
required
string
requestId

For a 5xx: quote it when contacting support

string

Example generated

{
"error": "example",
"issues": [
{
"path": "example",
"message": "example"
}
],
"requestId": "example"
}