> ## Documentation Index
> Fetch the complete documentation index at: https://docs.autosend.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Campaign

> Create a new email marketing campaign with sender, template, recipient lists, and scheduling options via the AutoSend API.

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.autosend.com/v1/campaigns' \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "name": "Spring Sale Newsletter",
      "subject": "Don'\''t miss our Spring Sale!",
      "previewText": "Up to 50% off this weekend only",
      "from": {
        "email": "hello@example.com",
        "name": "Example Team"
      },
      "replyTo": "support@example.com",
      "templateId": "60d5ec49f1b2c72d9c8b1234",
      "toLists": ["60d5ec49f1b2c72d9c8b0001"],
      "sendMode": "immediate",
      "publish": true,
      "sendNow": true,
      "trackingClick": true,
      "trackingOpen": true
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.autosend.com/v1/campaigns"
  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }
  payload = {
      "name": "Spring Sale Newsletter",
      "subject": "Don't miss our Spring Sale!",
      "previewText": "Up to 50% off this weekend only",
      "from": {
          "email": "hello@example.com",
          "name": "Example Team"
      },
      "replyTo": "support@example.com",
      "templateId": "60d5ec49f1b2c72d9c8b1234",
      "toLists": ["60d5ec49f1b2c72d9c8b0001"],
      "sendMode": "immediate",
      "publish": True,
      "sendNow": True,
      "trackingClick": True,
      "trackingOpen": True
  }

  response = requests.post(url, json=payload, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.autosend.com/v1/campaigns', {
    method: 'POST',
    headers: {
      Authorization: 'Bearer <token>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Spring Sale Newsletter',
      subject: "Don't miss our Spring Sale!",
      previewText: 'Up to 50% off this weekend only',
      from: {
        email: 'hello@example.com',
        name: 'Example Team',
      },
      replyTo: 'support@example.com',
      templateId: '60d5ec49f1b2c72d9c8b1234',
      toLists: ['60d5ec49f1b2c72d9c8b0001'],
      sendMode: 'immediate',
      publish: true,
      sendNow: true,
      trackingClick: true,
      trackingOpen: true,
    }),
  });
  const data = await response.json();
  console.log(data);
  ```

  ```php PHP theme={null}
  <?php
  $curl = curl_init();
  curl_setopt_array($curl, [
    CURLOPT_URL => 'https://api.autosend.com/v1/campaigns',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode([
      'name' => 'Spring Sale Newsletter',
      'subject' => "Don't miss our Spring Sale!",
      'previewText' => 'Up to 50% off this weekend only',
      'from' => [
        'email' => 'hello@example.com',
        'name' => 'Example Team',
      ],
      'replyTo' => 'support@example.com',
      'templateId' => '60d5ec49f1b2c72d9c8b1234',
      'toLists' => ['60d5ec49f1b2c72d9c8b0001'],
      'sendMode' => 'immediate',
      'publish' => true,
      'sendNow' => true,
      'trackingClick' => true,
      'trackingOpen' => true,
    ]),
    CURLOPT_HTTPHEADER => [
      'Authorization: Bearer <token>',
      'Content-Type: application/json',
    ],
  ]);
  $response = curl_exec($curl);
  curl_close($curl);
  echo $response;
  ```

  ```go Go theme={null}
  package main

  import (
  	"bytes"
  	"encoding/json"
  	"fmt"
  	"io"
  	"net/http"
  )

  func main() {
  	payload := map[string]interface{}{
  		"name":        "Spring Sale Newsletter",
  		"subject":     "Don't miss our Spring Sale!",
  		"previewText": "Up to 50% off this weekend only",
  		"from": map[string]string{
  			"email": "hello@example.com",
  			"name":  "Example Team",
  		},
  		"replyTo":       "support@example.com",
  		"templateId":    "60d5ec49f1b2c72d9c8b1234",
  		"toLists":       []string{"60d5ec49f1b2c72d9c8b0001"},
  		"sendMode":      "immediate",
  		"publish":       true,
  		"sendNow":       true,
  		"trackingClick": true,
  		"trackingOpen":  true,
  	}
  	body, _ := json.Marshal(payload)

  	req, _ := http.NewRequest("POST", "https://api.autosend.com/v1/campaigns", bytes.NewBuffer(body))
  	req.Header.Set("Authorization", "Bearer <token>")
  	req.Header.Set("Content-Type", "application/json")

  	client := &http.Client{}
  	resp, _ := client.Do(req)
  	defer resp.Body.Close()
  	respBody, _ := io.ReadAll(resp.Body)
  	fmt.Println(string(respBody))
  }
  ```

  ```java Java theme={null}
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;

  public class Main {
      public static void main(String[] args) throws Exception {
          String body = """
              {
                "name": "Spring Sale Newsletter",
                "subject": "Don't miss our Spring Sale!",
                "previewText": "Up to 50% off this weekend only",
                "from": { "email": "hello@example.com", "name": "Example Team" },
                "replyTo": "support@example.com",
                "templateId": "60d5ec49f1b2c72d9c8b1234",
                "toLists": ["60d5ec49f1b2c72d9c8b0001"],
                "sendMode": "immediate",
                "publish": true,
                "sendNow": true,
                "trackingClick": true,
                "trackingOpen": true
              }
              """;

          HttpClient client = HttpClient.newHttpClient();
          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://api.autosend.com/v1/campaigns"))
              .header("Authorization", "Bearer <token>")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(body))
              .build();
          HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
          System.out.println(response.body());
      }
  }
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'uri'
  require 'json'

  uri = URI('https://api.autosend.com/v1/campaigns')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(uri)
  request['Authorization'] = 'Bearer <token>'
  request['Content-Type'] = 'application/json'
  request.body = {
    name: 'Spring Sale Newsletter',
    subject: "Don't miss our Spring Sale!",
    previewText: 'Up to 50% off this weekend only',
    from: { email: 'hello@example.com', name: 'Example Team' },
    replyTo: 'support@example.com',
    templateId: '60d5ec49f1b2c72d9c8b1234',
    toLists: ['60d5ec49f1b2c72d9c8b0001'],
    sendMode: 'immediate',
    publish: true,
    sendNow: true,
    trackingClick: true,
    trackingOpen: true
  }.to_json

  response = http.request(request)
  puts JSON.parse(response.body)
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "id": "69d348dd0351e0c32be90342",
      "name": "Spring Sale Newsletter",
      "subject": "Don't miss our Spring Sale!",
      "previewText": "Up to 50% off this weekend only",
      "status": "scheduled",
      "sendMode": "immediate",
      "from": {
        "email": "hello@example.com",
        "name": "Example Team"
      },
      "replyTo": "support@example.com",
      "templateId": "A-280fa451a7ca5cc17513",
      "toLists": [
        {
          "id": "696e1158fbfc515799175f02",
          "name": "seg list",
          "type": "list",
          "contactCount": 3
        }
      ],
      "excludeLists": [],
      "sendNow": true,
      "sendToGlobalList": false,
      "metrics": {
        "sent": 0,
        "delivered": 0,
        "opened": 0,
        "suppressed": 0,
        "clicked": 0,
        "bounced": 0,
        "unsubscribed": 0,
        "spamReported": 0,
        "processedCount": 0,
        "totalContacts": 0,
        "failedCount": 0
      },
      "trackingClick": true,
      "trackingOpen": true,
      "source": "api",
      "createdAt": "2026-04-06T05:47:09.523Z",
      "updatedAt": "2026-04-06T05:52:38.949Z"
    },
    "message": "Campaign updated successfully"
  }
  ```
</ResponseExample>

### Authorizations

<ParamField path="Authorizations" type="string | header" required>
  Bearer authentication header of the form Bearer `<token>`, where `<token>` is your auth token.
</ParamField>

### Body

<ParamField body="name" type="string" required>
  Display name of the campaign. Between 1 and 200 characters.
</ParamField>

<ParamField body="subject" type="string" required>
  Email subject line. Between 1 and 998 characters.
</ParamField>

<ParamField body="previewText" type="string">
  Preview text shown in email clients before the message is opened. Maximum 200 characters.
</ParamField>

<ParamField body="from" type="object">
  Sender identity to use for this campaign.

  <Expandable title="from">
    <ParamField body="from.email" type="string">
      Sender email address. Must be a valid email.
    </ParamField>

    <ParamField body="from.name" type="string">
      Sender display name. Maximum 200 characters.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="fromSenderId" type="string">
  id of a saved sender identity. Mutually usable with `from`.
</ParamField>

<ParamField body="replyTo" type="string">
  Reply-to email address. Must be a valid email.
</ParamField>

<ParamField body="templateId" type="string">
  ID of the email template to use for this campaign. The template can be created via the [Template API](/api-reference/templates/create). Either `templateId` or `htmlTemplate` is required.
</ParamField>

<ParamField body="htmlTemplate" type="string">
  Raw HTML content to use as the campaign email body. Either `htmlTemplate` or `templateId` is required. If both are provided, `htmlTemplate` takes precedence and the template referenced by `templateId` will be updated with the provided HTML content.
</ParamField>

<ParamField body="toLists" type="array">
  Array of list or segment IDs to send the campaign to.
</ParamField>

<ParamField body="excludeLists" type="array">
  Array of list or segment IDs to exclude from sending.
</ParamField>

<ParamField body="unsubscribeGroupId" type="string">
  ID of the unsubscribe group to associate with this campaign.
</ParamField>

<ParamField body="sendNow" type="boolean">
  If `true`, the campaign will be scheduled to send after 120 seconds (2 minutes) from creation.
</ParamField>

<ParamField body="scheduledAt" type="string">
  ISO 8601 date-time string at which to schedule the campaign for sending.
</ParamField>

<ParamField body="sendToGlobalList" type="boolean">
  If `true`, the campaign is sent to all contacts in the global list.
</ParamField>

<ParamField body="publish" type="boolean">
  If `true`, publishes and finalizes the campaign.
</ParamField>

<ParamField body="trackingClick" type="boolean">
  Enable or disable click tracking for this campaign.
</ParamField>

<ParamField body="trackingOpen" type="boolean">
  Enable or disable open tracking for this campaign.
</ParamField>

<ParamField body="sendMode" type="string">
  Delivery mode. One of: `immediate`, `scheduled`, `gradual`.
</ParamField>

<ParamField body="gradualStrategy" type="string">
  Growth strategy for gradual sending. One of: `fixed`, `1.25x`, `1.5x`, `1.75x`, `2x`. Required when `sendMode` is `gradual`.
</ParamField>

<ParamField body="dailyBatchSize" type="integer">
  Number of emails to send per day in gradual mode. Must be at least `1`.
</ParamField>

<ParamField body="timezone" type="string">
  Timezone string (e.g. `America/New_York`) for scheduled or gradual sending.
</ParamField>

<ParamField body="defaultCampaign" type="boolean">
  Mark this campaign as the default campaign. Applies to create only.
</ParamField>

<ParamField body="builderType" type="string">
  Identifies the campaign builder type used to create this campaign. Applies to create only.
</ParamField>

### Response

<span className="text-sm">Returns the newly created campaign object.</span>

<ResponseField name="success" type="boolean">
  Indicates whether the request was successful.
</ResponseField>

<ResponseField name="message" type="string">
  A human-readable message describing the result.
</ResponseField>

<ResponseField name="data" type="object">
  The created campaign object.

  <Expandable title="data">
    <ResponseField name="id" type="string">
      Unique identifier of the new campaign.
    </ResponseField>

    <ResponseField name="name" type="string">
      Display name of the campaign.
    </ResponseField>

    <ResponseField name="subject" type="string">
      Email subject line.
    </ResponseField>

    <ResponseField name="previewText" type="string">
      Preview text shown in email clients.
    </ResponseField>

    <ResponseField name="status" type="string">
      Status of the campaign. When `sendNow` is `true`, this will be `scheduled`.
    </ResponseField>

    <ResponseField name="sendMode" type="string">
      Delivery mode: `immediate`, `scheduled`, or `gradual`.
    </ResponseField>

    <ResponseField name="from" type="object">
      Sender identity used for this campaign.
    </ResponseField>

    <ResponseField name="replyTo" type="string">
      Reply-to email address.
    </ResponseField>

    <ResponseField name="templateId" type="string">
      ID of the email template associated with this campaign.
    </ResponseField>

    <ResponseField name="toLists" type="array">
      Array of list objects the campaign is being sent to.
    </ResponseField>

    <ResponseField name="excludeLists" type="array">
      Array of excluded list or segment IDs.
    </ResponseField>

    <ResponseField name="sendNow" type="boolean">
      Whether the campaign is set to send immediately.
    </ResponseField>

    <ResponseField name="sendToGlobalList" type="boolean">
      Whether the campaign is sent to all contacts.
    </ResponseField>

    <ResponseField name="metrics" type="object">
      Campaign delivery and engagement metrics.
    </ResponseField>

    <ResponseField name="trackingClick" type="boolean">
      Whether click tracking is enabled.
    </ResponseField>

    <ResponseField name="trackingOpen" type="boolean">
      Whether open tracking is enabled.
    </ResponseField>

    <ResponseField name="source" type="string">
      How the campaign was created (e.g. `api`).
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      ISO 8601 timestamp when the campaign was created.
    </ResponseField>

    <ResponseField name="updatedAt" type="string">
      ISO 8601 timestamp when the campaign was last updated.
    </ResponseField>
  </Expandable>
</ResponseField>


## OpenAPI

````yaml POST /campaigns
openapi: 3.1.0
info:
  title: Autosend Campaigns API
  version: 1.0.0
  description: API endpoints for managing marketing campaigns in Autosend.
servers:
  - url: https://api.autosend.com/v1
    description: Production
security:
  - BearerAuth: []
paths:
  /campaigns:
    post:
      tags:
        - Campaigns
      summary: Create a new campaign
      description: Creates a new marketing campaign. MCP access allowed.
      operationId: createCampaign
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/CampaignBody'
                - required:
                    - name
                    - subject
                  properties:
                    defaultCampaign:
                      type: boolean
                      description: Mark as default campaign (create only).
                    builderType:
                      type: string
                      description: Campaign builder type (create only).
      responses:
        '200':
          description: Campaign created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessResponse'
        '400':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CampaignBody:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 200
          description: Display name of the campaign.
        subject:
          type: string
          minLength: 1
          maxLength: 998
          description: Email subject line.
        previewText:
          type: string
          maxLength: 200
          description: Preview text shown in email clients.
        from:
          type: object
          properties:
            email:
              type: string
              format: email
              description: Sender email address.
            name:
              type: string
              maxLength: 200
              description: Sender display name.
        fromSenderId:
          type: string
          description: Id of a saved sender identity.
        replyTo:
          type: string
          format: email
          description: Reply-to email address.
        templateId:
          type: string
          description: ID of the email template to use.
        toLists:
          type: array
          items:
            type: string
          description: List/segment IDs to send the campaign to.
        excludeLists:
          type: array
          items:
            type: string
          description: List/segment IDs to exclude from sending.
        unsubscribeGroupId:
          type: string
          description: ID of the unsubscribe group.
        sendNow:
          type: boolean
          description: If true, send the campaign immediately.
        scheduledAt:
          type: string
          format: date-time
          description: ISO 8601 date-time to schedule the campaign.
        sendToGlobalList:
          type: boolean
          description: If true, send to the entire global contact list.
        publish:
          type: boolean
          description: If true, publish/finalize the campaign.
        trackingClick:
          type: boolean
          description: Enable or disable click tracking.
        trackingOpen:
          type: boolean
          description: Enable or disable open tracking.
        sendMode:
          type: string
          enum:
            - immediate
            - scheduled
            - gradual
          description: How the campaign is delivered.
        gradualStrategy:
          type: string
          enum:
            - fixed
            - 1.25x
            - 1.5x
            - 1.75x
            - 2x
          description: Gradual send growth strategy (used when sendMode is 'gradual').
        dailyBatchSize:
          type: integer
          minimum: 1
          description: Number of emails to send per day in gradual mode.
        timezone:
          type: string
          description: Timezone string for scheduled sending.
    SuccessResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
        code:
          type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form Bearer <token>, where <token>
        is your auth token.

````