> ## 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.

# Add a website source

> Add a website to the agent's knowledge base and start crawling it.

The crawler starts at `sourceUrl` and follows links up to a fixed
depth. Subdomains are not crawled. Use `pageLimit` to cap the number of
pages visited, and `pageUrls` to pin pages that are always fetched,
even if the crawler does not reach them through links. Set
`syncInterval` to re-crawl the site on a schedule.

The request returns as soon as the crawl is queued, before it finishes.
Poll `GET .../sources/{sourceId}` to track progress.

This request is not idempotent: sending it twice creates two sources.



## OpenAPI

````yaml POST /v1/agents/{agentId}/knowledge-base/sources/websites
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/websites:
    parameters:
      - name: agentId
        in: path
        required: true
        schema:
          type: string
    post:
      tags:
        - Source Hub
      summary: Add a website source
      description: |-
        Add a website to the agent's knowledge base and start crawling it.

        The crawler starts at `sourceUrl` and follows links up to a fixed
        depth. Subdomains are not crawled. Use `pageLimit` to cap the number of
        pages visited, and `pageUrls` to pin pages that are always fetched,
        even if the crawler does not reach them through links. Set
        `syncInterval` to re-crawl the site on a schedule.

        The request returns as soon as the crawl is queued, before it finishes.
        Poll `GET .../sources/{sourceId}` to track progress.

        This request is not idempotent: sending it twice creates two sources.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWebsiteSourceBody'
      responses:
        '201':
          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
components:
  schemas:
    CreateWebsiteSourceBody:
      description: A website to crawl and add to the agent's knowledge base.
      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
        name:
          description: Display name of the source
          minLength: 1
          type: string
        sourceUrl:
          description: URL the crawl starts from. If no scheme is given, https is used
          minLength: 1
          type: string
        pageUrls:
          description: >-
            Pages fetched on every sync, even if the crawler does not reach them
            through links. Each must be on the same host as sourceUrl
            (subdomains count as different hosts). Pinned pages do not count
            towards pageLimit
          maxItems: 100
          type:
            - array
            - 'null'
          items:
            type: string
        pageLimit:
          description: >-
            Maximum number of pages the crawl visits. If omitted, the crawler
            default is used
          minimum: 1
          maximum: 100
          type:
            - integer
            - 'null'
        syncInterval:
          description: >-
            Interval between scheduled re-crawls, in seconds (1 to 30 days). If
            omitted or null, the site is not re-crawled on a schedule
          minimum: 86400
          maximum: 2592000
          type:
            - integer
            - 'null'
      required:
        - name
        - sourceUrl
    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

````