> ## Documentation index
> Fetch the complete documentation index at: https://dify-docs.docs7.io/llms.txt
> Ask it with GET https://dify-docs.docs7.io/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.

# Run Pipeline

> Runs the full knowledge pipeline over one or more datasources. `response_mode` selects a streaming or blocking response.

`POST /datasets/{dataset_id}/pipeline/run`

## OpenAPI

````yaml en/api-reference/openapi_service.json post /datasets/{dataset_id}/pipeline/run
openapi: 3.0.1
info:
  description: REST API for Dify applications and knowledge bases. Application
    endpoints authenticate with an app API key; knowledge endpoints authenticate
    with a dataset API key.
  title: Dify Service API
  version: 1.0.0
servers:
  - description: Base URL of the Dify Service API. For self-hosted deployments,
      replace it with your own API base URL.
    url: https://{api_base_url}
    variables:
      api_base_url:
        default: api.dify.ai/v1
        description: Host and path of the API base URL, without the `https://` prefix.
security:
  - ApiKeyAuth: []
tags:
  - description: Operations related to chat messages and interactions.
    name: Chat Messages
  - description: File upload and preview operations.
    name: Files
  - description: Operations related to end user information.
    name: End Users
  - description: User feedback operations.
    name: Feedback
  - description: Operations related to managing conversations.
    name: Conversations
  - description: Text-to-Speech and Speech-to-Text operations.
    name: Audio
  - description: Operations to retrieve application settings and information.
    name: Applications
  - description: Operations related to managing annotations for direct replies.
    name: Annotations
  - description: Endpoints for resuming paused workflows that require human input.
    name: Human Input
  - description: Operations for executing and managing workflows.
    name: Workflow Runs
  - description: Operations related to text generation and completion.
    name: Completion Messages
  - description: Operations for managing knowledge bases, including creation,
      configuration, and retrieval.
    name: Knowledge Bases
  - description: Operations for creating, updating, and managing documents within a
      knowledge base.
    name: Documents
  - description: Operations for managing document chunks and child chunks.
    name: Chunks
  - description: Operations for managing knowledge base metadata fields and document
      metadata values.
    name: Metadata
  - description: Operations for managing knowledge base tags and tag bindings.
    name: Tags
  - description: Operations for retrieving available models.
    name: Models
  - description: Operations for managing and running knowledge pipelines, including
      datasource plugins and pipeline execution.
    name: Knowledge Pipeline
paths:
  /datasets/{dataset_id}/pipeline/run:
    post:
      description: Runs the full knowledge pipeline over one or more datasources.
        `response_mode` selects a streaming or blocking response.
      operationId: runPipeline
      parameters:
        - description: Knowledge base ID, from [List Knowledge
            Bases](/en/api-reference/knowledge-bases/list-knowledge-bases). For
            a scoped key, [copy the ID from the Dify
            URL](/en/api-reference/guides/knowledge#knowledge-base-id).
          in: path
          name: dataset_id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            examples:
              local_file:
                summary: Request Example - Local file
                value:
                  datasource_info_list:
                    - name: quarterly-report.pdf
                      reference: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                  datasource_type: local_file
                  inputs: {}
                  is_published: true
                  response_mode: blocking
                  start_node_id: "1719288585006"
              online_document:
                summary: Request Example - Online document
                value:
                  datasource_info_list:
                    - credential_id: cred-789xyz
                      page:
                        page_id: pg-def456
                        page_name: Product Roadmap
                        type: page
                      workspace_id: ws-abc123
                  datasource_type: online_document
                  inputs: {}
                  is_published: true
                  response_mode: streaming
                  start_node_id: "1719288585006"
              online_drive:
                summary: Request Example - Online drive
                value:
                  datasource_info_list:
                    - bucket: my-bucket
                      id: file-abc123
                      name: meeting-notes.docx
                      type: file
                  datasource_type: online_drive
                  inputs: {}
                  is_published: true
                  response_mode: blocking
                  start_node_id: "1719288585006"
              website_crawl:
                summary: Request Example - Website crawl
                value:
                  datasource_info_list:
                    - title: Getting Started Guide
                      url: https://example.com/docs/getting-started
                  datasource_type: website_crawl
                  inputs: {}
                  is_published: true
                  response_mode: blocking
                  start_node_id: "1719288585006"
            schema:
              properties:
                datasource_info_list:
                  description: List of datasource objects to process. The expected item structure
                    depends on `datasource_type`.
                  items:
                    oneOf:
                      - properties:
                          name:
                            description: Document title. Defaults to `"untitled"`.
                            type: string
                          reference:
                            description: Use the `id` returned by the [Upload Pipeline
                              File](/en/api-reference/knowledge-pipeline/upload-pipeline-file)
                              endpoint. `related_id` is accepted as an alias.
                            type: string
                        required:
                          - reference
                        title: Local File
                        type: object
                      - properties:
                          credential_id:
                            description: Credential for authenticating with the external platform. Managed
                              via the Dify console. If omitted, the provider's
                              default credential is used.
                            type: string
                          page:
                            description: Page details.
                            properties:
                              page_id:
                                description: Page identifier.
                                type: string
                              page_name:
                                description: Display name. Defaults to `"untitled"`.
                                type: string
                              type:
                                description: Page type defined by the datasource plugin (e.g., `"page"`,
                                  `"database"`).
                                type: string
                            required:
                              - page_id
                              - type
                            type: object
                          workspace_id:
                            description: ID of the workspace or database in the external platform (e.g., a
                              Notion workspace ID).
                            type: string
                        required:
                          - workspace_id
                          - page
                        title: Online Document
                        type: object
                      - properties:
                          title:
                            description: Used as the document name. Defaults to `"untitled"`.
                            type: string
                          url:
                            description: URL to crawl.
                            type: string
                        required:
                          - url
                        title: Website Crawl
                        type: object
                      - properties:
                          bucket:
                            description: Storage bucket name. Required by some drive providers (e.g.,
                              S3-compatible stores); omit if the provider does
                              not use buckets.
                            type: string
                          id:
                            description: File or folder ID.
                            type: string
                          name:
                            description: File name. Defaults to `"untitled"`.
                            type: string
                          type:
                            description: Whether this entry is a single file or a folder to expand.
                            enum:
                              - file
                              - folder
                            type: string
                        required:
                          - id
                          - type
                        title: Online Drive
                        type: object
                  type: array
                datasource_type:
                  description: Type of the datasource. Determines which fields are expected in
                    `datasource_info_list` items.
                  enum:
                    - local_file
                    - online_document
                    - website_crawl
                    - online_drive
                  type: string
                inputs:
                  additionalProperties: true
                  description: Key-value pairs for pipeline input variables defined in the
                    workflow. Pass `{}` if the pipeline has no input variables.
                  type: object
                is_published:
                  description: Whether to run the published version of the pipeline instead of the
                    current draft. Run the draft to test unpublished changes.
                  type: boolean
                response_mode:
                  description: Response mode for the pipeline execution. `streaming` returns a
                    Server-Sent Events stream, `blocking` waits and returns the
                    complete result.
                  enum:
                    - streaming
                    - blocking
                  type: string
                start_node_id:
                  description: ID of the node to start execution from, from [List Datasource
                    Plugins](/en/api-reference/knowledge-pipeline/list-datasource-plugins).
                  type: string
              required:
                - inputs
                - datasource_type
                - datasource_info_list
                - start_node_id
                - is_published
                - response_mode
              type: object
        required: true
      responses:
        "200":
          content:
            application/json:
              examples:
                success:
                  summary: Blocking Response Example
                  value:
                    data:
                      created_at: 1741267200
                      finished_at: 1741267210
                      id: f1e2d3c4-b5a6-7890-abcd-ef0987654321
                      outputs: {}
                      status: succeeded
                    task_id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                    workflow_run_id: f1e2d3c4-b5a6-7890-abcd-ef0987654321
              schema:
                additionalProperties: true
                description: Complete pipeline execution result. Returned when `response_mode`
                  is `blocking`.
                type: object
            text/event-stream:
              schema:
                description: >-
                  Server-Sent Events stream. Returned when `response_mode` is
                  `streaming`; see [SSE
                  Streaming](/en/api-reference/guides/streaming) for the wire
                  format.


                  Key events:


                  - `workflow_started`: execution began

                  - `node_started` / `node_finished`: per-node progress with
                  `node_id`, `node_type`, `status`, `inputs`, `outputs`

                  - `workflow_finished`: final result with `status`, `outputs`,
                  `total_tokens`, `elapsed_time`

                  - `ping`: keepalive
                type: string
          description: "Pipeline execution result. Format depends on `response_mode`:
            streaming returns a `text/event-stream`, blocking returns a JSON
            object."
        "400":
          content:
            application/json:
              examples:
                invalid_param:
                  summary: invalid_param
                  value:
                    code: invalid_param
                    message: Pipeline not found
                    status: 400
          description: "`invalid_param` : The knowledge base has no processing pipeline
            configured, or the request body failed validation."
        "403":
          content:
            application/json:
              examples:
                forbidden_1:
                  summary: forbidden (api access)
                  value:
                    code: forbidden
                    message: Dataset api access is not enabled.
                    status: 403
                forbidden_2:
                  summary: forbidden (key scope)
                  value:
                    code: forbidden
                    message: The API key is not authorized to access this knowledge base.
                    status: 403
          description: >-
            - `forbidden` : API access is not enabled for this knowledge base.

            - `forbidden` : The API key is scoped to specific knowledge bases,
            and this knowledge base is not one of them.
        "404":
          content:
            application/json:
              examples:
                not_found:
                  summary: not_found
                  value:
                    code: not_found
                    message: Dataset not found.
                    status: 404
          description: "`not_found` : No knowledge base matches `dataset_id`."
        "500":
          content:
            application/json:
              examples:
                pipeline_run_error:
                  summary: pipeline_run_error
                  value:
                    code: pipeline_run_error
                    message: "Pipeline execution failed: connection timeout"
                    status: 500
          description: "`pipeline_run_error` : Pipeline execution failed."
      summary: Run Pipeline
      tags:
        - Knowledge Pipeline
      x-mint:
        href: /en/api-reference/knowledge-pipeline/run-pipeline
        metadata:
          sidebarTitle: Run Pipeline
          title: Run Pipeline
components:
  securitySchemes:
    ApiKeyAuth:
      bearerFormat: API_KEY
      description: >-
        Every request authenticates with an API key: `Authorization: Bearer
        {API_KEY}`. App endpoints take an app API key; knowledge endpoints take
        a knowledge base API key ([Get
        Started](/en/api-reference/guides/get-started)).


        Keep keys server-side; never embed them in client code. Requests with a
        missing or invalid key fail with HTTP `401` (`unauthorized`).
      scheme: bearer
      type: http
````
