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

# Add sources by pattern

> Attaches all sources whose name matches a pattern (and type) to a knowledge base in one call — useful for bulk-adding a set of URLs or files you've already created. Requires a token with write access.



## OpenAPI

````yaml /openapi-knowledge-base.json post /knowledge-base/datasets/{dataset_id}/sources/pattern
openapi: 3.0.3
info:
  title: AnyReach Knowledge Base API
  version: 1.0.0
  description: Manage knowledge bases, their sources, and run retrieval queries.
servers:
  - url: https://api.anyreach.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Knowledge bases
    description: >-
      A knowledge base (a `dataset` in the API) is a collection of embedded
      content an agent can retrieve from.
  - name: Knowledge base sources
    description: Attach and detach sources to a knowledge base.
  - name: Sources
    description: >-
      A source is a file or URL whose content is ingested, chunked, and
      embedded.
paths:
  /knowledge-base/datasets/{dataset_id}/sources/pattern:
    post:
      tags:
        - Knowledge base sources
      summary: Add sources by pattern
      description: >-
        Attaches all sources whose name matches a pattern (and type) to a
        knowledge base in one call — useful for bulk-adding a set of URLs or
        files you've already created. Requires a token with write access.
      operationId: addKnowledgeBaseSourcesByPattern
      parameters:
        - name: dataset_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: The knowledge base ID.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddSourcesByPatternRequest'
            example:
              pattern: https://docs.example.com/help/%
              type: URL
      responses:
        '200':
          description: Matching sources attached and queued.
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    AddSourcesByPatternRequest:
      type: object
      required:
        - pattern
        - type
      properties:
        pattern:
          type: string
          description: Pattern matched against source names.
        type:
          $ref: '#/components/schemas/SourceType'
    SourceType:
      type: string
      enum:
        - FILE
        - URL
      description: Whether the source is an uploaded file or a crawled URL.
    Error:
      type: object
      properties:
        detail:
          type: string
          example: Dataset not found
  responses:
    Forbidden:
      description: The token's role doesn't grant access to this action.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: The resource does not exist.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Personal access token. See Authentication.

````