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

# Simulate a decision with a trace

> Run a version — or unsaved editor content — and return the trace.

Simulation is privileged, not read-only. JDM function nodes evaluate
expressions, so passing `content` is expression execution inside the
service: that path needs `author` or above and runs under a
wall-clock timeout and a size cap. Passing `version` runs stored
content and only needs `simulator`.

**Required roles**: `simulator` for `version`; `author` for `content`



## OpenAPI

````yaml post /api/decisions/{workspace}/{key}/simulate
openapi: 3.1.0
info:
  title: Nx1 AI API
  description: |

    AI API for Nx1 Data Platform Management and Automated Data Tasks.

    Authentication is required via PSK in Authorization header.

    Default PSK is | [ask a friend] |
  version: 0.10.2
servers: []
security: []
paths:
  /api/decisions/{workspace}/{key}/simulate:
    post:
      tags:
        - Decisions
      summary: Simulate a decision with a trace
      description: |-
        Run a version — or unsaved editor content — and return the trace.

        Simulation is privileged, not read-only. JDM function nodes evaluate
        expressions, so passing `content` is expression execution inside the
        service: that path needs `author` or above and runs under a
        wall-clock timeout and a size cap. Passing `version` runs stored
        content and only needs `simulator`.

        **Required roles**: `simulator` for `version`; `author` for `content`
      operationId: simulate_api_decisions__workspace___key__simulate_post
      parameters:
        - name: workspace
          in: path
          required: true
          schema:
            type: string
            maxLength: 64
            pattern: ^[a-z0-9][a-z0-9-]{0,63}$
            description: Workspace slug.
            title: Workspace
          description: Workspace slug.
        - name: key
          in: path
          required: true
          schema:
            type: string
            maxLength: 64
            pattern: ^[a-z0-9][a-z0-9-]{0,63}$
            description: Decision key — a flat slug, never a path.
            title: Key
          description: Decision key — a flat slug, never a path.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SimulateRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SimulateResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '408':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Request Timeout
        '413':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Content Too Large
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable Content
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - OAuth2AuthorizationCodeBearer: []
        - APIKeyHeader: []
components:
  schemas:
    SimulateRequest:
      properties:
        context:
          additionalProperties: true
          type: object
          title: Context
          description: Input context to simulate against.
        version:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Version
          description: Persisted version to simulate. Preferred.
        content:
          anyOf:
            - type: string
            - type: 'null'
          title: Content
          description: >-
            Unsaved JDM content from the editor. Function nodes evaluate
            expressions, so this path requires the `author` role or above and
            runs under a wall-clock timeout.
        trace:
          type: boolean
          title: Trace
          description: Include the node-by-node trace.
          default: true
      type: object
      title: SimulateRequest
    SimulateResponse:
      properties:
        workspace:
          type: string
          title: Workspace
        key:
          type: string
          title: Key
        version:
          anyOf:
            - type: integer
            - type: 'null'
          title: Version
        content_sha:
          anyOf:
            - type: string
            - type: 'null'
          title: Content Sha
        inline:
          type: boolean
          title: Inline
          description: True when unsaved content was simulated.
          default: false
        result:
          title: Result
        performance:
          anyOf:
            - type: string
            - type: 'null'
          title: Performance
        trace:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Trace
        latency_ms:
          type: number
          title: Latency Ms
      type: object
      required:
        - workspace
        - key
        - result
        - latency_ms
      title: SimulateResponse
    ErrorResponse:
      properties:
        error:
          type: string
          title: Error
          description: A brief description of the error that occurred.
        code:
          type: integer
          title: Code
          description: The HTTP status code associated with the error.
          default: 500
      type: object
      required:
        - error
      title: ErrorResponse
  securitySchemes:
    OAuth2AuthorizationCodeBearer:
      type: oauth2
      flows:
        authorizationCode:
          scopes: {}
          authorizationUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/auth
          tokenUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/token
    APIKeyHeader:
      type: apiKey
      in: header
      name: Authorization-PSK

````