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

# Update a campaign

> Update the fields of a draft campaign that the request sets; omitted fields keep their current values. Only a draft can be updated. With bearer token authentication, the user must be an administrator who can manage campaigns in every location of the audience, both the current one and a new one the request sets. <h3>OAuth</h3>Required scopes: <code>campaigns</code>



## OpenAPI

````yaml /assets/openapi.json patch /campaigns/v1/{campaignId}
openapi: 3.0.2
info:
  title: Spacebring
  version: 1.0.0
  termsOfService: https://www.spacebring.com/terms
servers:
  - url: https://api.spacebring.com
security: []
paths:
  /campaigns/v1/{campaignId}:
    patch:
      tags:
        - Campaigns
      summary: Update a campaign
      description: >-
        Update the fields of a draft campaign that the request sets; omitted
        fields keep their current values. Only a draft can be updated. With
        bearer token authentication, the user must be an administrator who can
        manage campaigns in every location of the audience, both the current one
        and a new one the request sets. <h3>OAuth</h3>Required scopes:
        <code>campaigns</code>
      operationId: patchCampaign
      parameters:
        - in: path
          name: campaignId
          required: true
          description: ID of the campaign.
          schema:
            type: string
            format: uuid
        - in: header
          name: spacebring-network-id
          schema:
            type: string
            format: uuid
          required: false
          description: >-
            The id of the network. Required when using bearer token
            authentication
      requestBody:
        $ref: '#/components/requestBodies/patchCampaign'
      responses:
        '204':
          description: No Content
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responseError'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responseError'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responseError'
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responseError'
      security:
        - BasicAuth: []
        - OAuth2:
            - campaigns
components:
  requestBodies:
    patchCampaign:
      content:
        application/json:
          schema:
            type: object
            properties:
              campaign:
                type: object
                properties:
                  audience:
                    type: object
                    properties:
                      locationRefs:
                        description: >-
                          IDs of the locations whose active members the rules
                          choose from.
                        minItems: 1
                        type: array
                        items:
                          type: string
                          format: uuid
                      rules:
                        description: >-
                          Rules a member or nonmember of the locations has to
                          match at least one of. Defaults to none, which reaches
                          every active member of the locations.
                        maxItems: 20
                        type: array
                        items:
                          oneOf:
                            - type: object
                              properties:
                                companyRefs:
                                  description: IDs of the companies whose people match.
                                  minItems: 1
                                  maxItems: 500
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                type:
                                  type: string
                                  enum:
                                    - companies
                                  description: People of the given companies.
                              required:
                                - companyRefs
                                - type
                            - type: object
                              properties:
                                eventRefs:
                                  description: IDs of the events whose attendees match.
                                  minItems: 1
                                  maxItems: 500
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                type:
                                  type: string
                                  enum:
                                    - eventAttendees
                                  description: >-
                                    Attendees of the given events, not their
                                    hosts.
                              required:
                                - eventRefs
                                - type
                            - type: object
                              properties:
                                membershipTypes:
                                  description: >-
                                    Membership types whose customers match:
                                    member, nonmember, or both.
                                  minItems: 1
                                  type: array
                                  items:
                                    type: string
                                    enum:
                                      - member
                                      - nonmember
                                type:
                                  type: string
                                  enum:
                                    - membershipTypes
                                  description: >-
                                    Everyone at the locations with one of the
                                    given membership types.
                              required:
                                - membershipTypes
                                - type
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - people
                                  description: The given people.
                                userRefs:
                                  description: >-
                                    IDs of the users who match, the user IDs of
                                    user customers.
                                  minItems: 1
                                  maxItems: 500
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                              required:
                                - type
                                - userRefs
                            - type: object
                              properties:
                                planRefs:
                                  description: IDs of the plans whose holders match.
                                  minItems: 1
                                  maxItems: 500
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                type:
                                  type: string
                                  enum:
                                    - plans
                                  description: >-
                                    People holding an active subscription to one
                                    of the given plans, personally or through
                                    their company.
                              required:
                                - planRefs
                                - type
                            - type: object
                              properties:
                                tierRefs:
                                  description: >-
                                    IDs of the resource tiers whose holders
                                    match.
                                  minItems: 1
                                  maxItems: 500
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                type:
                                  type: string
                                  enum:
                                    - resourceTiers
                                  description: >-
                                    People holding an active subscription to one
                                    of the given resource tiers, personally or
                                    through their company.
                              required:
                                - tierRefs
                                - type
                    required:
                      - locationRefs
                    description: >-
                      Who receives the campaign. An update replaces the whole
                      audience with this one.
                  channel:
                    type: string
                    enum:
                      - email
                      - push
                    description: >-
                      Channel the campaign is sent through. It is sent with the
                      content of its channel only. To reach people by email and
                      push, create two campaigns.
                  email:
                    type: object
                    properties:
                      body:
                        default: ''
                        description: >-
                          Body of the email, in the same markdown as a Feed
                          post. It can hold the variables {customer.name},
                          {customer.surname}, {customer.companyTitle}, filled in
                          for each recipient. Can be empty in a draft, but is
                          needed to send it.
                        type: string
                        maxLength: 20000
                      buttonLabel:
                        description: >-
                          Label of the button below the body, given together
                          with buttonUrl. It can hold the variables
                          {customer.name}, {customer.surname},
                          {customer.companyTitle}, filled in for each recipient.
                        type: string
                        maxLength: 60
                      buttonUrl:
                        description: >-
                          https link the button opens, given together with
                          buttonLabel.
                        type: string
                        format: uri
                      replyTo:
                        description: >-
                          Address replies go to. Defaults to the network's email
                          when omitted.
                        type: string
                        format: email
                      subject:
                        default: ''
                        description: >-
                          Subject of the email. It can hold the variables
                          {customer.name}, {customer.surname},
                          {customer.companyTitle}, filled in for each recipient.
                          Can be empty in a draft, but is needed to send it.
                        type: string
                        maxLength: 200
                    description: >-
                      Email content, used when the channel is email. An update
                      replaces the whole email with this one, so send every
                      field to keep.
                  name:
                    type: string
                    minLength: 1
                    maxLength: 200
                    description: Name of the campaign, shown to admins only.
                  push:
                    type: object
                    properties:
                      body:
                        default: ''
                        description: >-
                          Body of the push notification. Can be empty in a
                          draft, but is needed to send it.
                        type: string
                        maxLength: 1000
                      link:
                        description: >-
                          Link to a member web portal page, under /suite, that
                          the notification opens in the member app. The member
                          app home when omitted.
                        type: string
                        maxLength: 2000
                      title:
                        default: ''
                        description: >-
                          Title of the push notification. Can be empty in a
                          draft, but is needed to send it.
                        type: string
                        maxLength: 100
                    description: >-
                      Push content, used when the channel is push. An update
                      replaces the whole push with this one, so send every field
                      to keep.
                description: >-
                  Campaign fields to change. Omitted fields keep their current
                  values.
            required:
              - campaign
      required: true
  schemas:
    responseError:
      type: object
      properties:
        message:
          type: string
        type:
          type: string
  securitySchemes:
    BasicAuth:
      type: http
      description: >-
        See our [authentication
        documentation](https://www.spacebring.com/docs/developer/api/authentication#basic-authentication)
        for how to authorize your requests
      scheme: basic
    OAuth2:
      type: oauth2
      description: >-
        See our [authentication
        documentation](https://www.spacebring.com/docs/developer/api/authentication#oauth2)
        for how to authorize your requests
      flows:
        authorizationCode:
          authorizationUrl: https://oauth2.spacebring.com/api/oauth2/authorize
          tokenUrl: https://oauth2.spacebring.com/api/oauth2/token
          refreshUrl: https://oauth2.spacebring.com/api/oauth2/token
          scopes:
            benefits.readonly: Read benefits and applications
            benefits: Read and write benefits and applications
            campaigns.readonly: Read campaigns
            campaigns: Read and write campaigns
            checkIns.readonly: Read check-ins
            checkIns: Read and write check-ins
            community.readonly: Read community companies and memberships
            community: Read and write community companies and memberships
            events.readonly: Read events and tickets
            events: Read and write events and tickets
            feed.readonly: Read feed posts
            feed: Read and write feed posts
            invoices.readonly: Read contracts, credit notes, discounts and invoices
            invoices: Read and write contract, credit notes, discounts and invoices
            locations.readonly: Read locations
            locations: Read and write locations
            plans.readonly: Read plans
            plans: Read and write plans
            resources.readonly: Read resources and bookings
            resources: Read and write resources and bookings
            subscriptions.readonly: Read subscriptions
            subscriptions: Read and write subscriptions
            shop.readonly: Read products and orders
            shop: Read and write products and orders
            support.readonly: Read support tickets
            support: Read and write support tickets
            transactions.readonly: Read transactions
            transactions: Read and write transactions
            visitors.readonly: Read visitors
            visitors: Read and write visitors

````

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