Skip to Content
API ReferenceCampaigns

Campaigns API

List and retrieve campaign information.

List Campaigns

Get a list of all campaigns in your organization.

Endpoint

GET /api/campaigns

Example Request

curl -X GET NEXT_PUBLIC_BASE_URL/api/campaigns \ -H "x-api-key: your-api-key"

Response Schema

FieldTypeDescription
campaignsarrayList of campaigns
campaigns[].idstringCampaign unique identifier
campaigns[].namestringCampaign name
campaigns[].createdAtstringISO 8601 timestamp of creation

Example Response

{ "campaigns": [ { "id": "clxyz123", "name": "Welcome Series", "createdAt": "2024-01-15T10:30:00.000Z" }, { "id": "clxyz456", "name": "Newsletter January", "createdAt": "2024-01-10T08:00:00.000Z" } ] }

Get Campaign Details

Get detailed information about a specific campaign including all emails.

Endpoint

GET /api/campaigns/:id

Path Parameters

ParameterTypeDescription
idstringCampaign ID

Example Request

curl -X GET NEXT_PUBLIC_BASE_URL/api/campaigns/clxyz123 \ -H "x-api-key: your-api-key"

Response Schema

FieldTypeDescription
idstringCampaign ID
namestringCampaign name
createdAtstringISO 8601 timestamp
statsobjectCampaign statistics
stats.totalEmailsnumberTotal emails in campaign
stats.totalOpensnumberTotal opens across all emails
stats.totalClicksnumberTotal clicks across all emails
stats.openRatenumberOpen rate percentage
stats.clickRatenumberClick rate percentage
linksarrayAggregated link statistics
links[].urlstringOriginal link URL
links[].clicksnumberTotal clicks on this link
emailsarrayList of emails in the campaign

Example Response

{ "id": "clxyz123", "name": "Welcome Series", "createdAt": "2024-01-15T10:30:00.000Z", "stats": { "totalEmails": 1250, "totalOpens": 856, "totalClicks": 302, "openRate": 68.48, "clickRate": 24.16 }, "links": [ { "url": "https://example.com/signup", "clicks": 156 }, { "url": "https://example.com/learn-more", "clicks": 89 } ], "emails": [ { "id": "email123", "trackingId": "hE4kJ9", "recipient": "user@example.com", "subject": "Welcome to our service!", "createdAt": "2024-01-15T10:32:00.000Z", "opens": 2, "clicks": 1 } ] }

Create Campaign

Create a new campaign in your organization.

Endpoint

POST /api/campaigns

Request Body

FieldTypeRequiredDescription
namestringYesCampaign name (must be unique within the organization)

Example Request

curl -X POST NEXT_PUBLIC_BASE_URL/api/campaigns \ -H "x-api-key: your-api-key" \ -H "Content-Type: application/json" \ -d '{"name": "Welcome Series"}'

Response Schema

FieldTypeDescription
idstringCampaign unique identifier
namestringCampaign name
createdAtstringISO 8601 timestamp of creation

Example Response

{ "id": "clxyz123", "name": "Welcome Series", "createdAt": "2024-01-15T10:30:00.000Z" }

Archive Campaign

Archive a campaign. Archived campaigns are excluded from campaign lists and no longer accept new emails.

Endpoint

POST /api/campaigns/:id/archive

Path Parameters

ParameterTypeDescription
idstringCampaign ID

Example Request

curl -X POST NEXT_PUBLIC_BASE_URL/api/campaigns/clxyz123/archive \ -H "x-api-key: your-api-key"

Example Response

{ "success": true }

Error Responses

StatusDescription
400 Bad RequestMissing required fields or campaign already archived
401 UnauthorizedInvalid or missing API key
403 ForbiddenCampaign limit reached on current plan
404 Not FoundCampaign not found or doesn’t belong to your organization
409 ConflictA campaign with this name already exists

Example Error

{ "error": "Campaign not found" }
Last updated on
Mailpulse Documentation