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

# Update a campaign

> Partial update (PUT is accepted too) of a draft, failed or paused campaign.



## OpenAPI

````yaml /api-reference/v2.0/openapi.json patch /campaigns/{id}
openapi: 3.1.0
info:
  title: Shortext API
  description: >-
    **Versioning**: every version is a frozen contract. A released version only
    receives additive changes

    (new endpoints, new optional fields, new response fields); anything breaking
    ships in a new version.

    Responses carry `X-Shortext-Api-Version`. When a version is scheduled for
    removal, responses also carry

    `Deprecation` and `Sunset` headers; after the sunset date the version
    answers HTTP 410.

    The list of versions and their status is available at `GET /api/versions`.


    **Responses**: always HTTP 200. Check `success` and `code` (`1000` =
    success), see `ApiEnvelope`.

    On failure, `trace_id` identifies the request for support.


    **Rate limit**: 300 requests per minute per company, shared by all its keys
    and by every API version.

    Responses carry `X-RateLimit-Limit` and `X-RateLimit-Remaining`; beyond the
    limit the API answers

    HTTP 429 with `Retry-After` (seconds) and the usual envelope. Prefer
    webhooks to polling.
  version: '2.0'
servers:
  - url: https://shortext.ny-corp.io/api/v2.0
security: []
tags:
  - name: Agents
    description: Agents
  - name: Knowledge
    description: Knowledge
  - name: Dynamic links
    description: Dynamic links
  - name: Billing
    description: Billing
  - name: Campaigns
    description: Campaigns
  - name: Channels
    description: Channels
  - name: Conversations
    description: Conversations
  - name: Follow-ups
    description: Follow-ups
  - name: Account
    description: Account
  - name: Tickets
    description: Tickets
  - name: Templates
    description: Templates
  - name: Hosted sessions
    description: Hosted sessions
  - name: Webhooks
    description: Webhooks
paths:
  /campaigns/{id}:
    patch:
      tags:
        - Campaigns
      summary: Update a campaign
      description: >-
        Partial update (PUT is accepted too) of a draft, failed or paused
        campaign.
      operationId: updateCampaign
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CampaignInput'
      responses:
        '200':
          description: >-
            Always HTTP 200: the outcome is in `success` and `code` (absolute
            value of the response code).
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiEnvelope'
                  - properties:
                      body:
                        $ref: '#/components/schemas/Campaign'
                    type: object
      security:
        - bearerAuth: []
components:
  schemas:
    CampaignInput:
      description: >-
        On update, only the fields given change. A scheduled or running campaign
        cannot be edited: pause it first.
      properties:
        name:
          description: Required on creation
          type: string
          maxLength: 255
        category:
          description: >-
            Required on creation. Contacts who unsubscribed get no marketing
            campaign.
          type: string
          enum:
            - marketing
            - transactional
            - specialized
        objective:
          type:
            - string
            - 'null'
        trigger:
          description: Required on creation
          type: string
          enum:
            - scheduled
            - new_conversation
        once_per_contact:
          type: boolean
        send_delay_minutes:
          description: 'Automatic campaigns: wait after the conversation starts'
          type: integer
        min_inactive_minutes:
          description: 'Automatic campaigns: wait for the conversation to be quiet'
          type: integer
        channels:
          description: The senders, by their channel_id (GET /channels)
          type: array
          items:
            properties:
              channel_id:
                type: string
            type: object
        messages:
          description: >-
            `whatsapp`: `{ template_id, variables: { name: { source, value?,
            fallback? } }, buttons?: { index: value }, header_url? }` (source:
            `field:firstname|lastname|name|email|phone|address|identifier`,
            `column:<key>` of the imported file, or `text` with `value`); an
            automatic campaign may send `{ text }` instead. `mail`: `{ subject,
            html }`. Texts accept `@firstname`, `@<column>` and
            `@{key|fallback}`.
          type: object
        audience:
          description: >-
            Scheduled campaigns: `{ source: "segment", segment_id }`, `{ source:
            "file", import_id, save_as_segment? }` (a checked file, POST
            /campaign-imports) or `{ source: "contacts", contact_ids }`
          type: object
        start_at:
          type:
            - string
            - 'null'
          format: date-time
        end_at:
          description: Required to launch
          type: string
          format: date-time
        send_window:
          type:
            - object
            - 'null'
          example:
            start: '08:00'
            end: '20:00'
        follow_up_intention_ids:
          type: array
          items:
            type: string
      type: object
    ApiEnvelope:
      properties:
        success:
          type: boolean
          example: true
        code:
          type: integer
          example: 1000
        message:
          type: string
          example: Request success.
        body:
          description: Endpoint payload, null when there is none
        token:
          description: Present only on authentication routes
          type:
            - string
            - 'null'
        trace_id:
          description: Present only when success is false
          type:
            - string
            - 'null'
      type: object
    Campaign:
      properties:
        id:
          description: >-
            Public representation of campaigns, their contact files and segments
            (API v2.0)
          type: string
          example: CMP-XXXXX
        name:
          type: string
        category:
          type: string
          enum:
            - marketing
            - transactional
            - specialized
        objective:
          type:
            - string
            - 'null'
        trigger:
          description: >-
            `scheduled`: sent once to an audience. `new_conversation`: sent on
            each new conversation while active.
          type: string
          enum:
            - scheduled
            - new_conversation
        status:
          type: string
          enum:
            - draft
            - scheduled
            - active
            - paused
            - ended
            - failed
        failure_reason:
          type:
            - string
            - 'null'
        once_per_contact:
          description: 'Automatic campaigns: a contact gets the message once'
          type:
            - boolean
            - 'null'
        channels:
          type: array
          items:
            properties:
              channel:
                type: string
                enum:
                  - whatsapp
                  - mail
              channel_id:
                description: 'The sender: WhatsApp phone number id or mailbox id (mbx_...)'
                type: string
            type: object
        messages:
          description: One message per channel, by channel
          type: object
          example:
            whatsapp:
              type: template
              template:
                id: TPL-XXXXX
                name: promo
                language: fr
              variables:
                name:
                  source: field:firstname
                  fallback: client
              buttons:
                - promo-@firstname
            mail:
              type: email
              subject: Our offer, @{firstname|dear customer}
        audience:
          properties:
            source:
              type: string
              enum:
                - segment
                - file
                - contacts
            segment_id:
              type:
                - string
                - 'null'
            import_id:
              type:
                - string
                - 'null'
            recipients:
              description: >-
                Recipients written to the campaign (a segment is evaluated when
                it starts)
              type: integer
          type: object
        start_at:
          type:
            - string
            - 'null'
          format: date-time
        end_at:
          description: Replies count for the campaign until this date
          type:
            - string
            - 'null'
          format: date-time
        send_window:
          description: Hours of the day it may send, in the company time zone
          properties:
            start:
              type: string
              example: '08:00'
            end:
              type: string
              example: '20:00'
          type:
            - object
            - 'null'
        follow_up_intention_ids:
          type: array
          items:
            type: string
        paused_at:
          type:
            - string
            - 'null'
          format: date-time
        duplicated_from:
          type:
            - string
            - 'null'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      type: object
  securitySchemes:
    bearerAuth:
      type: http
      description: >-
        Company API key, sent as `Authorization: Bearer <key>`. Create it in the
        dashboard (Developer > API Keys) with the permissions the integration
        needs.
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.