Skip to main content
POST
/
v1
/
campaigns
Node.js SDK
import Migma from 'migma';

const migma = new Migma('YOUR_API_KEY');

const { data, error } = await migma.campaigns.create({
  projectId: 'PROJECT_ID',
  name: 'Investor Update',
  conversationId: 'CONVERSATION_ID',
  from: 'hello@yourbrand.migma.email',
  fromName: 'Your Brand',
  recipientType: 'tag',
  recipientId: 'TAG_ID'
});
{
  "success": true,
  "data": {
    "id": "<string>",
    "projectId": "<string>",
    "name": "<string>",
    "conversationId": "<string>",
    "subject": "<string>",
    "preheaderText": "<string>",
    "from": "jsmith@example.com",
    "fromName": "<string>",
    "replyTo": "<string>",
    "recipientType": "audience",
    "recipientId": "<string>",
    "topicId": "<string>",
    "estimatedRecipients": 123,
    "providerType": "ses",
    "variables": {},
    "status": "draft",
    "scheduledAt": "2023-11-07T05:31:56Z",
    "scheduledTimezone": "<string>",
    "batchId": "<string>",
    "sentAt": "2023-11-07T05:31:56Z",
    "completedAt": "2023-11-07T05:31:56Z",
    "error": "<string>",
    "triggeredBy": "manual",
    "createdAt": "2023-11-07T05:31:56Z",
    "updatedAt": "2023-11-07T05:31:56Z"
  },
  "error": "<string>"
}

Authorizations

Authorization
string
header
required

API key authentication. Use 'Authorization: Bearer YOUR_API_KEY' where YOUR_API_KEY is obtained from the Migma dashboard under Settings → API Integration.

Body

application/json
projectId
string
required

Project ID

name
string
required

Campaign name

conversationId
string
required

Conversation ID of the generated email to use as template

from
string<email>
required

Sender email address

fromName
string
required

Sender display name

recipientType
enum<string>
required

Send to a segment (audience) or tag

Available options:
audience,
tag
recipientId
string
required

Segment or tag ID

subject
string

Email subject (auto-populated from conversation if omitted)

preheaderText
string

Preheader text

replyTo
string<email>

Reply-to address

topicId
string

Topic ID for preference filtering

providerType
enum<string>

Email provider (default: migma)

Available options:
ses,
resend,
sendgrid,
mailgun,
migma
variables
object

Template variables

Response

Campaign created

success
boolean
required
data
object
error
string | null