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

# Update Scenario

> Update a scenario's user-authored fields.

`origin`, `format`, `source_run_id`, `agent_id`, and `workspace_id` cannot be changed
via this endpoint -- same rationale as Create Scenario.



## OpenAPI

````yaml https://api.usetuner.ai/public/openapi.json put /api/v1/workspaces/{workspace_id}/agents/{agent_id}/scenarios/{scenario_id}
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/{scenario_id}:
    put:
      tags:
        - scenarios
      summary: Update Scenario
      description: >-
        Update a scenario's user-authored fields.


        `origin`, `format`, `source_run_id`, `agent_id`, and `workspace_id`
        cannot be changed

        via this endpoint -- same rationale as Create Scenario.
      operationId: >-
        update_scenario_api_v1_workspaces__workspace_id__agents__agent_id__scenarios__scenario_id__put
      parameters:
        - name: scenario_id
          in: path
          required: true
          schema:
            type: integer
            title: Scenario Id
        - 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/ScenarioAuthoringRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScenarioResponse'
        '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 or scenario not found.
          content:
            application/json:
              example:
                detail: Scenario with ID 9 not found
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: intent_id does not belong to this agent.
          content:
            application/json:
              example:
                detail: intent_id 9 does not belong to this agent.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - Bearer: []
components:
  schemas:
    ScenarioAuthoringRequest:
      properties:
        name:
          type: string
          maxLength: 200
          minLength: 1
          title: Name
        type:
          type: string
          enum:
            - routine
            - pressure
          title: Type
        situation:
          type: string
          maxLength: 8000
          minLength: 1
          title: Situation
        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
        intent_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Intent Id
        target_ai_evaluation:
          anyOf:
            - $ref: '#/components/schemas/TargetAiEvaluation'
            - type: 'null'
        tags:
          anyOf:
            - items:
                type: string
                maxLength: 50
              type: array
              maxItems: 20
            - type: 'null'
          title: Tags
      type: object
      required:
        - name
        - type
        - situation
      title: ScenarioAuthoringRequest
      description: >-
        Input schema for hand-authoring a scenario (used by both create and
        update).


        Named "authoring" rather than a generic "Input"/"Create" name because
        this shape is

        deliberately restricted to the fields a human can edit -- `origin`,
        `format`, and

        `source_run_id` are never part of this request; the endpoints that
        consume it set those

        fields themselves (see ScenarioService.create_manual_scenario).
    ScenarioResponse:
      properties:
        id:
          type: integer
          title: Id
        agent_id:
          type: integer
          title: Agent Id
        workspace_id:
          type: integer
          title: Workspace Id
        name:
          type: string
          title: Name
        type:
          type: string
          title: Type
        format:
          type: string
          title: Format
        origin:
          type: string
          title: Origin
        situation:
          type: string
          title: Situation
        goal:
          anyOf:
            - type: string
            - type: 'null'
          title: Goal
        first_line:
          anyOf:
            - type: string
            - type: 'null'
          title: First Line
        stop_condition:
          anyOf:
            - type: string
            - type: 'null'
          title: Stop Condition
        intent_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Intent Id
        target_ai_evaluation:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Target Ai Evaluation
        tags:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Tags
        source_run_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Source Run Id
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        last_run:
          anyOf:
            - $ref: '#/components/schemas/ScenarioExecutionItem'
            - type: 'null'
      type: object
      required:
        - id
        - agent_id
        - workspace_id
        - name
        - type
        - format
        - origin
        - situation
        - goal
        - first_line
        - stop_condition
        - intent_id
        - target_ai_evaluation
        - tags
        - source_run_id
        - created_at
        - updated_at
      title: ScenarioResponse
      description: Response schema for a single library scenario.
    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.
    TargetAiEvaluation:
      properties:
        type:
          type: string
          enum:
            - eval
            - outcome
          title: Type
        value:
          type: string
          title: Value
      type: object
      required:
        - type
        - value
      title: TargetAiEvaluation
    ScenarioExecutionItem:
      properties:
        simulation_run_id:
          type: integer
          title: Simulation Run Id
        run_created_at:
          type: string
          format: date-time
          title: Run Created At
        status:
          anyOf:
            - type: string
            - type: 'null'
          title: Status
        duration:
          anyOf:
            - type: number
            - type: 'null'
          title: Duration
        call_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Call Id
        analysis_stopped:
          type: boolean
          title: Analysis Stopped
        target_eval_label:
          anyOf:
            - type: string
            - type: 'null'
          title: Target Eval Label
        evals:
          items:
            $ref: '#/components/schemas/SimulationCallEvalResult'
          type: array
          title: Evals
        type:
          type: string
          title: Type
        evals_expected:
          type: boolean
          title: Evals Expected
      type: object
      required:
        - simulation_run_id
        - run_created_at
        - status
        - duration
        - call_id
        - analysis_stopped
        - target_eval_label
        - type
        - evals_expected
      title: ScenarioExecutionItem
      description: >-
        One past execution of a library scenario, within one simulation run.


        Deliberately its own class rather than a reuse of
        `SimulationCallDetailResponse`

        (`app/schemas/simulation_run.py`): that model already has a field called

        `scenario_id` meaning "the id of the `simulation_run_scenarios` row"
        (the execution

        record itself), which is a different concept from the library
        `scenario.id` this

        endpoint is scoped by. Reusing that model here would silently collide
        the two

        meanings under the same field name.


        Carries the same raw ingredients as `SimulationCallDetailResponse`

        (`status`, `call_id`, `duration`, `analysis_stopped`, `evals`, `type`,

        `target_eval_label`) that the web's `getScenarioVerdict()` helper

        (`voice-ray-web/src/lib/simulation/displayHelpers.ts`) already consumes
        to compute

        pass/fail client-side -- no server-side verdict is computed here, by
        design.


        Reused as-is (ENG-1541) for `ScenarioResponse.last_run`, the scenario
        list's additive

        "most recent execution" field -- same raw ingredients, one execution
        either way.
    SimulationCallEvalResult:
      properties:
        label:
          type: string
          title: Label
        value:
          anyOf:
            - type: string
            - type: 'null'
          title: Value
        evidence:
          anyOf:
            - type: string
            - type: 'null'
          title: Evidence
      type: object
      required:
        - label
        - value
        - evidence
      title: SimulationCallEvalResult
  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.