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

# Test send campaign

> Requires campaigns:manage and campaigns:read because the test can use stored recipient samples. Sends one copy of a draft campaign's content to a seed recipient, through the same rendering, sending and BanSafe checks as a launched campaign. The seed recipient must be a number connected to your team. The sending number must be connected, on a plan that includes Campaigns and, when the campaign selects numbers, one of them. A test is not a campaign recipient and is not counted in the campaign's statistics or webhooks. A team can send 20 tests an hour, and at most 5 an hour to one seed recipient. `429` means one of these limits was reached or BanSafe is pacing the sending number; follow `Retry-After`. `409 bansafe_cold_held` means the seed recipient has never written to the sending number and the campaign holds first messages. `409 state_conflict` means the campaign is not a draft or has A/B or weighted content alternatives, the sending number is a Hybrid Link number, or the seed recipient opted out. `504 result_unknown` means the outcome was not received in time and the test may still arrive. Send `projectId` in the body when using a team API key. `422 campaign_variables_missing` means the test's sample values, the mapped recipient value and the fallback all leave a variable in the campaign content empty.

Requires `campaigns:manage` and `campaigns:read`. Project tokens only access resources in their own project.



## OpenAPI

````yaml api-reference/features/campaigns.json POST /platform/campaigns/{campaignId}/test-send
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/campaigns/{campaignId}/test-send:
    post:
      tags:
        - Campaigns
      summary: Test send campaign
      description: >-
        Requires campaigns:manage and campaigns:read because the test can use
        stored recipient samples. Sends one copy of a draft campaign's content
        to a seed recipient, through the same rendering, sending and BanSafe
        checks as a launched campaign. The seed recipient must be a number
        connected to your team. The sending number must be connected, on a plan
        that includes Campaigns and, when the campaign selects numbers, one of
        them. A test is not a campaign recipient and is not counted in the
        campaign's statistics or webhooks. A team can send 20 tests an hour, and
        at most 5 an hour to one seed recipient. `429` means one of these limits
        was reached or BanSafe is pacing the sending number; follow
        `Retry-After`. `409 bansafe_cold_held` means the seed recipient has
        never written to the sending number and the campaign holds first
        messages. `409 state_conflict` means the campaign is not a draft or has
        A/B or weighted content alternatives, the sending number is a Hybrid
        Link number, or the seed recipient opted out. `504 result_unknown` means
        the outcome was not received in time and the test may still arrive. Send
        `projectId` in the body when using a team API key. `422
        campaign_variables_missing` means the test's sample values, the mapped
        recipient value and the fallback all leave a variable in the campaign
        content empty.


        Requires `campaigns:manage` and `campaigns:read`. Project tokens only
        access resources in their own project.
      operationId: managementTestSendPlatformCampaign
      parameters:
        - name: campaignId
          in: path
          required: true
          schema:
            type: string
          description: Identifier for the campaign.
        - name: Idempotency-Key
          in: header
          required: false
          description: >-
            Optional unique key, 1 to 255 bytes, that makes this request safe to
            retry for 24 hours. A retry with the same key, credential,
            `Polymorfa-Version` and request never runs it again: it returns `409
            idempotency_completed` when the original succeeded, or the original
            server error. Reusing the key for a different request returns `409
            idempotency_conflict`; a retry while the original is still running
            returns `409 idempotency_in_progress`, and a retry after an
            unrecorded outcome returns `409 idempotency_outcome_unknown`.


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

            **Value constraints**

            | Constraint | Accepted input |

            | --- | --- |

            | String length | `1` through `255` characters |
          schema:
            type: string
            minLength: 1
            maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/management__CampaignTestSendRequest'
      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__CampaignTestSend'
                    description: Structured data carried by this object.
                required:
                  - data
        '400':
          $ref: '#/components/responses/management__BadRequest'
        '401':
          $ref: '#/components/responses/management__Unauthorized'
        '402':
          $ref: '#/components/responses/management__PaymentRequired'
        '403':
          $ref: '#/components/responses/management__Forbidden'
        '404':
          $ref: '#/components/responses/management__NotFound'
        '409':
          $ref: '#/components/responses/management__Conflict'
        '422':
          $ref: '#/components/responses/management__CampaignVariablesMissing'
        '429':
          $ref: '#/components/responses/management__RateLimited'
        '502':
          $ref: '#/components/responses/management__UpstreamFailure'
        '503':
          $ref: '#/components/responses/management__SendPathUnavailable'
        '504':
          $ref: '#/components/responses/management__ResultUnknown'
      security:
        - management__ApiKeyAuth: []
      servers:
        - url: https://api.polymorfa.com
components:
  schemas:
    management__CampaignTestSendRequest:
      type: object
      additionalProperties: false
      properties:
        projectId:
          type: string
          format: uuid
          description: >-
            Required when using a team API key. Project tokens derive the
            project from the credential.


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

            **Value constraints**

            | Constraint | Accepted input |

            | --- | --- |

            | Format | `uuid` |
        sessionId:
          type: string
          format: uuid
          description: >-
            The number to send the test from. It must be connected, on a plan
            that includes Campaigns and, when the campaign selects numbers, one
            of them.


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

            **Value constraints**

            | Constraint | Accepted input |

            | --- | --- |

            | Format | `uuid` |
        to:
          type: string
          minLength: 1
          maxLength: 32
          description: >-
            The seed recipient in international format. It must be the phone of
            a number connected to your team.


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

            **Value constraints**

            | Constraint | Accepted input |

            | --- | --- |

            | String length | `1` through `32` characters |
          example: '+5511999990000'
        sampleRecipientId:
          type: string
          format: uuid
          description: >-
            A recipient of this campaign whose variables fill the content.
            Without it and without `variables`, the campaign's first recipient,
            or its audience's first member, is the sample.


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

            **Value constraints**

            | Constraint | Accepted input |

            | --- | --- |

            | Format | `uuid` |
        variables:
          type: object
          maxProperties: 50
          additionalProperties:
            oneOf:
              - type: string
                maxLength: 1024
              - type: number
              - type: boolean
          description: >-
            Variable values for the test. They override the sample recipient's
            values; without `sampleRecipientId`, only these values are used.


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

            **Value constraints**

            | Constraint | Accepted input |

            | --- | --- |

            | Object size | At most `50` properties |
      required:
        - sessionId
        - to
    management__CampaignTestSend:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          format: uuid
          description: |-
            The test send's ID.

            <!-- polymorfa-input-table -->
            **Value constraints**
            | Constraint | Accepted input |
            | --- | --- |
            | Format | `uuid` |
        campaignId:
          type: string
          format: uuid
          description: |-
            Identifier for the campaign.

            <!-- polymorfa-input-table -->
            **Value constraints**
            | Constraint | Accepted input |
            | --- | --- |
            | Format | `uuid` |
        status:
          type: string
          enum:
            - sent
          description: |-
            Current status of this resource or operation.

            <!-- polymorfa-input-table -->
            **Allowed values**
            | Value | Meaning |
            | --- | --- |
            | `sent` | Sent. |
        from:
          type: object
          additionalProperties: false
          properties:
            sessionId:
              type: string
              format: uuid
              description: |-
                Identifier of the connected Polymorfa session.

                <!-- polymorfa-input-table -->
                **Value constraints**
                | Constraint | Accepted input |
                | --- | --- |
                | Format | `uuid` |
            phone:
              type: string
              description: Phone number in international format.
          required:
            - sessionId
            - phone
          description: The number the test was sent from.
        to:
          type: string
          description: The seed recipient, in E.164 format.
        messageId:
          type: string
          nullable: true
          description: |-
            The WhatsApp message ID, when the send path returned one.

            <!-- polymorfa-input-table -->
            **Accepted alternatives**
            | Alternative | Accepted input |
            | --- | --- |
            | Alternative 1 | Type: `string` |
            | Alternative 2 | `null` |
        variables:
          type: object
          additionalProperties:
            type: string
          description: The variable values the content was rendered with.
        createdAt:
          type: number
          description: When the test was admitted, in Unix milliseconds.
      required:
        - id
        - campaignId
        - status
        - from
        - to
        - messageId
        - variables
        - createdAt
    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__PaymentRequired:
      description: The number's plan does not include this capability.
      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'
    management__CampaignVariablesMissing:
      description: >-
        `campaign_variables_missing`: a recipient (or the test's sample values)
        has no value and no fallback for a variable in the campaign content.
        Nothing was sent.
      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__RateLimited:
      description: A limit was reached. Wait for `Retry-After` before retrying.
      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.
        Retry-After:
          description: Seconds to wait before retrying.
          schema:
            type: integer
            minimum: 1
        Polymorfa-RateLimit-Reason:
          schema:
            type: string
          description: >-
            The limit that was reached. See the rate-limit reasons in the error
            reference.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/management__ErrorEnvelope'
    management__UpstreamFailure:
      description: '`upstream_failure`: the messaging provider could not complete the send.'
      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__SendPathUnavailable:
      description: >-
        The send path is unavailable or the sending number is not ready
        (`session_not_ready`, `command_dispatch_failed`, `service_unavailable`,
        or `bansafe_accounting_unavailable`). No message was sent.
      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__ResultUnknown:
      description: >-
        `result_unknown`: the outcome was not received before the deadline. The
        message may still arrive; check before repeating the request.
      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.