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

# Update campaign

> Update a campaign with a full payload. Requires a SERVER API token. The account_id is derived from the access token and must not be sent in the request body. The type query parameter must match the existing campaign type. Updates reject missing campaigns, invalid payloads, and blocked sensitive changes. Ended campaigns cannot be updated. Started campaigns cannot update start_date, attributes, rules, or brand_id, and end_date cannot be moved to the past.



## OpenAPI

````yaml PUT /campaigns/{id}
openapi: 3.0.1
info:
  title: Masivo's REST API
  description: Learn how to use Masivo's REST API
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://app.masivo.ai/api/storefront/v1
security:
  - bearerAuth: []
paths:
  /campaigns/{id}:
    put:
      description: >-
        Update a campaign with a full payload. Requires a SERVER API token. The
        account_id is derived from the access token and must not be sent in the
        request body. The type query parameter must match the existing campaign
        type. Updates reject missing campaigns, invalid payloads, and blocked
        sensitive changes. Ended campaigns cannot be updated. Started campaigns
        cannot update start_date, attributes, rules, or brand_id, and end_date
        cannot be moved to the past.
      parameters:
        - in: path
          name: id
          description: The campaign unique identifier
          required: true
          schema:
            type: string
            format: uuid
        - in: query
          name: type
          description: >-
            The campaign type to update. It must match the existing campaign
            type. The request body must be the full selected campaign form
            payload.
          required: true
          schema:
            $ref: '#/components/schemas/CampaignType'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CampaignInsert'
      responses:
        '200':
          description: Campaign updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Campaign'
        '403':
          description: Forbidden, CLIENT API tokens cannot update campaigns
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Campaign not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Invalid campaign or blocked update
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CampaignType:
      type: string
      description: The campaign type
      enum:
        - BEHAVIOR
        - COUPONS
        - PUNCH_CARDS
        - REFERRALS
        - SCORE_STREAKS
    CampaignInsert:
      type: object
      description: >-
        Storefront campaign write payload. Send the campaign type as the
        required type query parameter, not in the body. The body mirrors the
        dashboard campaign form for that type. account_id is derived from the
        SERVER token. Common validation: rules must contain at least one
        main/referrer rule, metadata must be a JSON object encoded as a string,
        budget must be at least 1, labels and platforms use dashboard select
        values, content stores optional CMS template field values, and dates
        must follow the campaign date restrictions.
      additionalProperties: true
      properties:
        brand_id:
          type: string
          description: The brand id of the campaign, null if is a global campaign
          nullable: true
        platforms:
          type: array
          description: Platform select values where this campaign applies
          items:
            type: object
            properties:
              label:
                type: string
              value:
                type: string
          nullable: true
        stores:
          type: array
          description: >-
            Store ids this campaign is restricted to. null means no store
            restriction; a non-empty array restricts the campaign to those
            stores; [] is an explicit empty restriction and matches no stores.
          items:
            type: string
          nullable: true
        channels:
          type: array
          description: >-
            Channel ids this campaign is restricted to. null means no channel
            restriction; a non-empty array restricts the campaign to those
            channels; [] is an explicit empty restriction and matches no
            channels.
          items:
            type: string
          nullable: true
        products:
          type: array
          description: >-
            Product ids this campaign is restricted to. null means no product
            restriction; a non-empty array restricts the campaign to those
            products; [] is an explicit empty restriction and matches no
            products.
          items:
            type: string
          nullable: true
        name:
          type: string
          description: The name of the campaign
        description:
          type: string
          description: The description of the campaign
        rules:
          type: string
          description: >-
            JSON string of an array of Rule objects (see the Rule/Effect
            schemas) with the main/referrer campaign rules. Must contain at
            least one rule for every campaign type, including REFERRALS.
            referee_rules_json does not replace this field. Each rule's
            effects[].reward_id must be the id of a reward that already exists
            and is ACTIVE for the account; create the reward from the dashboard
            first, this endpoint does not create rewards.
          example: >-
            [{"conditions":[],"effects":[{"reward_id":"1334205e-4876-4f04-9d4b-e58b3778be44","type":"DISCOUNT","tier_id":null,"expiration_date":null,"amount":10}]}]
        attributes:
          description: The attributes of the campaign
          oneOf:
            - type: object
              description: >-
                The attributes of the campaign for BEHAVIOR campaigns. trigger
                must be a supported event type and privacy must be PRIVATE or
                PUBLIC.
              properties:
                trigger:
                  type: string
                  description: The trigger of the campaign
                  example: PURCHASE
                privacy:
                  type: string
                  description: The privacy of the campaign
                  enum:
                    - PRIVATE
                    - PUBLIC
            - type: object
              description: >-
                The attributes of the campaign for COUPONS campaigns. Coupon
                campaigns validate non-empty custom codes, generated-code
                quantity, coupon template format, positive redemption limits,
                and duplicate active/used coupon codes that match the template.
              properties:
                max_redemptions_per_code:
                  type: number
                  description: The maximum redemptions per code. Must be at least 1.
                  example: 1
                max_redemptions_per_code_per_customer:
                  type: number
                  description: >-
                    The maximum redemptions per code per customer. Must be at
                    least 1.
                  example: 1
                code_format:
                  type: object
                  description: >-
                    The format of generated coupon codes. Generated quantities
                    must stay within the template permutation count and under
                    the same safe limit enforced by the dashboard form. Custom
                    codes are checked for duplicates against active campaigns
                    and active redemptions when they match this template.
                  properties:
                    template:
                      type: string
                      description: The template that all coupon codes should follow
                      example: '********'
                    case_sensitive:
                      type: boolean
                      description: If the coupon code is case sensitive
                      example: false
                codes:
                  type: array
                  description: The codes of the campaign
                  items:
                    type: string
                    example: ABCD1234
            - type: object
              description: >-
                The attributes of the campaign for PUNCH_CARDS campaigns.
                cards_per_customer and punches_per_card must be positive unless
                unlimited_cards changes the dashboard form requirements. On
                update, if punches_per_card changes, rules must be rebuilt and
                cannot be the same rules currently stored on the campaign.
              properties:
                trigger:
                  type: string
                  example: PURCHASE
                privacy:
                  type: string
                  enum:
                    - PRIVATE
                    - PUBLIC
                unlimited_cards:
                  type: boolean
                cards_per_customer:
                  type: number
                punches_per_card:
                  type: number
            - type: object
              description: >-
                The attributes of the campaign for REFERRALS campaigns.
                Main/referrer rules are required in rules. referee_rules_json
                can add referee rules but cannot be the only reward definition.
              properties:
                trigger:
                  type: string
                  example: PURCHASE
                privacy:
                  type: string
                  enum:
                    - PRIVATE
                    - PUBLIC
                max_participations_per_customer:
                  type: number
                  description: Must be an integer between 1 and 100.
                stock:
                  type: number
                  description: Must be an integer between 1 and 100000.
                uses:
                  type: number
                  description: Must be an integer greater than or equal to 0.
            - type: object
              description: >-
                The attributes of the campaign for SCORE_STREAKS campaigns. Each
                rule must include a positive milestone and at least one effect.
                Milestone belongs on the rule, not on each effect.
              properties:
                trigger:
                  type: string
                  description: The event type that advances the streak
                  example: PURCHASE
                privacy:
                  type: string
                  enum:
                    - PRIVATE
                    - PUBLIC
                loss:
                  type: object
                  description: When the streak is lost. Exactly one condition is required.
                  properties:
                    conditions:
                      type: array
                      minItems: 1
                      maxItems: 1
                      items:
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - NO_TRIGGER_EVENT_WITHIN
                          amount:
                            type: number
                            description: Integer from 1 to 365
                          unit:
                            type: string
                            enum:
                              - MINUTES
                              - HOURS
                              - DAYS
                              - WEEKS
                              - MONTHS
                reset:
                  type: object
                  description: >-
                    Optional calendar reset. When enabled is true, calendar is
                    required.
                  properties:
                    enabled:
                      type: boolean
                    calendar:
                      type: object
                      properties:
                        frequency:
                          type: string
                          enum:
                            - DAILY
                            - WEEKLY
                            - MONTHLY
                        week_starts_on:
                          type: number
                          description: Required when frequency is WEEKLY. 0-6.
                        day_of_month:
                          type: number
                          description: Required when frequency is MONTHLY. 1-31.
        status:
          description: The persisted campaign status for create/update requests
          type: string
          enum:
            - ACTIVE
            - INACTIVE
        start_date:
          type: string
          description: >-
            The start date of the campaign. On create, and on updates for
            scheduled campaigns, it must be today or later and less than one
            year from now.
          format: date-time
        withoutEndDate:
          type: boolean
          description: >-
            When true, end_date must be omitted and the campaign is stored
            without an end date.
        end_date:
          type: string
          description: >-
            The end date of the campaign. Omit it when withoutEndDate is true.
            When provided, it must be after start_date and less than one year
            from start_date.
          format: date-time
          nullable: true
        funded_by:
          type: string
          description: Who is funding these campaign
          nullable: true
        budget:
          type: number
          description: The budget of the campaign
          example: 1000
        divide_budget_in:
          type: string
          enum:
            - daily
            - weekly
            - monthly
            - total
        labels:
          type: array
          description: Label select values
          items:
            type: object
            properties:
              label:
                type: string
              value:
                type: string
        metadata:
          type: string
          description: JSON object encoded as a string
        content:
          type: object
          description: >-
            Optional CMS content values for the campaign. Each key is a template
            field name and each value contains the field metadata, type, and
            value. Send an empty object when the campaign has no CMS content.
          additionalProperties: true
          example:
            Title:
              name: Title
              type: input
              value: Value of the title
            BannerImage:
              alt: Alternative description for the image
              href: Href link for the image
              name: Name of the image
              type: image
              value: https://URL_TO_IMAGE
            Description:
              name: Name of the description
              type: input
              value: Value of the description
        template_id:
          type: string
          description: >-
            Optional CMS template id used to structure the campaign content.
            Send null when no template is selected.
          format: uuid
          nullable: true
        quantity:
          type: number
          description: >-
            COUPONS only. Number of coupon codes to generate or keep. Must be
            positive and within the safe limit for generated codes.
        useCustomCodes:
          type: boolean
          description: >-
            COUPONS only. When true, customCodes is used instead of generated
            codes
        customCodes:
          type: string
          description: >-
            COUPONS only. Comma-separated custom coupon codes. Required to
            contain at least one non-empty code when useCustomCodes is true.
        confirm_changes:
          type: boolean
          description: >-
            COUPONS update only. Required as true when changing code format or
            quantity
        referee_rules_json:
          type: string
          description: >-
            REFERRALS only. JSON string with referee campaign rules. This is
            optional and does not replace the required main/referrer rules
            field.
    Campaign:
      type: object
      description: Campaign response. account_id, order, and created_at are not returned.
      additionalProperties: true
      properties:
        id:
          type: string
          description: The campaign internal unique identifier
          format: uuid
        name:
          type: string
          description: The name of the campaign
        status:
          description: The computed campaign status returned by the API
          type: string
          enum:
            - RUNNING
            - PAUSED
            - SCHEDULED
            - FINISHED
            - NOT FINISHED
        attributes:
          description: The attributes of the campaign
          type: object
          additionalProperties: true
        stores:
          type: array
          description: >-
            Store ids this campaign is restricted to. null means no store
            restriction; a non-empty array restricts the campaign to those
            stores; [] is an explicit empty restriction and matches no stores.
          items:
            type: string
          nullable: true
        channels:
          type: array
          description: >-
            Channel ids this campaign is restricted to. null means no channel
            restriction; a non-empty array restricts the campaign to those
            channels; [] is an explicit empty restriction and matches no
            channels.
          items:
            type: string
          nullable: true
        products:
          type: array
          description: >-
            Product ids this campaign is restricted to. null means no product
            restriction; a non-empty array restricts the campaign to those
            products; [] is an explicit empty restriction and matches no
            products.
          items:
            type: string
          nullable: true
        content:
          description: The CMS content values stored for the campaign
          type: object
          additionalProperties: true
          example:
            Title:
              name: Title
              type: input
              value: Value of the title
            BannerImage:
              alt: Alternative description for the image
              href: Href link for the image
              name: BannerImage
              type: image
              value: https://URL_TO_IMAGE
            Description:
              name: Name of the description
              type: input
              value: Value of the description
        template_id:
          description: >-
            The CMS template id associated with the campaign content, or null
            when there is no template.
          type: string
          format: uuid
          nullable: true
    Error:
      required:
        - error
        - details
      type: object
      properties:
        error:
          type: string
        details:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````