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

# Preview Scenario Prompt

> Preview the scenario editor's live prompt, built from the same code simulated
calls use.

Declared ahead of `GET /scenarios/{scenario_id}` (and its siblings) so a literal
`preview-prompt` path segment is never captured as a `scenario_id` path parameter.
No DB writes; `situation` may be empty since the user is mid-typing.

This is only the scenario's own instruction body (`build_scenario_instruction_body`).
At actual call time, `build_simulation_system_prompt` additionally wraps it with the
LangSmith-fetched caller-persona prefix, any customer-profile-facts block, and the
inbound/outbound caller footer -- none of that is part of this preview.



## OpenAPI

````yaml https://api.usetuner.ai/public/openapi.json post /api/v1/workspaces/{workspace_id}/agents/{agent_id}/scenarios/preview-prompt
openapi: 3.1.0
info:
  title: My Public API
  version: 1.0.0
servers:
  - url: https://api.usetuner.ai
security: []
tags:
  - name: calls
    x-group: Calls
  - name: workspaces
    x-group: Workspaces
  - name: simulation
    x-group: Simulation
  - name: agent-settings
    x-group: Agent Settings
  - name: agents
    x-group: Agents
  - name: scenarios
    x-group: Scenarios
  - name: traces
    x-group: Traces
  - name: providers
    x-group: Providers
paths:
  /api/v1/workspaces/{workspace_id}/agents/{agent_id}/scenarios/preview-prompt:
    post:
      tags:
        - scenarios
      summary: Preview Scenario Prompt
      description: >-
        Preview the scenario editor's live prompt, built from the same code
        simulated

        calls use.


        Declared ahead of `GET /scenarios/{scenario_id}` (and its siblings) so a
        literal

        `preview-prompt` path segment is never captured as a `scenario_id` path
        parameter.

        No DB writes; `situation` may be empty since the user is mid-typing.


        This is only the scenario's own instruction body
        (`build_scenario_instruction_body`).

        At actual call time, `build_simulation_system_prompt` additionally wraps
        it with the

        LangSmith-fetched caller-persona prefix, any customer-profile-facts
        block, and the

        inbound/outbound caller footer -- none of that is part of this preview.
      operationId: >-
        preview_scenario_prompt_api_v1_workspaces__workspace_id__agents__agent_id__scenarios_preview_prompt_post
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: integer
            description: Tuner's internal numeric ID for the agent.
            title: Agent Id
          description: Tuner's internal numeric ID for the agent.
        - name: workspace_id
          in: path
          required: true
          schema:
            type: integer
            description: Workspace ID. Find this in Workspace > General Settings.
            title: Workspace Id
          description: Workspace ID. Find this in Workspace > General Settings.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScenarioPromptPreviewRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScenarioPromptPreviewResponse'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              example:
                detail: Not authenticated
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: You do not have access to this workspace.
          content:
            application/json:
              example:
                detail: User does not have access to workspace 42
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Agent not found.
          content:
            application/json:
              example:
                detail: Agent with ID 17 not found
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - Bearer: []
components:
  schemas:
    ScenarioPromptPreviewRequest:
      properties:
        situation:
          type: string
          maxLength: 8000
          title: Situation
          default: ''
        goal:
          anyOf:
            - type: string
              maxLength: 2000
            - type: 'null'
          title: Goal
        first_line:
          anyOf:
            - type: string
              maxLength: 500
            - type: 'null'
          title: First Line
        stop_condition:
          anyOf:
            - type: string
              maxLength: 1000
            - type: 'null'
          title: Stop Condition
      type: object
      title: ScenarioPromptPreviewRequest
      description: >-
        Input for the scenario editor's live prompt preview (`POST
        /scenarios/preview-prompt`).


        Deliberately not `ScenarioAuthoringRequest`: `situation` here may be
        empty (the user is

        mid-typing in the editor), whereas creating/updating a library scenario
        requires a

        non-blank situation. Trimming behavior is otherwise identical, reusing
        the same

        validator helpers for consistency (DRY).
    ScenarioPromptPreviewResponse:
      properties:
        sections:
          items:
            $ref: '#/components/schemas/ScenarioPromptPreviewSection'
          type: array
          title: Sections
        prompt:
          type: string
          title: Prompt
      type: object
      required:
        - sections
        - prompt
      title: ScenarioPromptPreviewResponse
      description: >-
        Response for the scenario editor's live prompt preview.


        `prompt` is the exact text `build_scenario_instruction_body` would
        produce for these

        inputs -- byte-identical to what a simulated call built from this same
        scenario would

        use as its instruction body.
    ErrorResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Human-readable description of what went wrong.
      type: object
      required:
        - detail
      title: ErrorResponse
      description: Error body returned when a request fails.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ScenarioPromptPreviewSection:
      properties:
        key:
          type: string
          enum:
            - situation
            - first_line
            - goal
            - stop_condition
          title: Key
        label:
          type: string
          title: Label
        value:
          type: string
          title: Value
      type: object
      required:
        - key
        - label
        - value
      title: ScenarioPromptPreviewSection
      description: >-
        One labelled part of the previewed prompt, for the web to render under a
        heading.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    Bearer:
      type: http
      description: >-
        Use Tuner API key (tr_api_...) or user session token. Find your API key
        in Workspace Settings > API Keys.
      scheme: bearer

````

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