PlunkPlunk
API ReferenceCampaigns

Create campaign

Create a new email campaign. Campaigns are created as DRAFT; use POST /campaigns/{id}/send to send or schedule one.

The sender domain must already be verified for this project.

Audience: audienceType decides which companion field is required — SEGMENT requires segmentId, FILTERED requires audienceCondition, and ALL requires neither.

POST
/campaigns

Authorization

ApiKeyAuth

AuthorizationBearer <token>

API Key authentication. The project is automatically derived from the key.

/v1/track requires a public key (pk_*) — it is the one endpoint intended for client-side use, and a secret key is rejected there with 401.

Every other endpoint requires a secret key (sk_*) and rejects public keys with 401.

So the two key types are not interchangeable in either direction: pick the key that matches the endpoint you are calling.

In: header

Request Body

application/json

name*string

Campaign name

description?string

Campaign description

subject*string

Email subject line

body*string

HTML email body

from*string

Sender email address (must be from verified domain)

Formatemail
fromName?string

Sender name

replyTo?string

Reply-to email address

Formatemail
type?string

Content type of the campaign email. Defaults to MARKETING.

Default"MARKETING"
Value in"TRANSACTIONAL" | "MARKETING" | "HEADLESS"
audienceType*string

Target audience type

Value in"ALL" | "SEGMENT" | "FILTERED"
segmentId?string

Segment ID. Required when audienceType is SEGMENT.

Formatuuid
audienceCondition?

Audience filter tree. Required when audienceType is FILTERED. Same structure as a segment's condition.

Response Body

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://api.plunk.jimster.dev/campaigns" \  -H "Content-Type: application/json" \  -d '{    "name": "March newsletter",    "subject": "What shipped in March",    "body": "<h1>Hello {{firstName}}</h1>",    "from": "news@example.com",    "fromName": "Example",    "audienceType": "ALL"  }'
{
  "success": true,
  "data": {
    "id": "string",
    "name": "string",
    "description": "string",
    "subject": "string",
    "body": "string",
    "from": "user@example.com",
    "fromName": "string",
    "replyTo": "user@example.com",
    "type": "TRANSACTIONAL",
    "status": "DRAFT",
    "audienceType": "ALL",
    "audienceCondition": {
      "logic": "AND",
      "groups": [
        {
          "filters": [
            {
              "field": "string",
              "operator": "equals",
              "value": null,
              "unit": "days"
            }
          ],
          "conditions": {
            "logic": "AND",
            "groups": []
          }
        }
      ]
    },
    "segmentId": "string",
    "scheduledFor": "2019-08-24T14:15:22Z",
    "totalRecipients": 0,
    "sentCount": 0,
    "deliveredCount": 0,
    "openedCount": 0,
    "clickedCount": 0,
    "bouncedCount": 0,
    "projectId": "string",
    "sentAt": "2019-08-24T14:15:22Z",
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z"
  }
}
{
  "success": false,
  "error": {
    "code": "string",
    "message": "string",
    "statusCode": 0,
    "requestId": "string",
    "errors": [
      {
        "field": "string",
        "message": "string",
        "code": "string",
        "received": null
      }
    ],
    "details": {},
    "suggestion": "string"
  },
  "timestamp": "2019-08-24T14:15:22Z"
}
{
  "success": false,
  "error": {
    "code": "INVALID_API_KEY",
    "message": "Invalid secret API key. This endpoint requires a secret key (sk_*), not a public key.",
    "statusCode": 401,
    "requestId": "8f14e45f-ceea-467a-9575-1f0f38e0b1c2"
  },
  "timestamp": "2025-01-15T10:30:00.000Z"
}
{
  "success": false,
  "error": {
    "code": "INTERNAL_SERVER_ERROR",
    "message": "Domain \"example.com\" is not verified. Please complete the DNS verification process in your domain settings.",
    "statusCode": 403,
    "requestId": "8f14e45f-ceea-467a-9575-1f0f38e0b1c2"
  },
  "timestamp": "2025-01-15T10:30:00.000Z"
}
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Request validation failed",
    "statusCode": 422,
    "requestId": "8f14e45f-ceea-467a-9575-1f0f38e0b1c2",
    "errors": [
      {
        "field": "to",
        "message": "Invalid email",
        "code": "invalid_string"
      }
    ],
    "suggestion": "Please check the API documentation for the correct request format."
  },
  "timestamp": "2025-01-15T10:30:00.000Z"
}