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 1.10.0+. Also available in JavaScript as
createWebSource and the other web source methods (@moss-js/moss
1.10.0+). Crawling, manual re-sync, and scheduled refresh are plan gated; see
Pricing.Methods
All methods areasync and the crawl settings are keyword-only.
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
delete_web_sourceremoves only that source’s pages. Other sources and documents added withadd_docsare 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
create_web_sourcecalls. - Every source on an index uses the index’s embedding model, fixed when the index is created.
Create options
Keyword arguments ofcreate_web_source, all optional:
Update options
Keyword arguments ofupdate_web_source. Arguments 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.
max_documents, respect_robots, and parse_documents are changed through the
updateWebSource API action.
The WebSource record
Every method except delete returns a frozenWebSource dataclass:
CreateWebSourceResult adds job_id. UpdateWebSourceResult adds job_id when resync
was True. ResyncWebSourceResult has id, job_id, and status. DeleteWebSourceResult
has deleted, id, and purge_job_id, which is None when there was nothing to purge, for
example when the index was already deleted.
Polling jobs
Crawl and purge jobs are polled withget_job_status(job_id), which returns a
JobStatusResponse. Its status is a
JobStatus object: compare status.value with the JobStatus
constants, as in the example above, rather than the object itself. current_phase.value
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.value == JobStatus.BUILDING with the phase "queued".
Errors
Every method raisesManageApiError 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.