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

# Update a campaign by ID. Only campaigns with status "draft" can be updated.



## OpenAPI

````yaml /openapi/chat-client.yaml put /whatsapp/campaigns/{id}
openapi: 3.0.3
info:
  version: 1.0.0
  title: HealviChat Client API
servers:
  - url: https://{tenant_domain}/third-party/v1
    variables:
      tenant_domain:
        default: your-tenant.onhealvi.com
        description: Your tenant domain
security:
  - bearerAuth: []
paths:
  /whatsapp/campaigns/{id}:
    put:
      tags:
        - whatsapp
      summary: >-
        Update a campaign by ID. Only campaigns with status "draft" can be
        updated.
      parameters:
        - in: path
          name: id
          schema:
            type: integer
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpsertWhatsappCampaign'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/WhatsappCampaign'
components:
  schemas:
    UpsertWhatsappCampaign:
      type: object
      properties:
        name:
          type: string
        agent_id:
          description: ID of WhatsApp agent to use for creating the campaign.
          type: integer
          nullable: true
        template_name:
          description: Name of template to send.
        template_language:
          description: Language of template to send.
          example: de
        template_components:
          description: >
            Array of objects describing how to fill variables within the
            specified template.

            If there are no variables, set this to an empty array.

            Format is defined by WhatsApp. See `components` under
            https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates
          type: array
          items:
            type: object
        recipients:
          type: array
          items:
            type: object
            properties:
              profile_id:
                description: >-
                  Optional ID of profile. Only used to have a reference. No data
                  is copied from the profile.
                type: integer
                nullable: true
              name:
                description: Optional name of recipient. Phone number is used if not set.
                type: string
                nullable: true
              phone_number:
                description: >-
                  Required phone number of recipient. Must be in international
                  format. See example.
                type: string
                example: 4915212345678
              placeholders:
                type: object
                description: >
                  Key-value object with the values for placeholders when used to
                  fill variables.

                  Used as is, no delimiters are added.
        start_at:
          description: >
            When to start the campaign in UTC. Only relevant when status is
            "in_progress".

            When messaging limit is hit for agent, campaign will pause
            automatically and resume

            the next day at the same time.
          type: string
          format: date-time
          example: '2023-01-01T12:00:00Z'
        send_from:
          description: >
            Together with send_until: time window to send the campaign. Can be
            used such that customers do not receive

            messages in the middle of the night.
          type: string
          example: '00:00:00'
        send_until:
          description: See send_from.
          type: string
          example: '23:59:59'
        assign_bot_id:
          description: |
            Optional ID of bot which will be assigned to the conversation.
            Existing running bot will be stopped and a new one will be started.
          type: integer
          nullable: true
        assign_user_id:
          description: |
            Optional ID of user the conversation will be assigned to.
          type: integer
          nullable: true
        assign_folder_id:
          description: |
            Optional ID of folder the conversation will be assigned to.
          type: integer
          nullable: true
    WhatsappCampaign:
      description: WhatsApp campaign (marketing).
      type: object
      properties:
        id:
          type: integer
          description: Internal ID.
        name:
          description: Name of campaign.
          type: string
        agent_id:
          description: ID of connected WhatsApp agent.
          type: string
        wa_template_id:
          description: ID of connected WhatsApp template.
          type: string
        status:
          description: Status of campaign.
          type: string
          enum:
            - ready
            - in_progress
            - paused
            - done
            - canceled
        components:
          description: >
            Array of objects describing how to fill variables within the
            specified template.

            If there are no variables, set this to an empty array.

            Format is defined by WhatsApp. See `components` under
            https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates
          type: array
          items:
            type: object
        start_at:
          description: >
            Datetime when to start sending the campaign. Field is only relevant
            if status is "in_progress".

            Field is also used when messaging limit is reached for the day.
            Campaign will wait till next day

            same time and continue sending.
          type: string
          format: date-time
          nullable: true
          example: '2023-01-01T12:00:00Z'
        send_from:
          description: >
            Together with send_until: time window to send the campaign. Can be
            used such that customers do not receive

            messages in the middle of the night.
          type: string
          example: '00:00:00'
        send_until:
          description: See send_from.
          type: string
          example: '23:59:59'
        assign_bot_id:
          description: |
            Optional ID of bot which will be assigned to the conversation.
            Existing running bot will be stopped and a new one will be started.
          type: integer
          nullable: true
        assign_user_id:
          description: |
            Optional ID of user the conversation will be assigned to.
          type: integer
          nullable: true
        assign_folder_id:
          description: |
            Optional ID of folder the conversation will be assigned to.
          type: integer
          nullable: true
        assign_tag_id:
          description: |
            Optional ID of tag the profile will be assigned to.
          type: integer
          nullable: true
        assign_group_id:
          description: |
            Optional ID of tag the profile will be assigned to.
          type: integer
          nullable: true
        resume_at:
          description: >
            When messaging limit is reached for the day, this field will be set
            to the datetime when the

            campaign will resume.
          type: string
          format: date-time
          nullable: true
          example: '2023-01-01T12:00:00Z'
        finished_at:
          description: |
            Filled when campaign is finished.
          type: string
          format: date-time
          nullable: true
          example: '2023-01-01T12:00:00Z'
        created_at:
          description: |
            When the campaign was created.
          type: string
          format: date-time
          nullable: true
          example: '2023-01-01T12:00:00Z'
        updated_at:
          description: |
            When the campaign was updated.
          type: string
          format: date-time
          nullable: true
          example: '2023-01-01T12:00:00Z'
        recipients_count:
          description: Total number of attached recipients.
          type: integer
        latest_statistics:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/WhatsappCampaignStatistics'
    WhatsappCampaignStatistics:
      description: Statistics of a WhatsApp campaign. Fetched hourly.
      type: object
      properties:
        id:
          type: integer
        campaign_id:
          type: integer
        datetime:
          type: string
          format: date-time
          example: '2023-01-01T12:00:00Z'
        recipients_count:
          type: integer
        to_send_count:
          type: integer
        to_send_percent:
          type: number
        sent_count:
          type: integer
        sent_percent:
          type: number
        delivered_count:
          type: integer
        delivered_percent:
          type: number
        read_count:
          type: integer
        read_percent:
          type: number
        error_count:
          type: integer
        error_percent:
          type: number
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````