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

# Create and Launch Campaign

> Creates a new SMS campaign and sends messages to all recipients. Recipients can be provided as an array, raw text, or from an existing contact book.



## OpenAPI

````yaml POST /campaigns
openapi: 3.0.0
info:
  title: ECSEND Developer API
  description: Public API for programmatically sending SMS and managing campaigns/contacts.
  version: 1.0.0
servers:
  - url: https://ecsend.paysgator.com
    description: Production Base URL
security:
  - ApiKeyAuth: []
paths:
  /campaigns:
    post:
      tags:
        - Campaigns
      summary: Create and launch a campaign
      description: >-
        Creates a new SMS campaign and sends messages to all recipients.
        Recipients can be provided as an array, raw text, or from an existing
        contact book.
      operationId: createCampaign
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCampaignRequest'
      responses:
        '201':
          description: Campaign created and launched
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateCampaignResponse'
        '400':
          description: Invalid request or no recipients
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: Insufficient balance
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Contact book not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CreateCampaignRequest:
      type: object
      required:
        - name
        - text
        - senderId
      properties:
        name:
          type: string
          description: Campaign name
          example: Summer Promo
        text:
          type: string
          description: Message content
          example: Get 20% off this summer!
        senderId:
          type: string
          description: Sender ID
          example: ECSEND
        recipients:
          type: array
          items:
            type: string
          description: Array of phone numbers
          example:
            - '+25884000001'
            - '+25884000002'
        rawReceivers:
          type: string
          description: Comma or newline separated phone numbers
          example: +25884000001,+25884000002
        contactBookName:
          type: string
          description: Name of existing contact book to use
          example: My Contacts
    CreateCampaignResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        campaignId:
          type: string
          example: clx456def
        status:
          type: string
          example: COMPLETED
        recipientCount:
          type: integer
          example: 100
    Error:
      type: object
      properties:
        error:
          type: string
          example: Unauthorized. Invalid or missing X-Api-Key.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key

````