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

# Update a knowledge base source

> Update a file or website source. Only the fields included in the
request are changed.

The crawl settings (`sourceUrl`, `pageUrls`, `pageLimit`,
`syncInterval`) apply to website sources only. Changing `sourceUrl` or
pinning a new page starts a crawl immediately; other changes take
effect on the next crawl.

A 503 means the update could not be completed, though part of it may
already be saved. Retry the same request.



## OpenAPI

````yaml PATCH /v1/agents/{agentId}/knowledge-base/sources/{sourceId}
openapi: 3.1.0
info:
  title: PolyAI Agents API
  version: 1.0.11
  description: Manage PolyAI agents, telephony, deployments, and real-time configs.
servers:
  - url: https://api.us.poly.ai
    description: US region
  - url: https://api.eu.poly.ai
    description: EU region
  - url: https://api.uk.poly.ai
    description: UK region
  - url: https://api.studio.poly.ai
    description: Studio region
security:
  - polyApiKey: []
paths:
  /v1/agents/{agentId}/knowledge-base/sources/{sourceId}:
    parameters:
      - name: agentId
        in: path
        required: true
        schema:
          type: string
      - name: sourceId
        in: path
        required: true
        schema:
          type: string
    patch:
      tags:
        - Source Hub
      summary: Update a knowledge base source
      description: |-
        Update a file or website source. Only the fields included in the
        request are changed.

        The crawl settings (`sourceUrl`, `pageUrls`, `pageLimit`,
        `syncInterval`) apply to website sources only. Changing `sourceUrl` or
        pinning a new page starts a crawl immediately; other changes take
        effect on the next crawl.

        A 503 means the update could not be completed, though part of it may
        already be saved. Retry the same request.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateSourceBody'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SaveSourceResponse'
        '400':
          description: Validation error
        '401':
          description: Unauthorized – missing or invalid API key
        '403':
          description: Forbidden – insufficient permissions
        '404':
          description: Resource not found
components:
  schemas:
    UpdateSourceBody:
      description: >-
        Partial update to a knowledge base source.


        Only fields included in the body are changed. Only syncInterval and

        variantIds can be cleared with null; null for any other field is
        rejected.
      type: object
      properties:
        targetEnvSandbox:
          description: Whether the source is used in sandbox
          type:
            - boolean
            - 'null'
        targetEnvPrerelease:
          description: Whether the source is used in pre-release
          type:
            - boolean
            - 'null'
        targetEnvLive:
          description: Whether the source is used in live
          type:
            - boolean
            - 'null'
        variantIds:
          description: >-
            Variants the source applies to. If provided, replaces the current
            list; if omitted, the list is unchanged. An empty list or null
            applies the source to all variants
          type:
            - array
            - 'null'
          items:
            type: string
        name:
          description: Display name of the source
          minLength: 1
          type:
            - string
            - 'null'
        sourceUrl:
          description: >-
            Website only. URL the crawl starts from. Changing it starts a crawl.
            Rejected if any pinned page is on a different host
          minLength: 1
          type:
            - string
            - 'null'
        pageUrls:
          description: >-
            Website only. Pages to add to the pinned list; existing pinned pages
            are kept. Pinning a new page starts a crawl
          maxItems: 100
          type:
            - array
            - 'null'
          items:
            type: string
        pageLimit:
          description: >-
            Website only. Maximum number of pages each crawl visits. Lowering it
            does not remove pages already indexed
          minimum: 1
          maximum: 100
          type:
            - integer
            - 'null'
        syncInterval:
          description: >-
            Website only. Interval between scheduled re-crawls, in seconds (1 to
            30 days). Send null to stop scheduled re-crawls
          minimum: 86400
          maximum: 2592000
          type:
            - integer
            - 'null'
    SaveSourceResponse:
      description: The saved source, and whether a crawl was queued.
      type: object
      properties:
        source:
          description: The saved source
          allOf:
            - $ref: '#/components/schemas/SourceSettingsResponse'
        syncRequested:
          description: >-
            False if the source was saved but a required crawl could not be
            queued. Creating a website source always requires a crawl; an update
            requires one only when sourceUrl changes or a new page is pinned.
            True otherwise
          type: boolean
      required:
        - source
        - syncRequested
    SourceSettingsResponse:
      description: |-
        A knowledge base source as saved, without its document count or sync
        state. Sources are shared across all branches of the agent.
      type: object
      properties:
        targetEnvSandbox:
          description: Whether the source is used in sandbox
          type:
            - boolean
            - 'null'
        targetEnvPrerelease:
          description: Whether the source is used in pre-release
          type:
            - boolean
            - 'null'
        targetEnvLive:
          description: Whether the source is used in live
          type:
            - boolean
            - 'null'
        variantIds:
          description: >-
            Variants the source applies to. An empty list or null applies it to
            all variants
          type:
            - array
            - 'null'
          items:
            type: string
        id:
          description: Unique source identifier
          type: string
        accountId:
          description: Account this source belongs to
          type: string
        projectId:
          description: Agent (project) this source belongs to
          type:
            - string
            - 'null'
        name:
          description: Display name of the source
          type: string
        createdAt:
          description: When the source was created
          type: string
        updatedAt:
          description: When the source was last updated
          type:
            - string
            - 'null'
        createdBy:
          description: Email of the user who created the source
          type: string
        updatedBy:
          description: Email of the user who last updated the source
          type:
            - string
            - 'null'
        sourceType:
          description: Source type (file, website)
          type: string
        sourceUrl:
          description: URL a website source is crawled from
          type:
            - string
            - 'null'
        syncInterval:
          description: Seconds between scheduled syncs; null when not scheduled
          type:
            - integer
            - 'null'
        webScrapeConfig:
          description: How a website source is crawled
          anyOf:
            - $ref: '#/components/schemas/WebScrapeConfigResponse'
            - type: 'null'
      required:
        - id
        - accountId
        - name
        - createdAt
        - createdBy
        - sourceType
    WebScrapeConfigResponse:
      description: >-
        Crawl settings for a website source. Unset settings use the crawler
        defaults.
      type: object
      properties:
        pageLimit:
          description: Maximum number of pages the crawl visits
          type:
            - integer
            - 'null'
  securitySchemes:
    polyApiKey:
      type: apiKey
      in: header
      name: X-API-KEY

````