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

# Create audience from campaign

> Creates an audience from the recipients of a previous campaign that had one `outcome`, to send them a follow-up campaign. The members are a snapshot taken when the request runs: later receipts, reads or replies on the source campaign do not change the audience. Numbers on the team's opt-out list are left out and counted in `optedOutCount`; each member keeps the template variables it had on the source campaign. Outcomes: `delivered` (the device confirmed delivery), `not_delivered` (sent, with no delivery confirmation), `read`, `not_read` (sent and not read, including sends never delivered), `replied`, `not_replied` (sent and no reply was attributed), and `failed` (confirmed failed sends; sends whose outcome is uncertain, such as a timeout waiting for WhatsApp, are excluded). Read outcomes depend on the recipient's read receipts. `404` means the campaign is not in your team (or not in `projectId` when given); `409` means no recipient that is not opted out has the outcome, and nothing is created.

Requires a team API key with `campaigns:manage`. Project tokens are not accepted.



## OpenAPI

````yaml api-reference/features/campaigns.json POST /platform/audiences/from-campaign
openapi: 3.0.3
info:
  title: Campaigns API methods
  version: 1.0.0
  description: Task-focused campaigns methods across supported Polymorfa connection types.
servers: []
security: []
paths:
  /platform/audiences/from-campaign:
    post:
      tags:
        - Audiences
      summary: Create audience from campaign
      description: >-
        Creates an audience from the recipients of a previous campaign that had
        one `outcome`, to send them a follow-up campaign. The members are a
        snapshot taken when the request runs: later receipts, reads or replies
        on the source campaign do not change the audience. Numbers on the team's
        opt-out list are left out and counted in `optedOutCount`; each member
        keeps the template variables it had on the source campaign. Outcomes:
        `delivered` (the device confirmed delivery), `not_delivered` (sent, with
        no delivery confirmation), `read`, `not_read` (sent and not read,
        including sends never delivered), `replied`, `not_replied` (sent and no
        reply was attributed), and `failed` (confirmed failed sends; sends whose
        outcome is uncertain, such as a timeout waiting for WhatsApp, are
        excluded). Read outcomes depend on the recipient's read receipts. `404`
        means the campaign is not in your team (or not in `projectId` when
        given); `409` means no recipient that is not opted out has the outcome,
        and nothing is created.


        Requires a team API key with `campaigns:manage`. Project tokens are not
        accepted.
      operationId: managementCreateAudienceFromCampaign
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 200
                  description: |-
                    Human-readable name for this resource.

                    <!-- polymorfa-input-table -->
                    **Value constraints**
                    | Constraint | Accepted input |
                    | --- | --- |
                    | String length | `1` through `200` characters |
                campaignId:
                  type: string
                  format: uuid
                  description: |-
                    The campaign whose recipients are selected.

                    <!-- polymorfa-input-table -->
                    **Value constraints**
                    | Constraint | Accepted input |
                    | --- | --- |
                    | Format | `uuid` |
                projectId:
                  type: string
                  format: uuid
                  description: >-
                    Optional. When given, the campaign must belong to this
                    project.


                    <!-- polymorfa-input-table -->

                    **Value constraints**

                    | Constraint | Accepted input |

                    | --- | --- |

                    | Format | `uuid` |
                outcome:
                  type: string
                  enum:
                    - delivered
                    - not_delivered
                    - read
                    - not_read
                    - replied
                    - not_replied
                    - failed
                  description: |-
                    Specifies outcome for this schema.

                    <!-- polymorfa-input-table -->
                    **Allowed values**
                    | Value | Meaning |
                    | --- | --- |
                    | `delivered` | Delivered. |
                    | `not_delivered` | Not delivered. |
                    | `read` | Read. |
                    | `not_read` | Not read. |
                    | `replied` | Replied. |
                    | `not_replied` | Not replied. |
                    | `failed` | Failed. |
              required:
                - name
                - campaignId
                - outcome
      responses:
        '200':
          description: Success
          headers:
            X-Request-Id:
              schema:
                type: string
              description: Stable request correlation identifier.
            X-Trace-Id:
              schema:
                type: string
                pattern: ^[0-9a-f]{32}$
              description: >-
                W3C trace ID of this request. Your `traceparent` trace ID when
                you sent a valid one.
            Polymorfa-Version:
              schema:
                type: string
              description: API version applied to this response.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  data:
                    allOf:
                      - $ref: >-
                          #/components/schemas/management__AudienceFromCampaignResult
                    description: Structured data carried by this object.
                required:
                  - data
        '400':
          $ref: '#/components/responses/management__BadRequest'
        '401':
          $ref: '#/components/responses/management__Unauthorized'
        '403':
          $ref: '#/components/responses/management__Forbidden'
        '404':
          $ref: '#/components/responses/management__NotFound'
        '409':
          $ref: '#/components/responses/management__Conflict'
      security:
        - management__ApiKeyAuth: []
      servers:
        - url: https://api.polymorfa.com
components:
  schemas:
    management__AudienceFromCampaignResult:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          format: uuid
          description: |-
            Identifier for this resource.

            <!-- polymorfa-input-table -->
            **Value constraints**
            | Constraint | Accepted input |
            | --- | --- |
            | Format | `uuid` |
        name:
          type: string
          description: Human-readable name for this resource.
        source:
          type: string
          enum:
            - campaign
          description: |-
            Specifies source for this management audience from campaign result.

            <!-- polymorfa-input-table -->
            **Allowed values**
            | Value | Meaning |
            | --- | --- |
            | `campaign` | Campaign. |
        recipientCount:
          type: integer
          minimum: 0
          description: |-
            Members in the new audience.

            <!-- polymorfa-input-table -->
            **Value constraints**
            | Constraint | Accepted input |
            | --- | --- |
            | Numeric value | `0` or greater |
        fileId:
          type: string
          nullable: true
          description: |-
            Identifier for the file.

            <!-- polymorfa-input-table -->
            **Accepted alternatives**
            | Alternative | Accepted input |
            | --- | --- |
            | Alternative 1 | Type: `string` |
            | Alternative 2 | `null` |
        columns:
          type: array
          nullable: true
          items:
            type: string
          description: >-
            Columns associated with this management audience from campaign
            result.


            <!-- polymorfa-input-table -->

            **Accepted alternatives**

            | Alternative | Accepted input |

            | --- | --- |

            | Alternative 1 | Type: `array` |

            | Alternative 2 | `null` |
        sampleRow:
          type: object
          nullable: true
          additionalProperties:
            type: string
          description: >-
            Structured sample row values for this management audience from
            campaign result.


            <!-- polymorfa-input-table -->

            **Accepted alternatives**

            | Alternative | Accepted input |

            | --- | --- |

            | Alternative 1 | Type: `object` |

            | Alternative 2 | `null` |
        mapping:
          type: object
          nullable: true
          additionalProperties: true
          description: >-
            Structured mapping values for this management audience from campaign
            result.


            <!-- polymorfa-input-table -->

            **Accepted alternatives**

            | Alternative | Accepted input |

            | --- | --- |

            | Alternative 1 | Type: `object` |

            | Alternative 2 | `null` |
        createdAt:
          type: integer
          description: Unix timestamp in milliseconds when this resource was created.
        updatedAt:
          type: integer
          description: Unix timestamp in milliseconds when this resource was last updated.
        sourceCampaignId:
          type: string
          format: uuid
          description: |-
            Identifier for the source campaign.

            <!-- polymorfa-input-table -->
            **Value constraints**
            | Constraint | Accepted input |
            | --- | --- |
            | Format | `uuid` |
        outcome:
          type: string
          enum:
            - delivered
            - not_delivered
            - read
            - not_read
            - replied
            - not_replied
            - failed
          description: |-
            Specifies outcome for this management audience from campaign result.

            <!-- polymorfa-input-table -->
            **Allowed values**
            | Value | Meaning |
            | --- | --- |
            | `delivered` | Delivered. |
            | `not_delivered` | Not delivered. |
            | `read` | Read. |
            | `not_read` | Not read. |
            | `replied` | Replied. |
            | `not_replied` | Not replied. |
            | `failed` | Failed. |
        matchedCount:
          type: integer
          minimum: 0
          description: >-
            Recipients of the source campaign with the outcome, before opt-outs
            were left out.


            <!-- polymorfa-input-table -->

            **Value constraints**

            | Constraint | Accepted input |

            | --- | --- |

            | Numeric value | `0` or greater |
        optedOutCount:
          type: integer
          minimum: 0
          description: >-
            Matched recipients left out because the number is on the team's
            opt-out list.


            <!-- polymorfa-input-table -->

            **Value constraints**

            | Constraint | Accepted input |

            | --- | --- |

            | Numeric value | `0` or greater |
      required:
        - id
        - name
        - source
        - recipientCount
        - fileId
        - columns
        - sampleRow
        - mapping
        - createdAt
        - updatedAt
        - sourceCampaignId
        - outcome
        - matchedCount
        - optedOutCount
    management__ErrorEnvelope:
      type: object
      required:
        - error
        - data
        - docs
      properties:
        error:
          type: object
          required:
            - type
            - code
            - message
            - param
            - request_id
          properties:
            type:
              type: string
              enum:
                - invalid_request_error
                - authentication_error
                - permission_error
                - conflict_error
                - rate_limit_error
                - api_error
                - upstream_error
              description: |-
                Type discriminator for this object.

                <!-- polymorfa-input-table -->
                **Allowed values**
                | Value | Meaning |
                | --- | --- |
                | `invalid_request_error` | Invalid request error. |
                | `authentication_error` | Authentication error. |
                | `permission_error` | Permission error. |
                | `conflict_error` | Conflict error. |
                | `rate_limit_error` | Rate limit error. |
                | `api_error` | Api error. |
                | `upstream_error` | Upstream error. |
            code:
              type: string
              description: Stable failure code. Use this value for programmatic handling.
            message:
              type: string
              description: Safe explanation of the failure.
            param:
              type: string
              nullable: true
              description: |-
                Invalid request field, or null when no field applies.

                <!-- polymorfa-input-table -->
                **Accepted alternatives**
                | Alternative | Accepted input |
                | --- | --- |
                | Alternative 1 | Type: `string` |
                | Alternative 2 | `null` |
            request_id:
              type: string
              description: >-
                Matches the X-Request-Id response header. Include it when you
                contact support.
            request_log_url:
              type: string
              format: uri
              description: >-
                Console page that shows this request. Returned only to
                organization and project credentials whose request was logged.


                <!-- polymorfa-input-table -->

                **Value constraints**

                | Constraint | Accepted input |

                | --- | --- |

                | Format | `uri` |
          description: Error details returned when the operation fails.
        data:
          type: string
          nullable: true
          enum:
            - null
          description: |-
            Always null for a failed request.

            <!-- polymorfa-input-table -->
            **Allowed values**
            | Value | Meaning |
            | --- | --- |
            | `null` | Null. |

            **Accepted alternatives**
            | Alternative | Accepted input |
            | --- | --- |
            | Alternative 1 | Type: `string` |
            | Alternative 2 | `null` |
        docs:
          type: string
          format: uri
          description: |-
            Documentation link to this failure code.

            <!-- polymorfa-input-table -->
            **Value constraints**
            | Constraint | Accepted input |
            | --- | --- |
            | Format | `uri` |
  responses:
    management__BadRequest:
      description: A path, query, or request-body value did not pass validation.
      headers:
        X-Request-Id:
          schema:
            type: string
          description: Stable request correlation identifier.
        X-Trace-Id:
          schema:
            type: string
            pattern: ^[0-9a-f]{32}$
          description: >-
            W3C trace ID of this request. Your `traceparent` trace ID when you
            sent a valid one.
        Polymorfa-Version:
          schema:
            type: string
          description: API version applied to this response.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/management__ErrorEnvelope'
    management__Unauthorized:
      description: Missing/invalid credential for this audience.
      headers:
        X-Request-Id:
          schema:
            type: string
          description: Stable request correlation identifier.
        X-Trace-Id:
          schema:
            type: string
            pattern: ^[0-9a-f]{32}$
          description: >-
            W3C trace ID of this request. Your `traceparent` trace ID when you
            sent a valid one.
        Polymorfa-Version:
          schema:
            type: string
          description: API version applied to this response.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/management__ErrorEnvelope'
    management__Forbidden:
      description: Authenticated but lacks the required scope/role/audience.
      headers:
        X-Request-Id:
          schema:
            type: string
          description: Stable request correlation identifier.
        X-Trace-Id:
          schema:
            type: string
            pattern: ^[0-9a-f]{32}$
          description: >-
            W3C trace ID of this request. Your `traceparent` trace ID when you
            sent a valid one.
        Polymorfa-Version:
          schema:
            type: string
          description: API version applied to this response.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/management__ErrorEnvelope'
    management__NotFound:
      description: >-
        The requested resource was not found inside the authenticated team or
        project scope.
      headers:
        X-Request-Id:
          schema:
            type: string
          description: Stable request correlation identifier.
        X-Trace-Id:
          schema:
            type: string
            pattern: ^[0-9a-f]{32}$
          description: >-
            W3C trace ID of this request. Your `traceparent` trace ID when you
            sent a valid one.
        Polymorfa-Version:
          schema:
            type: string
          description: API version applied to this response.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/management__ErrorEnvelope'
    management__Conflict:
      description: The request conflicts with the resource's current state.
      headers:
        X-Request-Id:
          schema:
            type: string
          description: Stable request correlation identifier.
        X-Trace-Id:
          schema:
            type: string
            pattern: ^[0-9a-f]{32}$
          description: >-
            W3C trace ID of this request. Your `traceparent` trace ID when you
            sent a valid one.
        Polymorfa-Version:
          schema:
            type: string
          description: API version applied to this response.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/management__ErrorEnvelope'
  securitySchemes:
    management__ApiKeyAuth:
      type: http
      scheme: bearer
      description: >-
        Send your team API key or project token as `Authorization: Bearer
        <token>`. The credential must have the required permissions. Project
        tokens can access only their own project.

````

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