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

# Create a campaign

> Creates a campaign mailing (a marketing email) for the authenticated customer. Creating a mailing only stores the content; use [send a campaign](/marketing/campaigns/send) or [schedule a campaign](/marketing/campaigns/schedule) to deliver it.

`subject` is required and must be unique within your account. An unsubscribe footer is appended to `html_part` automatically on save.

**Example curl command:**
```bash
curl -X POST \
https://api.paubox.com/v1/marketing/campaign_mailings \
  -H 'authorization: Token token=YOUR_API_KEY' \
  -H 'content-type: application/json' \
  -d '{
    "campaign_mailing": {
        "subject": "March newsletter",
        "html_part": "<html><body><div>Hello</div></body></html>",
        "text_part": "Hello",
        "template_type": "html"
    }
  }'
```




## OpenAPI

````yaml openapi2 POST /campaign_mailings
openapi: 3.0.3
info:
  title: Paubox Marketing API
  description: >
    Public documentation Paubox Marketing API. 


    All Paubox Marketing customers have access to the Paubox Marketing API to
    automate various tasks.


    ## Authentication

    Use the authorization header in requests with the format: `authorization:
    Token token=<API_KEY>`


    Replace `<API_KEY>` with your API key. Find your API key in the address bar
    from the email builder (note: each API Key is displayed only once upon
    creation).


    ## Base URL

    `https://api.paubox.com/v1/marketing`
  contact:
    name: Paubox Support
    url: https://www.paubox.com
  version: 1.0.0
servers:
  - url: https://api.paubox.com/v1/marketing
    description: Production server
security:
  - TokenAuth: []
tags:
  - name: subscribers
    description: Subscriber management operations
  - name: analytics
    description: Campaign analytics and reporting operations
  - name: campaign_mailings
    description: Campaign mailing management and sending operations
  - name: drip_campaigns
    description: Drip campaign management and automation operations
  - name: subscription_lists
    description: Subscription list management operations
  - name: subscriptions
    description: Subscriber opt-in and opt-out operations
  - name: tracking_links
    description: Tracking link analytics and data operations
paths:
  /campaign_mailings:
    post:
      tags:
        - campaign_mailings
      summary: Create a campaign mailing
      description: >
        Creates a campaign mailing (a marketing email) for the authenticated
        customer. Creating a mailing only stores the content; use [send a
        campaign](/marketing/campaigns/send) or [schedule a
        campaign](/marketing/campaigns/schedule) to deliver it.


        `subject` is required and must be unique within your account. An
        unsubscribe footer is appended to `html_part` automatically on save.


        **Example curl command:**

        ```bash

        curl -X POST \

        https://api.paubox.com/v1/marketing/campaign_mailings \
          -H 'authorization: Token token=YOUR_API_KEY' \
          -H 'content-type: application/json' \
          -d '{
            "campaign_mailing": {
                "subject": "March newsletter",
                "html_part": "<html><body><div>Hello</div></body></html>",
                "text_part": "Hello",
                "template_type": "html"
            }
          }'
        ```
      operationId: createCampaignMailing
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCampaignMailingRequest'
            example:
              campaign_mailing:
                subject: March newsletter
                html_part: <html><body><div>Hello</div></body></html>
                text_part: Hello
                template_type: html
        required: true
      responses:
        '200':
          description: >-
            The new campaign mailing's ID. If validation fails the response is
            still `200` but the body contains an `errors` array instead of
            `data`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CampaignMailingWriteResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    CreateCampaignMailingRequest:
      type: object
      properties:
        campaign_mailing:
          $ref: '#/components/schemas/CreateCampaignMailingRequest_campaign_mailing'
    CampaignMailingWriteResponse:
      type: object
      description: >-
        Returned with HTTP 200 in both the success and the validation-failure
        case. Check for the presence of `errors`.
      properties:
        data:
          $ref: '#/components/schemas/CampaignMailingWriteResponse_data'
        errors:
          type: array
          description: Validation messages, present only when the write failed
          items:
            type: string
    CreateCampaignMailingRequest_campaign_mailing:
      required:
        - subject
      type: object
      properties:
        subject:
          type: string
          description: Subject line. Required, and must be unique within your account.
        default_subject:
          type: string
          description: Fallback subject used when no subject is set on a send
        from:
          type: string
          description: From address for the mailing
        reply_to:
          type: string
          description: Reply-to address for the mailing
        html_part:
          type: string
          description: HTML body. An unsubscribe footer is appended automatically on save.
        text_part:
          type: string
          description: Plain-text body
        form_data:
          type: string
          description: JSON-encoded editor state, for mailings built in an editor
        template_type:
          type: string
          description: >-
            Editor the mailing is authored in, for example `quill`, `bee` or
            `html`. Defaults to `quill`.
          default: quill
    CampaignMailingWriteResponse_data:
      type: object
      properties:
        id:
          type: string
          description: UUID of the created or updated campaign mailing
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message
        code:
          type: string
          description: Error code
        details:
          type: object
          description: Additional error details
  responses:
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    TokenAuth:
      type: apiKey
      description: >-
        Token-based authentication. Use format: "Token token=<API_KEY>" where
        <API_KEY> is your API key
      name: authorization
      in: header

````