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

# Add or remove targeting

> The app's Add and Delete for one audience. Removed terms come out of Google Ads on the next sync. Not allowed while the audience is generating.

Scope: `campaigns:write`.

Send an `Idempotency-Key` header to make retries safe.



## OpenAPI

````yaml /api-reference/openapi.json patch /campaigns/{campaignId}/targeting
openapi: 3.1.0
info:
  title: Fandom API
  version: 1.0.0
  description: >-
    Campaigns, targeting, audiences, data stores, brands and Audience
    Exploration. The same operations are available as MCP tools at /mcp.
servers:
  - url: https://fandom-api-preview.vercel.app/api/v1
  - url: https://www.fandom.ai/api/v1
security:
  - bearerAuth: []
tags:
  - name: Workspace
    description: What's in the workspace.
  - name: Campaigns
    description: Campaigns, as the app's Marketing section shows them.
  - name: Targeting
    description: Keywords, segments, topics and websites for each audience on a campaign.
  - name: Google Ads
    description: Connected accounts, performance, and creating campaigns in Google Ads.
  - name: Audiences
    description: Saved audiences you can attach to campaigns.
  - name: Data stores
    description: >-
      YouTube channels and videos, with their comments, that audiences are built
      from.
  - name: Brands
    description: Brands that campaigns belong to.
  - name: Audience Exploration
    description: >-
      Who an audience is on YouTube: the channels they watch and how they group.
      Invite-only for now.
paths:
  /campaigns/{campaignId}/targeting:
    patch:
      tags:
        - Targeting
      summary: Add or remove targeting
      description: >-
        The app's Add and Delete for one audience. Removed terms come out of
        Google Ads on the next sync. Not allowed while the audience is
        generating.


        Scope: `campaigns:write`.


        Send an `Idempotency-Key` header to make retries safe.
      operationId: edit_campaign_targeting
      parameters:
        - name: campaignId
          in: path
          required: true
          description: Campaign id.
          schema:
            type: string
            pattern: ^[a-f0-9]{24}$
        - name: Idempotency-Key
          in: header
          required: false
          description: >-
            Any unique string. Repeating a request with the same key returns the
            first result instead of doing it twice.
          schema:
            type: string
            maxLength: 200
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                audienceId:
                  type: string
                  minLength: 1
                  maxLength: 200
                  description: The audience slot (the `id` in Get targeting).
                add:
                  type: array
                  items:
                    type: object
                    properties:
                      section:
                        type: string
                        enum:
                          - keywords
                          - negativeKeywords
                          - caaWebsites
                          - websites
                          - adCategories
                          - adAffinities
                          - adInMarketAffinities
                          - adLifeEvents
                          - adDetailedDemographics
                          - adDemographics
                          - cia
                          - caaApps
                        description: >-
                          `keywords`, `negativeKeywords`, `caaWebsites`
                          (websites), `adCategories` (topics), `adAffinities`,
                          `adInMarketAffinities`, `adLifeEvents`,
                          `adDetailedDemographics`, `adDemographics`, `cia`
                          (custom intent) or `caaApps`. Which apply depends on
                          the campaign type.
                      text:
                        type: string
                        minLength: 1
                        maxLength: 500
                      matchType:
                        type: string
                        enum:
                          - BROAD
                          - PHRASE
                          - EXACT
                        description: Keywords only.
                    required:
                      - section
                      - text
                    additionalProperties: false
                  maxItems: 200
                remove:
                  type: array
                  items:
                    type: object
                    properties:
                      section:
                        type: string
                        enum:
                          - keywords
                          - negativeKeywords
                          - caaWebsites
                          - websites
                          - adCategories
                          - adAffinities
                          - adInMarketAffinities
                          - adLifeEvents
                          - adDetailedDemographics
                          - adDemographics
                          - cia
                          - caaApps
                        description: >-
                          `keywords`, `negativeKeywords`, `caaWebsites`
                          (websites), `adCategories` (topics), `adAffinities`,
                          `adInMarketAffinities`, `adLifeEvents`,
                          `adDetailedDemographics`, `adDemographics`, `cia`
                          (custom intent) or `caaApps`. Which apply depends on
                          the campaign type.
                      text:
                        type: string
                        minLength: 1
                        maxLength: 500
                    required:
                      - section
                      - text
                    additionalProperties: false
                  maxItems: 200
              required:
                - audienceId
              additionalProperties: false
            example:
              audienceId: aud-ent-6524f0c1e4b0a1b2c3d4e5f6
              add:
                - section: keywords
                  text: building sets for kids
                  matchType: PHRASE
              remove:
                - section: adAffinities
                  text: Travel
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  added:
                    type: number
                  updated:
                    type: number
                  removed:
                    type: number
                  audience:
                    type: object
                    properties:
                      id:
                        type: string
                        description: The audience's slot on the campaign.
                      name:
                        type: string
                      audienceId:
                        type:
                          - string
                          - 'null'
                      status:
                        type: string
                        enum:
                          - not_generated
                          - generating
                          - ready
                          - error
                        description: Generation takes 30–90 seconds.
                      error:
                        type:
                          - string
                          - 'null'
                      updatedAt:
                        type:
                          - string
                          - 'null'
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            section:
                              type: string
                            label:
                              type: string
                              description: The section's name in the app.
                            text:
                              type: string
                            matchType:
                              type:
                                - string
                                - 'null'
                              description: 'Keywords only: BROAD, PHRASE or EXACT.'
                            source:
                              type: string
                              description: '`generated`, `manual`, `rfp`, `imported`…'
                          required:
                            - section
                            - label
                            - text
                            - matchType
                            - source
                          additionalProperties: false
                    required:
                      - id
                      - name
                      - audienceId
                      - status
                      - error
                      - updatedAt
                      - items
                    additionalProperties: false
                required:
                  - added
                  - updated
                  - removed
                  - audience
                additionalProperties: false
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  responses:
    BadRequest:
      description: >-
        The request is missing something or has a bad value. The message says
        what.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: No API key, or the key is wrong or revoked.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >-
        The key doesn't have the scope, or isn't allowed this campaign or
        account.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Nothing with that id in this workspace.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Conflict:
      description: >-
        The current state doesn't allow this (for example, it's already done or
        still generating).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: More than 120 requests in a minute. Wait and retry.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Stable, machine-readable.
              examples:
                - not_found
            message:
              type: string
              description: Plain-language explanation.
            requestId:
              type: string
              description: Quote this when asking for help.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: An API key from Settings → API access, starting with `fnd_`.

````

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