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

# Create Campaign

> > A newer version of this endpoint with more options is available: [Create Campaign (v2)](/api-reference/campaigns/create-campaign-v2).

API for creating an email campaign. For creating a campaign, HTML or plain text and list id or segment are mandatory.



## OpenAPI

````yaml /openapi-v1.json post /campaign
openapi: 3.1.0
info:
  title: Mailercloud Marketing API
  version: 1.0.0
  description: >-
    Campaigns, contacts, lists, segments, automations, and webhooks for the
    Mailercloud Marketing Platform.
servers:
  - url: https://cloudapi.mailercloud.com/v1
security:
  - apiKey: []
tags:
  - name: Campaigns
  - name: Contacts
  - name: Lists
  - name: Tags
  - name: Segments
  - name: Custom Properties
  - name: Senders
  - name: Templates
  - name: Automations
  - name: Webhooks
  - name: Webforms
  - name: Inbox Tracker
  - name: Account
paths:
  /campaign:
    post:
      tags:
        - Campaigns
      summary: Create Campaign
      description: >-
        > A newer version of this endpoint with more options is available:
        [Create Campaign (v2)](/api-reference/campaigns/create-campaign-v2).


        API for creating an email campaign. For creating a campaign, HTML or
        plain text and list id or segment are mandatory.
      operationId: create-campaign
      parameters:
        - name: Content-Type
          in: header
          required: true
          description: Request body type
          schema:
            type: string
            default: application/json
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - list_ids
                - name
                - sender
                - subject
              properties:
                email_preheader:
                  type: string
                  minLength: 1
                  description: >-
                    Email preheader is the summary text that follows a subject
                    line when the email is viewed in an inbox. In many cases,
                    it’s used to provide a short summary of the email, and is
                    typically one sentence long.


                    Minimum: 1


                    Maximum: 150
                html:
                  type: string
                  minLength: 1
                  description: HTML template content for your email campaign.
                list_ids:
                  type: array
                  description: Recipients of your email campaign.
                  items:
                    type: string
                    description: >-
                      List of contact lists ids, to which you want to send your
                      campaign. 


                      Format: Array of strings.
                mailing_preference:
                  type: boolean
                  description: >-
                    true - Mailing preference option will be displayed in footer
                    of email campaign template.


                    false - Mailing preference option will not be dispalyed.
                  default: true
                name:
                  type: string
                  minLength: 1
                  description: |-
                    Name of the campaign.

                    Minimum: 1

                    Maximum: 150
                pause_rules:
                  type: object
                  description: >-
                    Optional


                    If you want to set a rule for sending a campaign, use this
                    option. Based on the configured rule, the campaign will be
                    sent.
                  required:
                    - pause_condition
                    - pause_criteria
                    - pause_limit
                    - pause_target
                    - wait_time
                  properties:
                    pause_condition:
                      type: string
                      minLength: 1
                      description: >-
                        Rule for setting open or click percentage greater than
                        or less than pause target.


                        Supported pause_condition - greater than, less than
                    pause_criteria:
                      type: string
                      minLength: 1
                      description: Supported pause_criteria - open, click
                    pause_limit:
                      type: number
                      description: >-
                        The percentage of list contacts to which we want to send
                        campaigns first. In the order we set in rules.


                        Minimum: 1


                        Maximum: 50
                    pause_target:
                      type: number
                      description: |-
                        Value  of open/click (in percentage) to be achieved.

                        Minimum: 1

                        Maximum: 100
                    wait_time:
                      type: number
                      description: >-
                        After getting click rate or open rate grater than or
                        less than pause limit , How many time we have to wait to
                        send campaign to other contacts in the list.


                        Wait time in minutes .


                        Minimum: 1


                        Maximum: 43200
                permission_reminder:
                  type: string
                  minLength: 1
                  description: >-
                    The email disclaimer content in your email campaign. If you
                    want give unsubscribe link give %%unsubscribe%%


                    Minimum: 1


                    Maximum: 150
                plain_text:
                  type: string
                  minLength: 1
                  description: Plain text content of your email campaign.
                reply_email:
                  type: string
                  minLength: 1
                  description: >-
                    Email on which the campaign recipients will be able to reply
                    to. If replay_email empty then sender email will be the
                    reply email.
                report_spam:
                  type: boolean
                  description: Spam reporting enable or disable.
                  default: true
                rules:
                  type: object
                  properties:
                    limit:
                      type: number
                      description: >-
                        Count of subscribers in list to which campaign sends
                        based on the contacts_order.
                    contacts_order:
                      type: string
                      description: >-
                        The order of contact list in which you want to send your
                        email campaign.


                        Supported: first,last
                scheduled_at:
                  type: string
                  minLength: 1
                  description: >-
                    Schedule time for your email campaign. Pass your timezone
                    date-time format for accurate results.


                    Format: 2021-04-23 15:04:05
                segments:
                  type: string
                  minLength: 1
                  description: Your recipient segment id.
                sender:
                  type: object
                  required:
                    - sender_email
                    - sender_name
                  properties:
                    sender_email:
                      type: string
                      minLength: 1
                      description: From email for your email campaign.
                    sender_name:
                      type: string
                      minLength: 1
                      description: |-
                        From name for email campaign.

                        Maximum: 100
                subject:
                  type: string
                  minLength: 1
                  description: |-
                    Subject of the campaign.

                    Minimum: 1

                    Maximum: 150
                viewin_browser:
                  type: boolean
                  description: >-
                    true: Enable the "View this email in your browser"  in
                    Campaign preview page.


                    false: Disable the "View this email in your browser"  in
                    Campaign preview page.
                  default: true
            examples:
              example-1:
                value:
                  html: <html><body> Sample HTML  </body></html>
                  list_ids:
                    - sCVJ
                    - ghy
                  name: Campaign name
                  sender:
                    sender_email: sender@yourdomain.com
                    sender_name: Sender Name
                  scheduled_at: '2021-04-17 15:48:00'
                  subject: Prime member notification.
              example-2:
                value:
                  email_preheader: 'Prime member: You have an unused Prime benefit'
                  rules:
                    contacts_order: last
                    limit: 5
                  report_spam: false
                  mailing_preference: false
                  name: Campaign name
                  pause_rules:
                    pause_limit: 1
                    pause_criteria: open
                    pause_condition: greater than
                    pause_target: 1
                    wait_time: 10
                  permission_reminder: >-
                    If you wish to opt out of all type of emails, click
                    Unsubscribe. 
                  plain_text: plain text
                  reply_email: sender@yourdomain.com
                  sender:
                    sender_email: sender@yourdomain.com
                    sender_name: Sender Name
                  segments: hju
                  subject: Prime member notification.
                  viewin_browser: false
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                description: ''
                type: object
                properties: {}
              examples:
                example-1:
                  value:
                    id: hdjh
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                description: ''
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      field:
                        type: string
                        minLength: 1
                      message:
                        type: string
                        minLength: 1
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        field:
                          type: string
                        message:
                          type: string
              examples:
                example-1:
                  value:
                    errors:
                      - field: sender_email
                        message: sender_email  must be a valid email address
                      - field: reply_email
                        message: reply_email  must be a valid email address
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                description: ''
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      field:
                        type: string
                        minLength: 1
                      message:
                        type: string
                        minLength: 1
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        field:
                          type: string
                        message:
                          type: string
              examples:
                example-1:
                  value:
                    errors:
                      - field: ''
                        message: Authorization failed
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Your Mailercloud API key (plain text, no Bearer prefix). Create keys in
        Settings → API.

````