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

# Score a ScenarioRun.

> Score a currently running ScenarioRun.



## OpenAPI

````yaml /openapi-specs/stainless-processed-openapi.json post /v1/scenarios/runs/{id}/score
openapi: 3.1.0
info:
  title: RunLoop API
  version: '0.1'
  description: >-
    The RunLoop API spec that allows you to host lambda functions and Devboxes
    to enable scaled long running ai workflows.
  contact:
    name: Runloop AI Support
    url: https://runloop.ai
    email: support@runloop.ai
servers:
  - url: https://api.runloop.ai
    description: Runloop API
    variables: {}
security:
  - bearerAuth: []
tags:
  - name: Benchmark
  - name: Blueprint
  - name: Blueprint-Lifecycle
  - name: Blueprint-ObservabilityTools
  - name: Devbox
  - name: Devbox-FileTools
  - name: Devbox-Lifecycle
  - name: Devbox-NetworkTools
  - name: Devbox-ObservabilityTools
  - name: Devbox-PersistenceTools
  - name: Devbox-ShellTools
  - name: Scenario
  - name: ScenarioScorer
  - name: accounts
  - name: agents
  - name: apikeys
  - name: axons
  - name: executions
  - name: gateway-configs
  - name: mcp-configs
  - name: network-policies
  - name: objects
  - name: restricted_keys
  - name: secrets
  - name: streaming
paths:
  /v1/scenarios/runs/{id}/score:
    post:
      tags:
        - Scenario
      summary: Score a ScenarioRun.
      description: Score a currently running ScenarioRun.
      operationId: scoreScenarioRun
      parameters:
        - name: id
          in: path
          description: The ScenarioRun ID.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScenarioRunView'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Runloop from '@runloop/api-client';

            const client = new Runloop({
              bearerToken: process.env['RUNLOOP_API_KEY'], // This is the default and can be omitted
            });

            const scenarioRunView = await client.scenarios.runs.score('id');

            console.log(scenarioRunView.id);
        - lang: Python
          source: |-
            import os
            from runloop_api_client import Runloop

            client = Runloop(
                bearer_token=os.environ.get("RUNLOOP_API_KEY"),  # This is the default and can be omitted
            )
            scenario_run_view = client.scenarios.runs.score(
                "id",
            )
            print(scenario_run_view.id)
components:
  schemas:
    ScenarioRunView:
      type: object
      description: >-
        A ScenarioRunView represents a single run of a Scenario on a Devbox.
        When completed, the ScenarioRun will contain the final score and output
        of the run.
      properties:
        id:
          type: string
          description: ID of the ScenarioRun.
        name:
          description: Optional name of ScenarioRun.
          type:
            - string
            - 'null'
        scenario_id:
          type: string
          description: ID of the Scenario that has been run.
        devbox_id:
          type: string
          description: ID of the Devbox on which the Scenario is running.
        benchmark_run_id:
          description: >-
            ID of the BenchmarkRun that this Scenario is associated with, if
            any.
          type:
            - string
            - 'null'
        scoring_contract_result:
          description: The scoring result of the ScenarioRun.
          anyOf:
            - $ref: '#/components/schemas/ScoringContractResultView'
            - type: 'null'
        start_time_ms:
          type: integer
          format: int64
          description: The time that the scenario started
        duration_ms:
          format: int64
          description: Duration scenario took to run.
          type:
            - integer
            - 'null'
        state:
          $ref: '#/components/schemas/ScenarioRunState'
          description: The state of the ScenarioRun.
        metadata:
          type: object
          additionalProperties:
            type: string
          description: >-
            User defined metadata to attach to the scenario run for
            organization.
        purpose:
          description: Purpose of the ScenarioRun.
          type:
            - string
            - 'null'
        environment_variables:
          additionalProperties:
            type: string
          description: Environment variables used to run the scenario.
          type:
            - object
            - 'null'
        secrets_provided:
          additionalProperties:
            type: string
          description: User secrets used to run the scenario.
          type:
            - object
            - 'null'
      required:
        - id
        - scenario_id
        - devbox_id
        - state
        - metadata
    ScoringContractResultView:
      type: object
      description: >-
        A ScoringContractResultView represents the result of running all scoring
        functions on a given input context.
      properties:
        score:
          type: number
          format: float
          description: >-
            Total score for all scoring contracts. This will be a value between
            0 and 1.
        scoring_function_results:
          type: array
          items:
            $ref: '#/components/schemas/ScoringFunctionResultView'
          description: List of all individual scoring function results.
      required:
        - score
        - scoring_function_results
    ScenarioRunState:
      type: string
      enum:
        - running
        - scoring
        - scored
        - completed
        - canceled
        - timeout
        - failed
    ScoringFunctionResultView:
      type: object
      description: >-
        A ScoringFunctionResultView represents the result of running a single
        scoring function on a given input context.
      properties:
        score:
          type: number
          format: float
          description: Final score for the given scoring function.
        scoring_function_name:
          type: string
          description: Scoring function name that ran.
        output:
          type: string
          description: Log output of the scoring function.
        state:
          $ref: '#/components/schemas/ScoringFunctionResultViewState'
          description: The state of the scoring function application.
      required:
        - score
        - scoring_function_name
        - output
        - state
    ScoringFunctionResultViewState:
      type: string
      enum:
        - unknown
        - complete
        - error
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````