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

# Invoke Workflow Handler



## OpenAPI

````yaml /openapi.yaml post /v1/workflow-definitions/{definition_id}/invoke
openapi: 3.1.0
info:
  title: Knowledge Stack API
  description: Knowledge Stack backend API for authentication and knowledge management
  version: 0.1.0
servers:
  - url: http://localhost:8000
    description: Knowledge Stack API local dev server
security: []
tags:
  - name: auth
    description: Authentication and identity management
  - name: users
    description: User accounts
  - name: tenants
    description: Tenant management
  - name: invites
    description: Tenant invitations
  - name: folders
    description: Folder management
  - name: documents
    description: Document management
  - name: document-versions
    description: Document version management
  - name: sections
    description: Document sections
  - name: chunks
    description: Chunk CRUD and semantic search
  - name: chunk-lineages
    description: Chunk lineage tracking
  - name: tags
    description: Tag management
  - name: path-parts
    description: Path part traversal and tagging
  - name: Threads
    description: Thread conversations
  - name: Thread Messages
    description: Thread message management
  - name: user-permissions
    description: User path permissions
  - name: workflows
    description: Ingestion workflows
paths:
  /v1/workflow-definitions/{definition_id}/invoke:
    post:
      tags:
        - Workflow Definitions
      summary: Invoke Workflow Handler
      operationId: invoke_workflow
      parameters:
        - name: definition_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Definition Id
        - name: authorization
          in: header
          required: false
          schema:
            type: string
            nullable: true
            title: Authorization
        - name: ks_uat
          in: cookie
          required: false
          schema:
            type: string
            nullable: true
            title: Ks Uat
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InvokeWorkflowRequest'
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowRunResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    InvokeWorkflowRequest:
      properties:
        idempotency_key:
          type: string
          maxLength: 255
          nullable: true
          title: Idempotency Key
          description: Optional key to prevent duplicate runs from retries
      additionalProperties: false
      type: object
      title: InvokeWorkflowRequest
      description: Request body for invoking a workflow definition.
    WorkflowRunResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        workflow_definition_id:
          type: string
          format: uuid
          title: Workflow Definition Id
        user_id:
          type: string
          format: uuid
          title: User Id
        runner_type:
          $ref: '#/components/schemas/WorkflowRunnerType'
        status:
          $ref: '#/components/schemas/WorkflowRunStatus'
        started_at:
          type: string
          format: date-time
          title: Started At
        completed_at:
          type: string
          format: date-time
          nullable: true
          title: Completed At
        run_snapshot:
          $ref: '#/components/schemas/WorkflowRunSnapshot'
        error:
          type: string
          nullable: true
          title: Error
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      additionalProperties: false
      type: object
      required:
        - id
        - workflow_definition_id
        - user_id
        - runner_type
        - status
        - started_at
        - completed_at
        - run_snapshot
        - error
        - created_at
        - updated_at
      title: WorkflowRunResponse
      description: Workflow run response.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    WorkflowRunnerType:
      type: string
      enum:
        - SELF_HOSTED
      title: WorkflowRunnerType
      description: Runner that executes the workflow.
    WorkflowRunStatus:
      type: string
      enum:
        - PENDING
        - RUNNING
        - COMPLETED
        - FAILED
      title: WorkflowRunStatus
      description: Lifecycle status of a workflow run.
    WorkflowRunSnapshot:
      properties:
        workflow_definition_id:
          type: string
          format: uuid
          title: Workflow Definition Id
        workflow_name:
          type: string
          title: Workflow Name
        runner_type:
          $ref: '#/components/schemas/WorkflowRunnerType'
        user_id:
          type: string
          format: uuid
          title: User Id
        max_run_duration_seconds:
          type: integer
          title: Max Run Duration Seconds
        sources:
          items:
            $ref: '#/components/schemas/ABCDPathSnapshot'
          type: array
          title: Sources
        instructions:
          items:
            $ref: '#/components/schemas/ABCDPathSnapshot'
          type: array
          title: Instructions
        outputs:
          items:
            $ref: '#/components/schemas/ABCDPathSnapshot'
          type: array
          title: Outputs
        template:
          $ref: '#/components/schemas/ABCDPathSnapshot'
          nullable: true
      additionalProperties: false
      type: object
      required:
        - workflow_definition_id
        - workflow_name
        - runner_type
        - user_id
        - max_run_duration_seconds
        - sources
        - instructions
        - outputs
        - template
      title: WorkflowRunSnapshot
      description: Frozen ABCD configuration captured at workflow trigger time.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ABCDPathSnapshot:
      properties:
        path_part_id:
          type: string
          format: uuid
          title: Path Part Id
        materialized_path:
          type: string
          title: Materialized Path
        part_type:
          $ref: '#/components/schemas/PartType'
      additionalProperties: false
      type: object
      required:
        - path_part_id
        - materialized_path
        - part_type
      title: ABCDPathSnapshot
      description: Snapshot of a single ABCD path reference at trigger time.
    PartType:
      type: string
      enum:
        - FOLDER
        - DOCUMENT
        - DOCUMENT_VERSION
        - SECTION
        - CHUNK
        - THREAD
        - THREAD_MESSAGE
        - WORKFLOW_DEFINITION
        - WORKFLOW_RUN
      title: PartType
      description: Type of path part in the filesystem.

````