Skip to main content
A web source crawls a website into an index and keeps it up to date. The MossClient web source methods are typed wrappers over the /v1/manage web source actions: each call goes to the Moss cloud API with your project key, needs no index loaded locally, and works wherever the SDK runs.
Requires @moss-js/moss 1.10.0+. Also available in Python as create_web_source and the other web source methods (moss 1.10.0+). Crawling, manual re-sync, and scheduled refresh are plan gated; see Pricing.

Methods

These methods need the project key. A client built with a custom authenticator instead of a key throws Web source methods require a project key.

Several sites on one index

  • An index holds up to 20 web sources. Each root URL can be registered once per index; the URL with and without a trailing slash is the same source, and a repeat is refused with status 409.
  • Each source’s pages are tracked separately. A crawl or re-sync replaces only that source’s pages, and deleteWebSource removes only that source’s pages. Other sources and documents added with addDocs are never touched.
  • Crawls on the same index run one at a time. A crawl requested while another runs queues and starts on its own; you do not need to wait between createWebSource calls.
  • Every source on an index uses the index’s embedding model, fixed when the index is created.

Create options

CreateWebSourceOptions, all optional:

Update options

UpdateWebSourceOptions. Fields you leave out stay unchanged; crawl settings apply on the next crawl. Crawl settings cannot change while the source is crawling (status 409); the cadence can. maxDocuments, respectRobots, and parseDocuments are changed through the updateWebSource API action.

The WebSource record

Every method except delete returns a WebSource: CreateWebSourceResult adds jobId. UpdateWebSourceResult adds jobId when resync was true. ResyncWebSourceResult is { id, jobId, status }. DeleteWebSourceResult is { deleted, id, purgeJobId? }; purgeJobId is absent when there was nothing to purge, for example when the index was already deleted.

Polling jobs

Crawl and purge jobs are polled with getJobStatus(jobId), which resolves to a JobStatusResponse. status ends at 'completed' or 'failed'. currentPhase moves through 'queued' (waiting for another crawl or build on the index), 'crawling', 'parsing_documents' when linked files were found, and 'building_index'. A queued crawl reports status: 'building' with currentPhase: 'queued'.

Errors

Every method throws ManageApiError with the HTTP status and the API’s JSON error body in the message, which includes the Moss error code.

Environment

MOSS_CLOUD_API_BASE_URL overrides the API host used by the web source methods (default https://service.usemoss.dev). It does not affect the client’s other calls.