> ## 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

> Creates an audience from inline `members` (at most 1,000) or from an uploaded CSV file (`fileId` + `mapping`). Numbers are normalized to E.164 and repeated numbers are kept once. A file import accepts at most 100,000 data rows; a larger file is refused with `413` and must be split. The response reports how many rows were invalid, with up to 20 samples. `recipientCount` is the number of stored members; any client-supplied count is ignored.

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



## OpenAPI

````yaml api-reference/features/campaigns.json POST /platform/audiences
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:
    post:
      tags:
        - Audiences
      summary: Create audience
      description: >-
        Creates an audience from inline `members` (at most 1,000) or from an
        uploaded CSV file (`fileId` + `mapping`). Numbers are normalized to
        E.164 and repeated numbers are kept once. A file import accepts at most
        100,000 data rows; a larger file is refused with `413` and must be
        split. The response reports how many rows were invalid, with up to 20
        samples. `recipientCount` is the number of stored members; any
        client-supplied count is ignored.


        Requires a team API key with `campaigns:manage`. Project tokens are not
        accepted.
      operationId: managementCreateAudience
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/management__CreateAudienceRequest'
      responses:
        '200':
          description: Success
          headers:
            X-Request-Id:
              schema:
                type: string
              description: Stable request correlation identifier.
            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__AudienceImportResult'
                    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'
        '413':
          $ref: '#/components/responses/management__PayloadTooLarge'
      security:
        - management__ApiKeyAuth: []
      servers:
        - url: https://api.polymorfa.com
components:
  schemas:
    management__CreateAudienceRequest:
      type: object
      additionalProperties: false
      description: Send either `members` or `fileId` with `mapping`, not both.
      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 |
        source:
          type: string
          enum:
            - csv
            - manual
            - api
          description: |-
            Defaults to `csv` with `fileId`, otherwise `manual`.

            <!-- polymorfa-input-table -->
            **Allowed values**
            | Value | Meaning |
            | --- | --- |
            | `csv` | Csv. |
            | `manual` | Manual. |
            | `api` | Api. |
        members:
          type: array
          maxItems: 1000
          items:
            $ref: '#/components/schemas/management__RecipientInput'
          description: |-
            Members associated with this management create audience request.

            <!-- polymorfa-input-table -->
            **Value constraints**
            | Constraint | Accepted input |
            | --- | --- |
            | Array size | At most `1000` items |
        fileId:
          type: string
          minLength: 1
          maxLength: 512
          description: >-
            File id returned by the audience upload URL. UTF-8 CSV with a header
            row; comma, semicolon or tab separated.


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

            **Value constraints**

            | Constraint | Accepted input |

            | --- | --- |

            | String length | `1` through `512` characters |
        mapping:
          type: object
          additionalProperties: false
          properties:
            phone:
              type: string
              minLength: 1
              maxLength: 200
              description: |-
                Header of the phone column.

                <!-- polymorfa-input-table -->
                **Value constraints**
                | Constraint | Accepted input |
                | --- | --- |
                | String length | `1` through `200` characters |
            variables:
              type: object
              maxProperties: 50
              additionalProperties:
                type: string
                minLength: 1
                maxLength: 200
              description: |-
                Variable name to column header.

                <!-- polymorfa-input-table -->
                **Value constraints**
                | Constraint | Accepted input |
                | --- | --- |
                | Object size | At most `50` properties |
          required:
            - phone
          description: >-
            Structured mapping values for this management create audience
            request.
      required:
        - name
    management__AudienceImportResult:
      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:
            - csv
            - manual
            - api
          description: |-
            Specifies source for this management audience import result.

            <!-- polymorfa-input-table -->
            **Allowed values**
            | Value | Meaning |
            | --- | --- |
            | `csv` | Csv. |
            | `manual` | Manual. |
            | `api` | Api. |
        recipientCount:
          type: integer
          minimum: 0
          description: |-
            Number of recipients.

            <!-- 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 import 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 import
            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 import
            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.
        duplicateCount:
          type: integer
          minimum: 0
          description: |-
            Valid rows skipped because the number appeared earlier.

            <!-- polymorfa-input-table -->
            **Value constraints**
            | Constraint | Accepted input |
            | --- | --- |
            | Numeric value | `0` or greater |
        invalidCount:
          type: integer
          minimum: 0
          description: |-
            Number of invalids.

            <!-- polymorfa-input-table -->
            **Value constraints**
            | Constraint | Accepted input |
            | --- | --- |
            | Numeric value | `0` or greater |
        invalidRows:
          type: array
          maxItems: 20
          items:
            $ref: '#/components/schemas/management__InvalidRecipientRow'
          description: |-
            Invalid rows associated with this management audience import result.

            <!-- polymorfa-input-table -->
            **Value constraints**
            | Constraint | Accepted input |
            | --- | --- |
            | Array size | At most `20` items |
      required:
        - id
        - name
        - source
        - recipientCount
        - fileId
        - columns
        - sampleRow
        - mapping
        - createdAt
        - updatedAt
        - duplicateCount
        - invalidCount
        - invalidRows
    management__RecipientInput:
      type: object
      additionalProperties: false
      properties:
        phone:
          type: string
          minLength: 1
          maxLength: 64
          description: >-
            Number in international format, for example `+14155550100`. Spaces,
            dots, hyphens and parentheses are ignored; a leading `00` is read as
            `+`; digits without `+` are read as including the country code.


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

            **Value constraints**

            | Constraint | Accepted input |

            | --- | --- |

            | String length | `1` through `64` characters |
        variables:
          type: object
          maxProperties: 50
          additionalProperties:
            oneOf:
              - type: string
                maxLength: 1024
              - type: number
              - type: boolean
          description: >-
            Template variables. Names use letters, digits, `_`, `.` or `-` (at
            most 64 characters). Values are stored as strings.


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

            **Value constraints**

            | Constraint | Accepted input |

            | --- | --- |

            | Object size | At most `50` properties |
      required:
        - phone
    management__InvalidRecipientRow:
      type: object
      additionalProperties: false
      properties:
        row:
          type: integer
          minimum: 1
          description: >-
            1-based entry position for inline input; spreadsheet row number for
            a file, where the header is row 1.


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

            **Value constraints**

            | Constraint | Accepted input |

            | --- | --- |

            | Numeric value | `1` or greater |
        reason:
          type: string
          enum:
            - missing_phone
            - invalid_phone
            - invalid_variables
            - invalid_entry
          description: |-
            Reason for the reported state or outcome.

            <!-- polymorfa-input-table -->
            **Allowed values**
            | Value | Meaning |
            | --- | --- |
            | `missing_phone` | Missing phone. |
            | `invalid_phone` | Invalid phone. |
            | `invalid_variables` | Invalid variables. |
            | `invalid_entry` | Invalid entry. |
      required:
        - row
        - reason
    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.
        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.
        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.
        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.
        Polymorfa-Version:
          schema:
            type: string
          description: API version applied to this response.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/management__ErrorEnvelope'
    management__PayloadTooLarge:
      description: Request body exceeds the endpoint limit.
      headers:
        X-Request-Id:
          schema:
            type: string
          description: Stable request correlation identifier.
        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.