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

# Update a campaign

> Update a draft campaign's name, group, audience (mailing list, segment, or filter), or scheduling.

<Info>Campaigns can only be updated while they are in `Draft` status. At least one field must be provided.</Info>


## OpenAPI

````yaml /openapi.json post /v1/campaigns/{campaignId}
openapi: 3.1.0
info:
  title: Loops OpenAPI Spec
  description: This is the OpenAPI Spec for the [Loops API](https://loops.so/docs/api).
  version: 1.21.0
servers:
  - url: https://app.loops.so/api
security: []
tags:
  - name: API key
  - name: Audience segments
    description: View audience segments
  - name: Campaigns
    description: Create and manage email campaigns
  - name: Campaign groups
    description: Organize campaigns into groups
  - name: Components
    description: View email components
  - name: Configuration
    description: View configuration settings
  - name: Contacts
    description: Manage contacts in your audience
  - name: Contact properties
    description: Manage contact properties
  - name: Email messages
    description: Manage email message content for campaigns
  - name: Events
    description: Trigger workflows with events
  - name: Event patterns
    description: View workflow event patterns
  - name: Mailing lists
    description: View mailing lists
  - name: Themes
    description: View email themes
  - name: Transactional emails
    description: Create, manage, and send transactional emails
  - name: Transactional groups
    description: Organize transactional emails into groups
  - name: Uploads
    description: Upload image assets
  - name: Workflows
    description: View and mutate workflow graphs
  - name: Workflow nodes
    description: View and mutate workflow nodes
paths:
  /v1/campaigns/{campaignId}:
    parameters:
      - name: campaignId
        in: path
        required: true
        description: The ID of the campaign.
        schema:
          type: string
    post:
      tags:
        - Campaigns
      summary: Update a campaign
      description: >-
        Update a draft campaign's name, group, audience (mailing list, segment,
        or filter), or scheduling. At least one field must be provided.
        Campaigns can only be updated while in draft status.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCampaignRequest'
      responses:
        '200':
          description: Campaign updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CampaignResponse'
        '400':
          description: Invalid request body or campaign group not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CampaignFailureResponse'
        '401':
          description: Invalid API key or content API not enabled for this team.
        '404':
          description: Campaign, mailing list, or audience segment not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CampaignFailureResponse'
        '405':
          description: Wrong HTTP request method.
        '409':
          description: Campaign is not in draft status.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CampaignFailureResponse'
      security:
        - apiKey: []
components:
  schemas:
    UpdateCampaignRequest:
      type: object
      description: At least one field must be provided.
      properties:
        name:
          type: string
          description: The updated campaign name.
        campaignGroupId:
          type: string
          description: The ID of the group to move this campaign to.
        mailingListId:
          type:
            - string
            - 'null'
          description: The ID of the mailing list to send to.
        audienceSegmentId:
          type:
            - string
            - 'null'
          description: >-
            The ID of an audience segment. Setting this without also providing
            `audienceFilter` clears any existing `audienceFilter`. If both are
            provided, the filter is applied on top of the segment's filter.
        audienceFilter:
          $ref: '#/components/schemas/AudienceFilterInRequest'
        scheduling:
          $ref: '#/components/schemas/CampaignSchedulingRequest'
      additionalProperties: false
    CampaignResponse:
      type: object
      properties:
        id:
          type: string
          description: The ID of the campaign.
        name:
          type: string
          description: The name of the campaign.
        status:
          type: string
          description: The status of the campaign.
          enum:
            - Draft
            - Scheduled
            - Sending
            - Sent
        createdAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp for when the campaign was created.
        updatedAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp for when the campaign was last updated.
        emailMessageId:
          type:
            - string
            - 'null'
          description: The associated email message ID.
        campaignGroupId:
          type:
            - string
            - 'null'
          description: The ID of the campaign group this campaign belongs to..
        mailingListId:
          type:
            - string
            - 'null'
          description: The ID of the mailing list this campaign sends to, if set.
        audienceSegmentId:
          type:
            - string
            - 'null'
          description: The ID of the audience segment this campaign targets, if set.
        audienceFilter:
          $ref: '#/components/schemas/AudienceFilter'
          description: The filter rules that define the audience for this campaign, if set.
        scheduling:
          $ref: '#/components/schemas/CampaignScheduling'
      required:
        - id
        - name
        - status
        - createdAt
        - updatedAt
        - emailMessageId
        - campaignGroupId
        - mailingListId
        - audienceSegmentId
        - audienceFilter
        - scheduling
    CampaignFailureResponse:
      type: object
      properties:
        message:
          type: string
      required:
        - message
    AudienceFilterInRequest:
      type:
        - object
        - 'null'
      description: >-
        A tree of audience conditions combined with `match`. Setting this
        without also providing `audienceSegmentId` clears any existing
        `audienceSegmentId`. When both are provided, this filter is applied on
        top of the segment's filter.
      properties:
        match:
          type: string
          enum:
            - all
            - any
        conditions:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/AudienceFilterCondition'
      required:
        - match
        - conditions
      additionalProperties: false
    CampaignSchedulingRequest:
      type: object
      description: >-
        When the campaign should send. `timestamp` is required and must be in
        the future when `method` is `schedule`, and must be omitted when
        `method` is `now`.
      properties:
        method:
          type: string
          enum:
            - now
            - schedule
        timestamp:
          type: string
          format: date-time
      required:
        - method
      additionalProperties: false
    AudienceFilter:
      type:
        - object
        - 'null'
      description: A tree of audience conditions combined with `match`.
      properties:
        match:
          type: string
          enum:
            - all
            - any
        conditions:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/AudienceFilterCondition'
      required:
        - match
        - conditions
      additionalProperties: false
    CampaignScheduling:
      type: object
      description: When the campaign is scheduled to send.
      properties:
        method:
          type: string
          enum:
            - now
            - schedule
        timestamp:
          type:
            - string
            - 'null'
          format: date-time
          description: ISO 8601 send time. Null when the method is `now`.
      required:
        - method
        - timestamp
    AudienceFilterCondition:
      oneOf:
        - $ref: '#/components/schemas/PropertyCondition'
        - $ref: '#/components/schemas/OptInCondition'
        - $ref: '#/components/schemas/ActivityCondition'
      discriminator:
        propertyName: type
    PropertyCondition:
      type: object
      description: Matches contacts by a property value.
      properties:
        type:
          type: string
          enum:
            - property
        key:
          type: string
          description: The contact property name.
        operator:
          type: string
          enum:
            - any
            - contains
            - notContains
            - equals
            - notEquals
            - greaterThan
            - lessThan
            - isTrue
            - isFalse
            - empty
            - notEmpty
            - dateEmpty
            - dateNotEmpty
            - after
            - before
            - between
        value:
          description: >-
            The comparison value. Omitted for value-less operators (e.g.
            `isTrue`, `empty`). A `{ from, to }` object for `between`.
          oneOf:
            - type: string
            - type: number
            - type: object
              properties:
                from:
                  type: string
                  format: date-time
                to:
                  type: string
                  format: date-time
              required:
                - from
                - to
      required:
        - type
        - key
        - operator
    OptInCondition:
      type: object
      description: Matches contacts by mailing-list opt-in status.
      properties:
        type:
          type: string
          enum:
            - optIn
        status:
          type:
            - string
            - 'null'
          enum:
            - accepted
            - pending
            - rejected
            - null
      required:
        - type
        - status
    ActivityCondition:
      type: object
      description: Matches contacts by their activity on a campaign or workflow.
      properties:
        type:
          type: string
          enum:
            - activity
        action:
          type: string
          enum:
            - sent
            - opened
            - clicked
        negate:
          type: boolean
        target:
          type: string
          enum:
            - campaign
            - workflow
            - workflowEmail
        id:
          type: string
          description: The ID of the campaign, workflow, or workflow email.
      required:
        - type
        - action
        - negate
        - target
        - id
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````

## Related topics

- [LMX](/docs/creating-emails/lmx.md)
- [API Introduction](/docs/api-reference/intro.md)
- [Recipe: Active 30-day users segment](/docs/guides/active-30-day-users.md)
- [Update a campaign group](/docs/api-reference/update-campaign-group.md)
- [Campaigns](/docs/cli/campaigns.md)
