Create a campaign
const url = 'https://api.sendwing.app/api/organizations/example/campaigns';const options = { method: 'POST', headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'}, body: '{"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"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The workspace, like org_…. An OAuth access token works in the one the member picked when connecting, which GET /me returns.
Request Bodyrequired
Section titled “Request Bodyrequired”object
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
Like tpl_…
Responses
Section titled “Responses”The draft
object
Like cmp_…
Internal name, never shown to contacts
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
The inbox snippet shown after the subject
On one of the workspace’s verified sending domains
May use merge tags, like {{firstName}}. Lists leave out the content
The plain-text version; generated from html when null
The editor’s content html was rendered from; null for HTML written by hand
A design of the email editor (contentVersion 2)
object
object
A colour like “#4f46e5”
A colour like “#4f46e5”
A colour like “#4f46e5”
A colour like “#4f46e5”
A colour like “#4f46e5”
object
A colour like “#4f46e5”
A document of the old editor (contentVersion 1)
object
object
object
object
object
object
object
object
The template it started from, for reference; its content was copied
Who receives the campaign
object
object
Null once the mailing list is deleted
object
Null once the segment is deleted
object
Null once the tag is deleted
Why a scheduled campaign couldn’t start and went back to draft; cleared by the next send
While set, a sending campaign sends nothing; resume it once the reason is fixed
The user_… or key_… that created it
The design as markdown, with ?include=markdown or when saved from markdown; null for content that isn’t a design
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
object
What went wrong, in words you can show people
For a 400, each invalid field of the request; for a 422, what to fix first
object
The field, like events.0.name in the request or subject of what it acts on
For a 5xx: quote it when contacting support
Example generated
{ "error": "example", "issues": [ { "path": "example", "message": "example" } ], "requestId": "example"}The API key or access token is missing, invalid or expired
object
What went wrong, in words you can show people
For a 400, each invalid field of the request; for a 422, what to fix first
object
The field, like events.0.name in the request or subject of what it acts on
For a 5xx: quote it when contacting support
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
object
What went wrong, in words you can show people
For a 400, each invalid field of the request; for a 422, what to fix first
object
The field, like events.0.name in the request or subject of what it acts on
For a 5xx: quote it when contacting support
Example generated
{ "error": "example", "issues": [ { "path": "example", "message": "example" } ], "requestId": "example"}The request body is too large
object
What went wrong, in words you can show people
For a 400, each invalid field of the request; for a 422, what to fix first
object
The field, like events.0.name in the request or subject of what it acts on
For a 5xx: quote it when contacting support
Example generated
{ "error": "example", "issues": [ { "path": "example", "message": "example" } ], "requestId": "example"}Too many requests; wait for the seconds in Retry-After
object
What went wrong, in words you can show people
For a 400, each invalid field of the request; for a 422, what to fix first
object
The field, like events.0.name in the request or subject of what it acts on
For a 5xx: quote it when contacting support
Example generated
{ "error": "example", "issues": [ { "path": "example", "message": "example" } ], "requestId": "example"}