# POST /campaigns — Create Campaign

> Product: **Pabbly Email Marketing** (v2)
> Base URL: `https://emails.pabbly.com/api/v2`
> Auth: Bearer via `Authorization` header
> Canonical: `/email-marketing/campaigns/create-campaign`

Only HTML builder type is supported. The campaign is automatically set to "live" status and "API / Workflow Campaign" type. You can paste HTML content directly to create the campaign.EndFragment Body Fields

**Body parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| campaignDetails | object | No |  |
|   ↳ campaignName | string | No |  |
|   ↳ senderName | string | No |  |
|   ↳ subject | string | No |  |
|   ↳ preheaderText | string | No |  |
| builderType | string | No |  |
| content | string | No |  |

**Example request body:**

```json
{
  "campaignDetails": {
    "campaignName": "Welcome Newsletddter",
    "senderName": "John Doe",
    "subject": "Welcome to our newsletter",
    "preheaderText": "Check out our latest updates"
  },
  "builderType": "HTML",
  "content": "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Welcome</title></head><body style='font-family: Arial, sans-serif; padding: 20px; background-color: #f4f4f4;'><div style='max-width: 600px; margin: 0 auto; background-color: #ffffff; padding: 30px; border-radius: 8px;'><h1 style='color: #333; margin-bottom: 20px;'>Welcome to Our Newsletter!</h1><p style='color: #666; line-height: 1.6;'>Thank you for subscribing. We're excited to share amazing content with you.</p><a href='#' style='display: inline-block; margin-top: 20px; padding: 12px 24px; background-color: #007bff; color: #ffffff; text-decoration: none; border-radius: 4px;'>Get Started</a></div></body></html>"
}
```

**Response (201)** — Create Campaign:

```json
{
    "success": true,
    "status": "success",
    "message": "Campaign created successfully via public API.",
    "data": {
        "campaignDetails": {
            "campaignType": "API / Workflow Campaign",
            "campaignName": "Welcome Newsletddter",
            "senderName": "John Doe",
            "subject": "Welcome to our newsletter",
            "preheaderText": "Check out our latest updates"
        },
        "sendDetails": {
            "deliveryServerRouting": false,
            "deliveryServerRoutingConfig": []
        },
        "recipientDetails": {
            "includedList": [],
            "excludedList": [],
            "sentToIndividuals": [],
            "autoFollow": false
        },
        "totalStats": {
            "sent": 0,
            "delivered": 0,
            "failed": 0,
            "queued": 0,
            "opened": 0,
            "uniqueOpens": 0,
            "clicked": 0,
            "unsubscribed": 0,
            "bounced": 0,
            "softBounced": 0,
            "hardBounced": 0
        },
        "linksStats": {
            "clicks": 0
        },
        "batchProcessing": {
            "currentListIndex": 0,
            "currentBatchSkip": 0,
            "batchSize": 10000,
            "isInitialized": false,
            "processedSubscribers": 0,
            "allSubscribersQueued": false,
            "totalUniqueEmails": 0,
            "completionRetryCount": 0,
            "validationMismatch": false,
            "forceCompleted": false
        },
        "_id": "695264982011e7f242b9cd9c",
        "userId": "682db2da6ef7e93a3eceb126",
        "businessId": "69398c24e90b87748e209d9b",
        "campaignFolder": null,
        "status": "live",
        "templateId": "695264982011e7f242b9cd9e",
        "totalSubscribers": 0,
        "isDeleted": false,
        "deletedAt": null,
        "permanentDeleteAt": null,
        "countryStats": [],
        "deviceStats": [],
        "osStats": [],
        "createdAt": "2025-12-29T11:23:04.838Z",
        "updatedAt": "2025-12-29T11:23:04.841Z",
        "__v": 0
    }
}
```

**Code examples:**

_cURL_

```curl
curl -X POST https://emails.pabbly.com/api/v2/campaigns \
  -H "Authorization: Bearer {{YOUR_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{
    "campaignDetails": {
      "campaignName": "Welcome Newsletddter",
      "senderName": "John Doe",
      "subject": "Welcome to our newsletter",
      "preheaderText": "Check out our latest updates"
    },
    "builderType": "HTML",
    "content": "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Welcome</title></head><body style='font-family: Arial, sans-serif; padding: 20px; background-color: #f4f4f4;'><div style='max-width: 600px; margin: 0 auto; background-color: #ffffff; padding: 30px; border-radius: 8px;'><h1 style='color: #333; margin-bottom: 20px;'>Welcome to Our Newsletter!</h1><p style='color: #666; line-height: 1.6;'>Thank you for subscribing. We're excited to share amazing content with you.</p><a href='#' style='display: inline-block; margin-top: 20px; padding: 12px 24px; background-color: #007bff; color: #ffffff; text-decoration: none; border-radius: 4px;'>Get Started</a></div></body></html>"
  }'
```

_Ruby_

```ruby
require 'net/http'
require 'json'

uri = URI('https://emails.pabbly.com/api/v2/campaigns')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer {{YOUR_API_KEY}}'
request['Content-Type'] = 'application/json'
request.body = "{\"campaignDetails\":{\"campaignName\":\"Welcome Newsletddter\",\"senderName\":\"John Doe\",\"subject\":\"Welcome to our newsletter\",\"preheaderText\":\"Check out our latest updates\"},\"builderType\":\"HTML\",\"content\":\"<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Welcome</title></head><body style='font-family: Arial, sans-serif; padding: 20px; background-color: #f4f4f4;'><div style='max-width: 600px; margin: 0 auto; background-color: #ffffff; padding: 30px; border-radius: 8px;'><h1 style='color: #333; margin-bottom: 20px;'>Welcome to Our Newsletter!</h1><p style='color: #666; line-height: 1.6;'>Thank you for subscribing. We're excited to share amazing content with you.</p><a href='#' style='display: inline-block; margin-top: 20px; padding: 12px 24px; background-color: #007bff; color: #ffffff; text-decoration: none; border-radius: 4px;'>Get Started</a></div></body></html>\"}"

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
  http.request(request)
end

data = JSON.parse(response.body)
```

_Python_

```python
import requests

response = requests.post(
    'https://emails.pabbly.com/api/v2/campaigns',
    headers={'Authorization': 'Bearer {{YOUR_API_KEY}}'},
    json={
    'campaignDetails': {
        'campaignName': 'Welcome Newsletddter',
        'senderName': 'John Doe',
        'subject': 'Welcome to our newsletter',
        'preheaderText': 'Check out our latest updates'
    },
    'builderType': 'HTML',
    'content': '<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Welcome</title></head><body style='font-family: Arial, sans-serif; padding: 20px; background-color: #f4f4f4;'><div style='max-width: 600px; margin: 0 auto; background-color: #ffffff; padding: 30px; border-radius: 8px;'><h1 style='color: #333; margin-bottom: 20px;'>Welcome to Our Newsletter!</h1><p style='color: #666; line-height: 1.6;'>Thank you for subscribing. We're excited to share amazing content with you.</p><a href='#' style='display: inline-block; margin-top: 20px; padding: 12px 24px; background-color: #007bff; color: #ffffff; text-decoration: none; border-radius: 4px;'>Get Started</a></div></body></html>'
},
)

data = response.json()
```

_PHP_

```php
<?php
$ch = curl_init('https://emails.pabbly.com/api/v2/campaigns');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer {{YOUR_API_KEY}}', 'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"campaignDetails":{"campaignName":"Welcome Newsletddter","senderName":"John Doe","subject":"Welcome to our newsletter","preheaderText":"Check out our latest updates"},"builderType":"HTML","content":"<!DOCTYPE html><html><head><meta charset=\'UTF-8\'><title>Welcome</title></head><body style=\'font-family: Arial, sans-serif; padding: 20px; background-color: #f4f4f4;\'><div style=\'max-width: 600px; margin: 0 auto; background-color: #ffffff; padding: 30px; border-radius: 8px;\'><h1 style=\'color: #333; margin-bottom: 20px;\'>Welcome to Our Newsletter!</h1><p style=\'color: #666; line-height: 1.6;\'>Thank you for subscribing. We\'re excited to share amazing content with you.</p><a href=\'#\' style=\'display: inline-block; margin-top: 20px; padding: 12px 24px; background-color: #007bff; color: #ffffff; text-decoration: none; border-radius: 4px;\'>Get Started</a></div></body></html>"}');

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
```

_Java_

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
HttpRequest.Builder builder = HttpRequest.newBuilder()
    .uri(URI.create("https://emails.pabbly.com/api/v2/campaigns"))
    .header("Authorization", "Bearer {{YOUR_API_KEY}}")
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("{\"campaignDetails\":{\"campaignName\":\"Welcome Newsletddter\",\"senderName\":\"John Doe\",\"subject\":\"Welcome to our newsletter\",\"preheaderText\":\"Check out our latest updates\"},\"builderType\":\"HTML\",\"content\":\"<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Welcome</title></head><body style='font-family: Arial, sans-serif; padding: 20px; background-color: #f4f4f4;'><div style='max-width: 600px; margin: 0 auto; background-color: #ffffff; padding: 30px; border-radius: 8px;'><h1 style='color: #333; margin-bottom: 20px;'>Welcome to Our Newsletter!</h1><p style='color: #666; line-height: 1.6;'>Thank you for subscribing. We're excited to share amazing content with you.</p><a href='#' style='display: inline-block; margin-top: 20px; padding: 12px 24px; background-color: #007bff; color: #ffffff; text-decoration: none; border-radius: 4px;'>Get Started</a></div></body></html>\"}"));

HttpRequest request = builder.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

_Node.js_

```node
const response = await fetch('https://emails.pabbly.com/api/v2/campaigns', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer {{YOUR_API_KEY}}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "campaignDetails": {
      "campaignName": "Welcome Newsletddter",
      "senderName": "John Doe",
      "subject": "Welcome to our newsletter",
      "preheaderText": "Check out our latest updates"
    },
    "builderType": "HTML",
    "content": "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Welcome</title></head><body style='font-family: Arial, sans-serif; padding: 20px; background-color: #f4f4f4;'><div style='max-width: 600px; margin: 0 auto; background-color: #ffffff; padding: 30px; border-radius: 8px;'><h1 style='color: #333; margin-bottom: 20px;'>Welcome to Our Newsletter!</h1><p style='color: #666; line-height: 1.6;'>Thank you for subscribing. We're excited to share amazing content with you.</p><a href='#' style='display: inline-block; margin-top: 20px; padding: 12px 24px; background-color: #007bff; color: #ffffff; text-decoration: none; border-radius: 4px;'>Get Started</a></div></body></html>"
  }),
});

const data = await response.json();
```

_Go_

```go
package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    payload := strings.NewReader("{\"campaignDetails\":{\"campaignName\":\"Welcome Newsletddter\",\"senderName\":\"John Doe\",\"subject\":\"Welcome to our newsletter\",\"preheaderText\":\"Check out our latest updates\"},\"builderType\":\"HTML\",\"content\":\"<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Welcome</title></head><body style='font-family: Arial, sans-serif; padding: 20px; background-color: #f4f4f4;'><div style='max-width: 600px; margin: 0 auto; background-color: #ffffff; padding: 30px; border-radius: 8px;'><h1 style='color: #333; margin-bottom: 20px;'>Welcome to Our Newsletter!</h1><p style='color: #666; line-height: 1.6;'>Thank you for subscribing. We're excited to share amazing content with you.</p><a href='#' style='display: inline-block; margin-top: 20px; padding: 12px 24px; background-color: #007bff; color: #ffffff; text-decoration: none; border-radius: 4px;'>Get Started</a></div></body></html>\"}")
    req, _ := http.NewRequest("POST", "https://emails.pabbly.com/api/v2/campaigns", payload)
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Bearer {{YOUR_API_KEY}}")

    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)
    fmt.Println(string(body))
}
```

_.NET_

```dotnet
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://emails.pabbly.com/api/v2/campaigns");
request.Headers.TryAddWithoutValidation("Authorization", "Bearer {{YOUR_API_KEY}}");
request.Content = new StringContent("{\"campaignDetails\":{\"campaignName\":\"Welcome Newsletddter\",\"senderName\":\"John Doe\",\"subject\":\"Welcome to our newsletter\",\"preheaderText\":\"Check out our latest updates\"},\"builderType\":\"HTML\",\"content\":\"<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Welcome</title></head><body style='font-family: Arial, sans-serif; padding: 20px; background-color: #f4f4f4;'><div style='max-width: 600px; margin: 0 auto; background-color: #ffffff; padding: 30px; border-radius: 8px;'><h1 style='color: #333; margin-bottom: 20px;'>Welcome to Our Newsletter!</h1><p style='color: #666; line-height: 1.6;'>Thank you for subscribing. We're excited to share amazing content with you.</p><a href='#' style='display: inline-block; margin-top: 20px; padding: 12px 24px; background-color: #007bff; color: #ffffff; text-decoration: none; border-radius: 4px;'>Get Started</a></div></body></html>\"}");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

var response = await client.SendAsync(request);
var data = await response.Content.ReadAsStringAsync();
Console.WriteLine(data);
```

---

**Other endpoints in Campaigns:**

- [GET /campaigns — Get All Campaigns](/email-marketing/campaigns/get-all-campaigns)
- [GET /campaigns/{Campaign ID} — Get Campaign by ID](/email-marketing/campaigns/get-campaign-by-id)
- [POST /campaigns/send-to-individual — Send Campaign to Individual](/email-marketing/campaigns/send-campaign-to-individual)
- [POST /campaigns/send-to-list — Send Campaign to Lists](/email-marketing/campaigns/send-campaign-to-lists)

