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

# Run a simulation plan

> Create and execute a job for an existing simulation run plan. Optionally provide runtime variables to override plan-defined variables.



## OpenAPI

````yaml /api-reference/openapi.documented.json post /v1/simulation/plan/{planId}/job
openapi: 3.1.0
info:
  title: Roark Analytics API
  description: >-
    The Roark Analytics API gives you access to the same API that powers the
    award winning Roark Analytics platform.
  version: 1.0.0
servers:
  - description: Production
    url: https://api.roark.ai
security:
  - Bearer: []
tags:
  - name: Agent
  - name: Agent Endpoint
  - name: Call
  - name: Chat
  - name: Metric
  - name: Metric Policy
  - name: Metric Collection Job
  - name: Simulation Persona
  - name: Simulation Scenario
  - name: Simulation Run Plan
  - name: Simulation Run Plan Job
  - name: Simulation Job
  - name: HTTP Request Definition
  - name: Webhook
  - name: Issue
  - name: Knowledge Base
  - name: Call Analysis
  - name: Health
paths:
  /v1/simulation/plan/{planId}/job:
    post:
      tags:
        - Simulation Run Plan Job
      summary: Run a simulation plan
      description: >-
        Create and execute a job for an existing simulation run plan. Optionally
        provide runtime variables to override plan-defined variables.
      operationId: postV1SimulationPlanByPlanIdJob
      parameters:
        - in: path
          name: planId
          schema:
            _def:
              checks:
                - kind: uuid
              typeName: ZodString
              coerce: false
            ~standard:
              version: 1
              vendor: zod
          required: true
          example: 7f3e4d2c-8a91-4b5c-9e6f-1a2b3c4d5e6f
          description: Simulation run plan ID
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunSimulationPlanBody'
      responses:
        '200':
          description: Successfully triggered simulation run plan
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/RunSimulationPlanResponse'
                required:
                  - data
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Authentication error
              example:
                type: authentication
                code: unauthorized
                message: Authentication required
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Permission error
              example:
                type: forbidden
                code: permission_denied
                message: You do not have permission to access this resource
          description: Forbidden
        '404':
          description: Simulation run plan not found
          content:
            application/json:
              schema:
                _def:
                  unknownKeys: strip
                  catchall:
                    _def:
                      typeName: ZodNever
                    ~standard:
                      version: 1
                      vendor: zod
                  typeName: ZodObject
                ~standard:
                  version: 1
                  vendor: zod
                _cached: null
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Rate limit error
              example:
                type: rate_limit
                code: too_many_requests
                message: Rate limit exceeded
          description: Too Many Requests
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Server error
              example:
                type: internal
                code: internal_error
                message: Internal server error
          description: Internal Server Error
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Roark from '@roarkanalytics/sdk';


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


            const response = await
            client.simulationRunPlanJob.start('7f3e4d2c-8a91-4b5c-9e6f-1a2b3c4d5e6f');


            console.log(response.data);
        - lang: Python
          source: |-
            import os
            from roark_analytics import Roark

            client = Roark(
                bearer_token=os.environ.get("ROARK_API_BEARER_TOKEN"),  # This is the default and can be omitted
            )
            response = client.simulation_run_plan_job.start(
                plan_id="7f3e4d2c-8a91-4b5c-9e6f-1a2b3c4d5e6f",
            )
            print(response.data)
components:
  schemas:
    RunSimulationPlanBody:
      type: object
      properties:
        variables:
          anyOf:
            - type: object
              additionalProperties:
                type: string
              description: >-
                Global format: key-value pairs that apply to ALL scenarios in
                the plan
              example:
                orderNumber: '12345'
                environment: staging
            - type: array
              items:
                type: object
                properties:
                  scenarioId:
                    type: string
                    format: uuid
                    description: ID of the scenario to apply variables to
                  variables:
                    type: object
                    additionalProperties:
                      type: string
                    description: Key-value pairs for this scenario
                required:
                  - scenarioId
                  - variables
              description: >-
                Scenario-specific format: an array of objects, each with a
                scenarioId and its variable key-value pairs
              example:
                - scenarioId: 550e8400-e29b-41d4-a716-446655440000
                  variables:
                    orderNumber: '12345'
                - scenarioId: 7a3d2e1f-c4b5-6a89-0d1e-2f3a4b5c6d7e
                  variables:
                    orderNumber: '67890'
          description: >-
            Runtime variables that override plan-defined scenario variables.
            Accepts one of two formats:


            Option 1 — Global (flat key-value object, applies to ALL scenarios):
              { "orderNumber": "12345", "environment": "staging" }

            Option 2 — Per-scenario (array of objects with scenarioId +
            variables):
              [
                { "scenarioId": "550e8400-...", "variables": { "orderNumber": "12345" } },
                { "scenarioId": "7a3d2e1f-...", "variables": { "orderNumber": "67890" } }
              ]
      description: >-
        Optional request body for running a simulation plan with runtime
        variables
    RunSimulationPlanResponse:
      type: object
      properties:
        simulationRunPlanId:
          type: string
          format: uuid
          description: ID of the simulation run plan that was executed
        simulationRunPlanJobId:
          type: string
          format: uuid
          description: ID of the simulation run plan job that was created
        status:
          type: string
          enum:
            - PENDING
            - QUEUED
            - CREATING_SNAPSHOTS
            - CREATING_SIMULATIONS
            - RUNNING_SIMULATIONS
            - COMPLETED
            - FAILED
            - TIMED_OUT
            - CANCELLED
            - CANCELLING
            - ENDING_SIMULATIONS
          description: Initial status of the job
        createdAt:
          type: string
          description: When the job was created
      required:
        - simulationRunPlanId
        - simulationRunPlanJobId
        - status
        - createdAt
      description: Response when triggering a simulation run plan
      example:
        simulationRunPlanId: 9a8b7c6d-5e4f-3210-abcd-ef9876543210
        simulationRunPlanJobId: 7f3e4d2c-8a91-4b5c-9e6f-1a2b3c4d5e6f
        status: PENDING
        createdAt: '2024-01-15T10:30:00Z'
    ErrorResponse:
      type: object
      properties:
        type:
          type: string
          enum:
            - validation
            - authentication
            - forbidden
            - not_found
            - conflict
            - rate_limit
            - internal
          description: The error type category
          examples:
            - validation
            - authentication
        code:
          type: string
          description: Machine-readable error code identifier
          examples:
            - invalid_parameter
            - missing_required_field
            - unauthorized
        message:
          type: string
          description: Human-readable error message
          examples:
            - The request was invalid
            - Authentication required
        param:
          type: string
          description: The parameter that caused the error (if applicable)
          examples:
            - email
            - user_id
        details:
          description: Additional error context information
      required:
        - type
        - code
        - message
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````