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

# Run a workflow

> Run an Optimization Studio workflow synchronously and return its output. Runs the workflow's published version; address a specific version with the `{versionId}` form of this path.



## OpenAPI

````yaml POST /api/workflows/{workflowId}/run
openapi: 3.1.0
info:
  title: LangWatch API
  version: 1.0.0
  description: LangWatch openapi spec
servers:
  - url: https://app.langwatch.ai
security:
  - project_api_key: []
paths:
  /api/workflows/{workflowId}/run:
    post:
      tags:
        - Workflows
      summary: Run a workflow
      description: >-
        Run an Optimization Studio workflow synchronously and return its output.
        Runs the workflow's published version; address a specific version with
        the `{versionId}` form of this path.
      operationId: postApiWorkflowsByWorkflowIdRun
      parameters:
        - schema:
            type: string
          in: path
          name: workflowId
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
              description: >-
                The workflow's input fields, named as the workflow's entry node
                names them
      responses:
        '200':
          description: The workflow finished; `result` holds its output fields
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - idle
                      - waiting
                      - running
                      - success
                      - error
                      - skipped
                    description: Execution state the run finished in
                  result:
                    type:
                      - object
                      - 'null'
                    additionalProperties: {}
                    description: >-
                      The workflow's output fields, named as the workflow names
                      them
                required:
                  - status
        '400':
          description: >-
            The request was not sent as application/json, or the body was not
            valid JSON
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                required:
                  - message
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                required:
                  - message
        '403':
          description: The API key lacks workflows:manage
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Stable failure code; branch on this
                  message:
                    type: string
                  fault:
                    type: string
                    description: >-
                      Who the failure is attributable to: customer, platform,
                      provider
                  tips:
                    type: array
                    items:
                      type: string
                  docsUrl:
                    type: string
                required:
                  - error
                additionalProperties: true
        '404':
          description: No such workflow, or it has never been published
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Stable failure code; branch on this
                  message:
                    type: string
                  fault:
                    type: string
                    description: >-
                      Who the failure is attributable to: customer, platform,
                      provider
                  tips:
                    type: array
                    items:
                      type: string
                  docsUrl:
                    type: string
                required:
                  - error
                additionalProperties: true
components:
  securitySchemes:
    project_api_key:
      type: apiKey
      in: header
      name: X-Auth-Token
      description: >-
        Project API key for sending traces and accessing project-scoped
        resources. Format: sk-lw-... (no underscore). Obtain one by creating a
        project via the Admin API or the LangWatch UI.

````