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

# Run Workflow

Initiate an execution of a Workflow by name. You can run the latest version, choose a version by label or version number, pass input variables and metadata, and optionally receive results asynchronously with a callback URL.

## Behavior Notes

* `workflow_label_name` and `workflow_version_number` identify a specific version; omit both to run the latest version.
* When `callback_url` is provided, the API accepts the run immediately and posts results to your callback when execution finishes.
* Use [Get Workflow Version Execution Results](/reference/workflow-version-execution-results) to poll for execution output.

## Related

* [Create Workflow](/reference/create-workflow)
* [Get Workflow Version Execution Results](/reference/workflow-version-execution-results)
* [Workflows](/why-promptlayer/workflows)


## OpenAPI

````yaml POST /workflows/{workflow_name}/run
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security:
  - ApiKeyAuth: []
paths:
  /workflows/{workflow_name}/run:
    post:
      tags:
        - workflow
      summary: Run Workflow
      operationId: runWorkflow
      parameters:
        - name: workflow_name
          in: path
          required: true
          schema:
            type: string
          description: The name of the workflow to execute.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunWorkflow'
            examples:
              runLatest:
                summary: Run latest version
                value:
                  input_variables:
                    user_message: I need help with billing
                  metadata:
                    environment: production
                  return_all_outputs: false
              runLabel:
                summary: Run production label
                value:
                  workflow_label_name: production
                  input_variables:
                    user_message: Hello
              asyncCallback:
                summary: Run asynchronously with callback
                value:
                  input_variables:
                    user_message: Hello
                  callback_url: https://example.com/promptlayer/workflow-callback
      responses:
        '201':
          description: Workflow execution created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunWorkflowResponse'
              examples:
                queued:
                  summary: Workflow execution started
                  value:
                    success: true
                    message: Workflow execution started
                    warning: null
                    workflow_version_execution_id: 98765
        '202':
          description: >-
            Accepted. Returned when callback_url is provided and the workflow
            will deliver results asynchronously.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunWorkflowResponse'
              examples:
                accepted:
                  summary: Accepted for callback delivery
                  value:
                    success: true
                    message: Workflow execution accepted
                    warning: null
                    workflow_version_execution_id: 98765
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    RunWorkflow:
      type: object
      properties:
        workflow_label_name:
          type: string
          nullable: true
          description: Specify a workflow label name to run a specific labeled version.
        workflow_version_number:
          type: integer
          nullable: true
          description: Specify a workflow version number to run a specific version.
        metadata:
          type: object
          additionalProperties:
            type: string
          nullable: true
          description: A dictionary of metadata key-value pairs.
        input_variables:
          type: object
          additionalProperties: true
          default: {}
          description: A dictionary of input variables required by the workflow.
        return_all_outputs:
          type: boolean
          default: false
          description: >-
            If set to `true`, all outputs from the workflow execution will be
            returned.
        callback_url:
          type: string
          format: uri
          nullable: true
          description: >-
            HTTP URL where execution results are posted asynchronously. When
            provided, the API returns 202 Accepted immediately.
      required: []
      description: >-
        Parameters to run a workflow by label, version number, or latest
        version. workflow_label_name and workflow_version_number are mutually
        exclusive.
    RunWorkflowResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Indicates if the request was successful.
        message:
          type: string
          description: A message describing the result.
        warning:
          type: string
          nullable: true
          description: Warning about missing or unused input variables, if any.
        workflow_version_execution_id:
          type: integer
          description: The ID of the created workflow execution.
      required:
        - success
        - message
        - workflow_version_execution_id
      description: Response after initiating a workflow execution.
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          default: false
          description: Indicates that the request failed.
        message:
          type: string
          description: Human-readable error message.
        error:
          type: string
          description: Machine-readable or fallback error message.
      additionalProperties: true
      description: >-
        Standard error response. Some legacy endpoints may return either message
        or error.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  responses:
    UnauthorizedError:
      description: Unauthorized - missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFoundError:
      description: Not found - requested resource does not exist or is not accessible.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: Validation error - request parameters or body are invalid.
      content:
        application/json:
          schema:
            oneOf:
              - $ref: '#/components/schemas/HTTPValidationError'
              - $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````