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

> ## Agent Instructions
> Use the public API base URL: https://api.teamfollowup.ai/api.
> Authenticate public API requests with Authorization: Bearer YOUR_API_KEY.
> Use product-owned terms: agents, calls, campaigns, contacts, phone numbers, billing, and configuration.

# Create campaign test run

> Start a test run for this agent's campaign.

Required API key scope: `calls:write`.



## OpenAPI

````yaml /openapi.yaml post /api/agent-builder/agents/{id}/campaign/test-runs
openapi: 3.1.0
info:
  title: TFUAI Server API
  version: 1.0.0
  description: >-
    API reference for the TFUAI SaaS server.


    All published endpoints are mounted under `/api`. Responses use a standard
    envelope: `{ "success": true, ... }` on success and `{ "success": false,
    "error": "..." }` on failure.


    Product API modules are being launched module by module. This spec currently
    exposes only contracted public modules.


    Authenticate public API requests with an API key in the `Authorization`
    header: `Authorization: Bearer YOUR_API_KEY`.
servers:
  - url: https://api.teamfollowup.ai
    description: Production API origin. Public API paths are under /api.
  - url: https://devapi.teamfollowup.ai
    description: Development API origin. Public API paths are under /api.
security: []
tags:
  - name: Agents
    description: Manage voice agents, campaigns, workflows, and outcomes.
  - name: Analytics
    description: >-
      Minimal, non-billing performance summary: volume, conversion, and pickup
      metrics.
  - name: Calls
    description: Review calls, test runs, and execution history.
  - name: Campaign Workflows
    description: >-
      What runs after a call lands: for each outcome (booked, opted out, asked
      for a callback…), an ordered chain of actions — tag the contact, move a
      pipeline stage, send an SMS, book an appointment. Stored as a graph:
      `nodes` are the actions, `edges` say what follows what, and
      `dispositionEntries` maps each outcome to the node its chain starts at.


      **Pick the narrowest endpoint that does the job.**


      | To | Call | |

      | --- | --- | --- |

      | See what fires per outcome | `GET .../workflow/digest` | Reads as plain
      text, no graph walking |

      | Add steps to an outcome | `POST .../outcomes/{outcome}/nodes` | Server
      derives node ids, edge ids, handles, layout |

      | Change a message, tag or setting | `PATCH .../workflow` | Merges;
      carries no graph, so it cannot damage one |

      | Remove one step | `DELETE .../nodes/{nodeId}` | Also re-links the chain
      around it |

      | Author or replace the whole graph | `PUT .../workflow` | Replaces
      everything you send |


      `PUT` is the only one that can re-wire, position nodes, build an `if`,
      save an unconfigured draft, or copy a whole workflow — and the only one
      that can overwrite a change someone else made after you read it. Use it
      when you are genuinely authoring the graph, and send `expectedVersion`
      when you do. For everything else the narrower endpoints are both easier
      and safer.
  - name: Contacts
    description: Contact list, filters, contact call history, and do-not-call actions.
  - name: GHL
    description: CRM variables and contact helpers used by agent and campaign setup flows.
  - name: Phone Numbers
    description: >-
      Caller ID pool, number search, assignment, movement, and release
      endpoints.
  - name: Power Dialer
    description: >-
      Power Dialer queue, lead cadence, callback, parked lead, and campaign
      schedule endpoints.
  - name: Projects
    description: >-
      Project management endpoints: list, update, disconnect, configure project
      campaigns, and validate setup.
  - name: Skills and Tools
    description: Manage reusable agent behaviors and in-call tool descriptions.
  - name: Voices
    description: Voice catalogue endpoints for choosing the voice used by an agent.
paths:
  /api/agent-builder/agents/{id}/campaign/test-runs:
    post:
      tags:
        - Agents
      summary: Create campaign test run
      description: |-
        Start a test run for this agent's campaign.

        Required API key scope: `calls:write`.
      operationId: create-campaign-test-run
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            minLength: 1
          description: Agent id.
          example: agent_1ffdb9717444d0e77346838911
        - name: locationId
          in: query
          required: false
          schema:
            type: string
            minLength: 1
          description: Pair with campaignId; omit both for primary campaign.
          example: loc_abc123
        - name: campaignId
          in: query
          required: false
          schema:
            type: string
            minLength: 1
          description: Pair with locationId; omit both for primary campaign.
          example: cmp_123
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CallsTestCampaignTriggerRequest'
            examples:
              existingContact:
                summary: Test against an existing GHL contact
                value:
                  contactId: contact_123
                  agentTest: false
              inlineContact:
                summary: Create/reuse the contact in the same call
                value:
                  contact:
                    name: Alex Morgan
                    phone: '+14155559876'
                  agentTest: false
      responses:
        '200':
          description: Campaign test run created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CallsTestCampaignTriggerResponse'
              examples:
                default:
                  value:
                    success: true
                    data:
                      intentId: 66a91f0b0d8f3b2b79a01f12
                      locationId: loc_abc123
                      contactId: contact_123
                      contactCreated: true
                      campaignId: cmp_123
                      activeTags:
                        - new_lead
                      expiresAt: '2026-07-08T16:35:00.000Z'
        '400':
          description: Validation failed or the request body is malformed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentsErrorResponse'
              examples:
                default:
                  value:
                    success: false
                    error: VALIDATION
                    message: locationId is required.
                    details:
                      - field: locationId
                        message: locationId is required.
        '401':
          description: Missing or invalid authentication.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentsErrorResponse'
              examples:
                default:
                  value:
                    success: false
                    error: Unauthorized
                    message: Authentication required.
        '403':
          description: >-
            Authenticated but missing the required `calls:write` scope or tenant
            access.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentsErrorResponse'
              examples:
                default:
                  value:
                    success: false
                    error: FORBIDDEN
                    message: No access to agent "agent_1ffdb9717444d0e77346838911".
                insufficientScope:
                  value:
                    success: false
                    error: InsufficientScope
                    message: This API key does not have the required scope.
                    requiredScope: calls:write
        '404':
          description: Agent or related project not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentsErrorResponse'
              examples:
                default:
                  value:
                    success: false
                    error: NOT_FOUND
                    message: Agent "agent_1ffdb9717444d0e77346838911" not found.
        '409':
          description: Request conflicts with current agent state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentsErrorResponse'
              examples:
                default:
                  value:
                    success: false
                    error: IN_USE
                    message: Agent is referenced by one or more campaigns or projects.
                    references:
                      projectsV2:
                        - businessName: Acme Roofing
                          campaigns:
                            - id: cmp_123
                              name: Roofing Follow Up
                              agentId: agent_1ffdb9717444d0e77346838911
                      masterDb: []
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentsErrorResponse'
              examples:
                default:
                  value:
                    success: false
                    error: TooManyRequests
                    message: Too many requests, please try again later.
        '500':
          description: Unexpected server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentsErrorResponse'
              examples:
                default:
                  value:
                    success: false
                    error: InternalError
                    message: Unexpected server error.
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.teamfollowup.ai/api/agent-builder/agents/{id}/campaign/test-runs \
              --header 'Authorization: Bearer YOUR_API_KEY' \
              --header 'Content-Type: application/json' \
              --data '{
              "contactId": "contact_123",
              "agentTest": false
            }'
components:
  schemas:
    CallsTestCampaignTriggerRequest:
      type: object
      additionalProperties: {}
      properties:
        contactId:
          type:
            - string
            - 'null'
          description: >-
            Existing GHL contact id for outbound/appointment campaign tests. The
            dashboard resolves this client-side. Use null for inbound dial-in
            tests.
          example: contact_123
        contact:
          type: object
          description: >-
            API-convenience alternative to contactId: create — or reuse, deduped
            by phone — a GHL contact from these details when contactId is
            omitted. No marker tag is applied. contactId wins when both are
            sent.
          properties:
            name:
              type: string
              description: Display name for the created test contact.
              example: Alex Morgan
            phone:
              type: string
              description: Phone number to dial. E.164 recommended.
              example: '+14155559876'
          required:
            - name
            - phone
        callerPhone:
          type: string
          description: Tester phone number for inbound dial-in tests.
          example: '+14155559876'
        agentTest:
          type: boolean
          description: >-
            When true, run an agent-only inbound test without campaign side
            effects.
          example: false
    CallsTestCampaignTriggerResponse:
      type: object
      additionalProperties: false
      required:
        - success
        - data
      properties:
        success:
          type: boolean
        data:
          $ref: '#/components/schemas/CallsTestCampaignTriggerResult'
    AgentsErrorResponse:
      type: object
      additionalProperties: {}
      required:
        - success
        - error
        - message
      properties:
        success:
          type: boolean
        error:
          type: string
          description: Machine-readable error code.
          example: VALIDATION
        message:
          type: string
          description: Human-readable explanation safe to show to an operator.
          example: locationId is required.
        references:
          type: object
          additionalProperties: {}
          description: Structured conflict details. Present on delete conflicts.
        details:
          type: array
          description: Field-level validation details when available.
          items:
            type: object
            additionalProperties: false
            required:
              - field
              - message
            properties:
              field:
                type:
                  - string
                  - 'null'
                example: locationId
              message:
                type: string
                example: locationId is required.
    CallsTestCampaignTriggerResult:
      type: object
      additionalProperties: false
      required:
        - intentId
        - locationId
        - campaignId
        - activeTags
        - expiresAt
      properties:
        intentId:
          type: string
          example: 66a91f0b0d8f3b2b79a01f12
        locationId:
          type: string
          example: loc_9f7a123
        contactId:
          type:
            - string
            - 'null'
          description: >-
            The GHL contact the test ran against — echoed back, including when
            created/reused from an inline `contact`. Null for inbound dial-in
            tests.
          example: contact_123
        contactCreated:
          type: boolean
          description: >-
            True when a GHL contact was created (or reused by phone) from an
            inline `contact` on this call.
          example: false
        campaignId:
          type: string
          example: campaign_speed_to_lead_123
        activeTags:
          type: array
          items:
            type: string
          example:
            - new_lead
        triggerKind:
          type: string
          example: tag_added
        calendarId:
          type:
            - string
            - 'null'
          example: calendar_main_booking
        appointmentId:
          type:
            - string
            - 'null'
          example: null
        appointmentStartTime:
          type:
            - string
            - 'null'
          format: date-time
          example: null
        dialNumber:
          type:
            - string
            - 'null'
          example: '+14155551234'
        callerPhone:
          type:
            - string
            - 'null'
          example: '+14155559876'
        agentTest:
          type: boolean
          example: false
        expiresAt:
          type: string
          format: date-time
          example: '2026-07-08T16:35:00.000Z'
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
      description: 'Send your API key as `Authorization: Bearer YOUR_API_KEY`.'

````