archastro.platform.v1.resources.knowledge_sources

  1# Copyright (c) 2026 ArchAstro Inc. Licensed under the MIT License.
  2# This file is auto-generated by @archastro/sdk-generator. Do not edit.
  3# Content hash: 481469aba270
  4
  5from __future__ import annotations
  6
  7import builtins
  8from datetime import datetime
  9from typing import Any, Literal, Required, TypedDict
 10
 11from pydantic import BaseModel, Field
 12
 13from ...runtime.http_client import HttpClient, SyncHttpClient
 14from ...types.common import ContextIngestion, KnowledgeSource, KnowledgeSourceKindListResponse
 15
 16
 17class KnowledgeSourceCreateInput(TypedDict, total=False):
 18    "Create a knowledge source"
 19
 20    agent: str | None
 21    "Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`."
 22    metadata: dict[str, Any] | None
 23    "Arbitrary key-value metadata to attach to the source. Returned as-is on reads."
 24    org: str | None
 25    "Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`)."
 26    parent_source: str | None
 27    "Parent knowledge source ID (`ksrc_...`). Use to create a child source."
 28    payload: dict[str, Any] | None
 29    "Type-specific configuration for the source. Shape depends on `type`."
 30    state: str | None
 31    'Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.'
 32    team: str | None
 33    "Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`."
 34    thread: str | None
 35    "Thread ID (`thr_...`) to associate this source with, if applicable."
 36    type: Required[str]
 37    "Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`."
 38    user: str | None
 39    "User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`."
 40
 41
 42class KnowledgeSourceUpdateInput(TypedDict, total=False):
 43    "Update a knowledge source"
 44
 45    metadata: dict[str, Any] | None
 46    "Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided."
 47    payload: dict[str, Any] | None
 48    "Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided."
 49    state: str | None
 50    'Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.'
 51
 52
 53class KnowledgeSourceIngestInputContent(TypedDict, total=False):
 54    content_type: str | None
 55    'MIME type of the content, e.g. `"application/pdf"` or `"text/plain"`.'
 56    data: Required[str]
 57    'The raw document bytes. When `data_encoding` is `"base64"`, provide the base64-encoded representation of the binary content.'
 58    data_encoding: str | None
 59    'Encoding format of `data`. One of `"raw"` (default, plain text) or `"base64"` (binary content such as images or PDFs, decoded server-side before storage).'
 60    filename: str | None
 61    'Original filename for the document, e.g. `"report.pdf"`.'
 62
 63
 64class KnowledgeSourceIngestInput(TypedDict, total=False):
 65    "Trigger ingestion on a knowledge source"
 66
 67    content: KnowledgeSourceIngestInputContent | None
 68    "Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`."
 69    dedupe: bool | None
 70    "When `true`, reuse the source's existing document if the pushed content is byte-identical to it, instead of creating a duplicate. The reused document keeps its chunks and embeddings, and `title`/`metadata` from this request are still applied to it. Content that differs in any way always creates a new document. Defaults to `false`, which creates a new document on every push. Push mode only not valid with `pull: true`. Check `metadata.document_reused` on the returned ingestion to see whether a document was actually reused."
 71    file: str | None
 72    "ID of an already-uploaded file (`fil_...`). The runner reads filename and content type from the stored file. Upload the file via `POST /v1/files` first. Mutually exclusive with `content` and `pull`."
 73    metadata: dict[str, Any] | None
 74    "Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`."
 75    pull: bool | None
 76    "When `true`, re-triggers ingestion using the source's own configured data. Re-scrapes a `scrape/site`, re-fetches a `web/link`, or re-processes a `file/document`. Mutually exclusive with `file` and `content`. Not valid for `knowledge/documents` sources."
 77    title: str | None
 78    "Display title for the ingested document. Applied in push mode only; ignored when `pull: true`."
 79
 80
 81class KnowledgeSourceSearchInput(TypedDict, total=False):
 82    "Search within a knowledge source"
 83
 84    max_results: int | None
 85    "Maximum number of results to return. The platform applies its own upper bound; omit to use the default."
 86    min_similarity: float | None
 87    'Cosine-similarity floor for the vector leg, 0.0-1.0. Candidates below it are discarded before ranking, so a high value trades recall for precision. Pass `0.0` to disable the floor when a missed match costs more than a weak one note that with no floor every query returns results, so an empty response can no longer be read as "no match". Omit to use the default.'
 88    mode: str | None
 89    'Search algorithm to use. One of `"hybrid"` (default, combines vector and full-text), `"vector"` (semantic similarity only), or `"fulltext"` (keyword matching only).'
 90    query: Required[str]
 91    "Natural language or keyword query string to search for."
 92    recency_days: int | None
 93    "When set, limits results to documents ingested within the last N days. Omit to search across all documents regardless of age."
 94
 95
 96class KnowledgeSourceListResponseDataItem(BaseModel):
 97    agent: str | None = Field(
 98        default=None,
 99        description="ID of the agent that owns this source (`agt_...`). `null` if owned by a human user or team.",
100    )
101    context_installation: str | None = Field(
102        default=None,
103        description="ID of the context installation that provisioned this source (`cin_...`). `null` when the source was created directly rather than through an installation.",
104    )
105    created_at: datetime | None = Field(
106        default=None, description="When this knowledge source was created (ISO 8601)."
107    )
108    id: str = Field(..., description="Knowledge source ID (`cso_...`).")
109    metadata: dict[str, Any] | None = Field(
110        default=None,
111        description="Arbitrary key-value metadata attached to this source. Useful for storing caller-defined labels or references.",
112    )
113    org: str | None = Field(
114        default=None,
115        description="ID of the organization this source belongs to (`org_...`). `null` if not scoped to an org.",
116    )
117    parent_source: str | None = Field(
118        default=None,
119        description="ID of the parent knowledge source (`cso_...`) when this source was derived from another. `null` for top-level sources.",
120    )
121    payload: dict[str, Any] | None = Field(
122        default=None,
123        description="Type-specific configuration object. The keys depend on the source `type`; see the create endpoint for the expected shape per type.",
124    )
125    sandbox: str | None = Field(
126        default=None,
127        description="ID of the developer sandbox this source is scoped to (`sbx_...`). `null` outside sandbox contexts.",
128    )
129    state: str = Field(
130        ...,
131        description='Current lifecycle state of the source. One of `"active"` (ingestion running normally) or `"paused"` (ingestion suspended).',
132    )
133    team: str | None = Field(
134        default=None,
135        description="ID of the team that owns this source (`tea_...`). `null` if owned by a user, agent, or org.",
136    )
137    thread: str | None = Field(
138        default=None,
139        description="ID of the chat thread this source is associated with (`thr_...`). `null` when not thread-scoped.",
140    )
141    type: str = Field(
142        ...,
143        description='Source type identifier (e.g. `"gmail"`, `"github_activity"`). Determines the shape of `payload` and the ingestion behavior.',
144    )
145    updated_at: datetime | None = Field(
146        default=None, description="When this knowledge source was last modified (ISO 8601)."
147    )
148    user: str | None = Field(
149        default=None,
150        description="ID of the user that owns this source (`usr_...`). `null` if owned by a team, agent, or org.",
151    )
152
153
154class KnowledgeSourceListResponse(BaseModel):
155    """
156    Successful response
157    """
158
159    data: list[KnowledgeSourceListResponseDataItem] = Field(
160        ..., description="Array of knowledge source objects for the current page."
161    )
162    has_next: bool = Field(
163        ..., description="`true` if a subsequent page exists, `false` if this is the last page."
164    )
165    has_prev: bool = Field(
166        ..., description="`true` if a previous page exists, `false` if this is the first page."
167    )
168    page: int = Field(..., description="Current page number.")
169    page_size: int = Field(..., description="Number of results returned per page.")
170    total_entries: int = Field(
171        ..., description="Total number of knowledge sources matching the query across all pages."
172    )
173    total_pages: int = Field(..., description="Total number of pages available.")
174
175
176class KnowledgeSourceSearchResponseDataItem(BaseModel):
177    content: str | None = Field(
178        default=None, description="Normalized plain-text content of the matched chunk."
179    )
180    content_type: str | None = Field(
181        default=None, description='MIME type of the content, e.g. `"text/plain"` or `"text/html"`.'
182    )
183    created_at: datetime | None = Field(
184        default=None, description="When this item was indexed into the knowledge base (ISO 8601)."
185    )
186    id: str = Field(..., description="Context item ID (`cim_...`).")
187    kind: Literal["chunk"] = Field(
188        default="chunk",
189        description='Result variant discriminator. Always `"chunk"` for this object type.',
190    )
191    metadata: dict[str, Any] | None = Field(
192        default=None,
193        description="Arbitrary key-value metadata attached to this item by the source connector.",
194    )
195    raw_content: dict[str, Any] | None = Field(
196        default=None,
197        description="Raw content payload as stored by the source connector, before normalization.",
198    )
199    structured_data: str | None = Field(
200        default=None,
201        description="Public ID (`sda_...`) of the structured-data record attached to the source message. Present only for such items on source search.",
202    )
203    structured_data_summary: str | None = Field(
204        default=None,
205        description="Search summary of that record, computed when the request is served. When present, `content` is the indexed text and may be stale.",
206    )
207    type: str | None = Field(
208        default=None,
209        description='Type identifier of the parent knowledge source (e.g. `"gmail"`, `"github_activity"`). Returns `"unknown"` when the source association is not loaded.',
210    )
211
212
213class KnowledgeSourceSearchResponse(BaseModel):
214    """
215    Successful response
216    """
217
218    data: list[KnowledgeSourceSearchResponseDataItem] = Field(
219        ...,
220        description="Array of matching knowledge items ordered by relevance score descending. An item indexed from a message that has structured data attached also carries `structured_data` and `structured_data_summary`, the record's search summary computed at read time. `content` is still the indexed text and may be stale.",
221    )
222    degraded: bool | None = Field(
223        default=None,
224        description="True when a `hybrid` search ran fulltext only because the vector leg was unavailable. Absent when the query was empty.",
225    )
226    effective_mode: Literal["hybrid", "vector", "fulltext"] | None = Field(
227        default=None,
228        description="Retrieval mode that actually ran. Differs from the requested `mode` when a `hybrid` search fell back to `fulltext`. Absent when the query was empty.",
229    )
230
231
232class AsyncKnowledgeSourceKindResource:
233    def __init__(self, http: HttpClient):
234        self._http = http
235
236    async def list(self) -> KnowledgeSourceKindListResponse:
237        """
238        List creatable knowledge source kinds
239        Returns the fixed set of knowledge source types that can be created directly via
240        `POST /api/v1/knowledge_sources`. Use this endpoint to discover valid values for the
241        `type` param before calling the create endpoint.
242        Source kinds populated by server-driven flows such as `webhook/inbound`,
243        `connectors/*/emails`, and `thread/messages` are intentionally excluded from this
244        list, as they cannot be created through the API.
245
246        Returns:
247            List of knowledge source kinds available for creation via the API.
248        """
249        return await self._http.request(
250            "/api/v1/knowledge_sources/kinds",
251            response_type=KnowledgeSourceKindListResponse,
252        )
253
254
255class AsyncKnowledgeSourceResource:
256    def __init__(self, http: HttpClient):
257        self._http = http
258        self.kinds = AsyncKnowledgeSourceKindResource(http)
259
260    async def list(
261        self,
262        *,
263        page: int | None = None,
264        page_size: int | None = None,
265        search: str | None = None,
266        type: str | None = None,
267        team: builtins.list[str] | None = None,
268        thread: builtins.list[str] | None = None,
269        installation: str | None = None,
270        agent: str | None = None,
271        org: str | None = None,
272        owner_scope: Literal["any", "individual", "system"] | None = None,
273    ) -> KnowledgeSourceListResponse:
274        """
275        List knowledge sources
276        Returns a paginated list of knowledge sources visible to the authenticated caller.
277        Results are ordered by creation time descending.
278        Use the `type`, `installation`, `agent`, `org`, and `owner_scope` filters to narrow the
279        result set. Combine `owner_scope: "system"` with `org` to list org-level sources that
280        have no individual owner. Combine `owner_scope: "individual"` with `agent` to list
281        sources owned by a specific agent.
282        Pagination is page-number based. The default page size is 25.
283
284        Args:
285            page: Page number to retrieve. Defaults to 1.
286            page_size: Number of knowledge sources to return per page. Defaults to 25.
287            search: Filter sources whose type contains this string. Case-insensitive substring match.
288            type: Exact knowledge source type to filter by, e.g. `"knowledge/documents"`.
289            team: Exact team IDs whose sources to include.
290            thread: Exact backing thread IDs whose sources to include.
291            installation: Installation ID (`ins_...`). Returns only sources associated with this installation.
292            agent: Agent ID (`agt_...`). Returns only sources owned by or associated with this agent.
293            org: Organization ID (`org_...`). Returns only sources belonging to this organization. Combine with `owner_scope: "system"` to retrieve org-level system sources.
294            owner_scope: Filter by ownership scope. One of `"any"` (default returns all visible sources), `"individual"` (only sources owned by a user, team, or agent), or `"system"` (only sources with no individual owner, typically org-level).
295
296        Returns:
297            Successful response
298        """
299        query: dict[str, object] = {}
300        if page is not None:
301            query["page"] = page
302        if page_size is not None:
303            query["page_size"] = page_size
304        if search is not None:
305            query["search"] = search
306        if type is not None:
307            query["type"] = type
308        if team is not None:
309            query["team"] = team
310        if thread is not None:
311            query["thread"] = thread
312        if installation is not None:
313            query["installation"] = installation
314        if agent is not None:
315            query["agent"] = agent
316        if org is not None:
317            query["org"] = org
318        if owner_scope is not None:
319            query["owner_scope"] = owner_scope
320        return await self._http.request(
321            "/api/v1/knowledge_sources",
322            query=query,
323            response_type=KnowledgeSourceListResponse,
324        )
325
326    async def create(self, input: KnowledgeSourceCreateInput) -> KnowledgeSource:
327        """
328        Create a knowledge source
329        Creates a new knowledge source of the requested type and returns the created object.
330        Only types listed by `GET /api/v1/knowledge_sources/kinds` may be created through this
331        endpoint. Other source types such as `webhook/inbound`, `connectors/*/emails`, and
332        `thread/messages` are provisioned automatically by server-driven flows (webhook
333        auto-provisioning, installation activation, connector lifecycle events) and cannot be
334        created directly via the API.
335        Exactly one of `team`, `user`, `agent`, or `org` must identify the owner of the new
336        source. Omit `org` when an individual owner (`team`, `user`, or `agent`) is supplied;
337        include `org` alone for org-level system-owned sources.
338
339        Args:
340            input: Request body.
341            input.agent: Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`.
342            input.metadata: Arbitrary key-value metadata to attach to the source. Returned as-is on reads.
343            input.org: Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`).
344            input.parent_source: Parent knowledge source ID (`ksrc_...`). Use to create a child source.
345            input.payload: Type-specific configuration for the source. Shape depends on `type`.
346            input.state: Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.
347            input.team: Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`.
348            input.thread: Thread ID (`thr_...`) to associate this source with, if applicable.
349            input.type: Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`.
350            input.user: User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`.
351
352        Returns:
353            The newly created knowledge source.
354        """
355        return await self._http.request(
356            "/api/v1/knowledge_sources",
357            method="POST",
358            body=input,
359            response_type=KnowledgeSource,
360        )
361
362    async def delete(self, source: str) -> None:
363        """
364        Delete a knowledge source
365        Permanently deletes the knowledge source identified by `source`. This action is
366        irreversible all documents, embeddings, and ingestion history associated with the
367        source are removed.
368        The authenticated caller must own the source or have sufficient permissions within its
369        parent organization. Returns `204 No Content` on success.
370
371        Args:
372            source: Knowledge source ID (`ksrc_...`) to delete.
373
374        Returns:
375            Empty response. The source has been permanently deleted.
376        """
377        await self._http.request(f"/api/v1/knowledge_sources/{source}", method="DELETE")
378
379    async def get(self, source: str) -> KnowledgeSource:
380        """
381        Retrieve a knowledge source
382        Returns the knowledge source identified by `source`. The authenticated caller must have
383        access to the source's parent organization or be the individual owner of the source.
384        Use the list endpoint to retrieve many sources at once or to discover sources by type
385        or owner.
386
387        Args:
388            source: Knowledge source ID (`ksrc_...`) to retrieve.
389
390        Returns:
391            The requested knowledge source.
392        """
393        return await self._http.request(
394            f"/api/v1/knowledge_sources/{source}",
395            response_type=KnowledgeSource,
396        )
397
398    async def update(self, source: str, input: KnowledgeSourceUpdateInput) -> KnowledgeSource:
399        """
400        Update a knowledge source
401        Updates the mutable fields of an existing knowledge source and returns the updated
402        object. Only fields provided in the request body are changed; omitted fields retain
403        their current values.
404        You can update the type-specific `payload`, the `metadata` map, and the `state`. To
405        pause a source and prevent automatic ingestion, set `state` to `"paused"`. To resume,
406        set it back to `"active"`.
407
408        Args:
409            source: Knowledge source ID (`ksrc_...`) to update.
410            input: Request body.
411            input.metadata: Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided.
412            input.payload: Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided.
413            input.state: Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.
414
415        Returns:
416            The updated knowledge source.
417        """
418        return await self._http.request(
419            f"/api/v1/knowledge_sources/{source}",
420            method="PATCH",
421            body=input,
422            response_type=KnowledgeSource,
423        )
424
425    async def ingest(self, source: str, input: KnowledgeSourceIngestInput) -> ContextIngestion:
426        """
427        Trigger ingestion on a knowledge source
428        Starts an ingestion run on the specified knowledge source and returns the ingestion
429        object. Exactly one of two modes must be chosen per request:
430        **Push mode** (`file` or `content`) available for `knowledge/documents` sources only.
431        Supply the document bytes either as a reference to an already-uploaded file (`file`) or
432        as an inline blob (`content`). The runner stores the bytes and indexes the resulting
433        document. `title` and `metadata` are persisted on the document in push mode.
434        **Pull mode** (`pull: true`) re-triggers ingestion using the source's own configured
435        data. Use this to re-scrape a `scrape/site`, re-fetch a `web/link`, or re-process a
436        `file/document`. Not valid for `knowledge/documents` (which has no upstream push new
437        bytes instead) or for source kinds populated by server-driven flows. `title` and
438        `metadata` are ignored in pull mode.
439        If an ingestion is already active for the source, the existing ingestion is returned
440        rather than creating a duplicate.
441
442        Args:
443            source: Knowledge source ID (`ksrc_...`) to ingest.
444            input: Request body.
445            input.content: Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`.
446            input.dedupe: When `true`, reuse the source's existing document if the pushed content is byte-identical to it, instead of creating a duplicate. The reused document keeps its chunks and embeddings, and `title`/`metadata` from this request are still applied to it. Content that differs in any way always creates a new document. Defaults to `false`, which creates a new document on every push. Push mode only not valid with `pull: true`. Check `metadata.document_reused` on the returned ingestion to see whether a document was actually reused.
447            input.file: ID of an already-uploaded file (`fil_...`). The runner reads filename and content type from the stored file. Upload the file via `POST /v1/files` first. Mutually exclusive with `content` and `pull`.
448            input.metadata: Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`.
449            input.pull: When `true`, re-triggers ingestion using the source's own configured data. Re-scrapes a `scrape/site`, re-fetches a `web/link`, or re-processes a `file/document`. Mutually exclusive with `file` and `content`. Not valid for `knowledge/documents` sources.
450            input.title: Display title for the ingested document. Applied in push mode only; ignored when `pull: true`.
451
452        Returns:
453            The created ingestion, or an existing active ingestion if one is already running.
454        """
455        return await self._http.request(
456            f"/api/v1/knowledge_sources/{source}/ingest",
457            method="POST",
458            body=input,
459            response_type=ContextIngestion,
460        )
461
462    async def search(
463        self, source: str, input: KnowledgeSourceSearchInput
464    ) -> KnowledgeSourceSearchResponse:
465        """
466        Search within a knowledge source
467        Executes a search query against the indexed documents in a single knowledge source and
468        returns matching results ranked by relevance.
469        Three search modes are supported: `"hybrid"` (default) combines vector similarity and
470        full-text scoring, `"vector"` uses embedding-based semantic search only, and
471        `"fulltext"` uses keyword-based search only. Use `"hybrid"` for most use cases;
472        prefer `"vector"` when semantic meaning matters more than exact terms.
473        Optionally restrict results to documents ingested within the last N days using
474        `recency_days`. Results are ordered by relevance score descending.
475
476        Args:
477            source: Knowledge source ID (`ksrc_...`) to search within.
478            input: Request body.
479            input.max_results: Maximum number of results to return. The platform applies its own upper bound; omit to use the default.
480            input.min_similarity: Cosine-similarity floor for the vector leg, 0.0-1.0. Candidates below it are discarded before ranking, so a high value trades recall for precision. Pass `0.0` to disable the floor when a missed match costs more than a weak one note that with no floor every query returns results, so an empty response can no longer be read as "no match". Omit to use the default.
481            input.mode: Search algorithm to use. One of `"hybrid"` (default, combines vector and full-text), `"vector"` (semantic similarity only), or `"fulltext"` (keyword matching only).
482            input.query: Natural language or keyword query string to search for.
483            input.recency_days: When set, limits results to documents ingested within the last N days. Omit to search across all documents regardless of age.
484
485        Returns:
486            Successful response
487        """
488        return await self._http.request(
489            f"/api/v1/knowledge_sources/{source}/search",
490            method="POST",
491            body=input,
492            response_type=KnowledgeSourceSearchResponse,
493        )
494
495
496class KnowledgeSourceKindResource:
497    def __init__(self, http: SyncHttpClient):
498        self._http = http
499
500    def list(self) -> KnowledgeSourceKindListResponse:
501        """
502        List creatable knowledge source kinds
503        Returns the fixed set of knowledge source types that can be created directly via
504        `POST /api/v1/knowledge_sources`. Use this endpoint to discover valid values for the
505        `type` param before calling the create endpoint.
506        Source kinds populated by server-driven flows such as `webhook/inbound`,
507        `connectors/*/emails`, and `thread/messages` are intentionally excluded from this
508        list, as they cannot be created through the API.
509
510        Returns:
511            List of knowledge source kinds available for creation via the API.
512        """
513        return self._http.request(
514            "/api/v1/knowledge_sources/kinds",
515            response_type=KnowledgeSourceKindListResponse,
516        )
517
518
519class KnowledgeSourceResource:
520    def __init__(self, http: SyncHttpClient):
521        self._http = http
522        self.kinds = KnowledgeSourceKindResource(http)
523
524    def list(
525        self,
526        *,
527        page: int | None = None,
528        page_size: int | None = None,
529        search: str | None = None,
530        type: str | None = None,
531        team: builtins.list[str] | None = None,
532        thread: builtins.list[str] | None = None,
533        installation: str | None = None,
534        agent: str | None = None,
535        org: str | None = None,
536        owner_scope: Literal["any", "individual", "system"] | None = None,
537    ) -> KnowledgeSourceListResponse:
538        """
539        List knowledge sources
540        Returns a paginated list of knowledge sources visible to the authenticated caller.
541        Results are ordered by creation time descending.
542        Use the `type`, `installation`, `agent`, `org`, and `owner_scope` filters to narrow the
543        result set. Combine `owner_scope: "system"` with `org` to list org-level sources that
544        have no individual owner. Combine `owner_scope: "individual"` with `agent` to list
545        sources owned by a specific agent.
546        Pagination is page-number based. The default page size is 25.
547
548        Args:
549            page: Page number to retrieve. Defaults to 1.
550            page_size: Number of knowledge sources to return per page. Defaults to 25.
551            search: Filter sources whose type contains this string. Case-insensitive substring match.
552            type: Exact knowledge source type to filter by, e.g. `"knowledge/documents"`.
553            team: Exact team IDs whose sources to include.
554            thread: Exact backing thread IDs whose sources to include.
555            installation: Installation ID (`ins_...`). Returns only sources associated with this installation.
556            agent: Agent ID (`agt_...`). Returns only sources owned by or associated with this agent.
557            org: Organization ID (`org_...`). Returns only sources belonging to this organization. Combine with `owner_scope: "system"` to retrieve org-level system sources.
558            owner_scope: Filter by ownership scope. One of `"any"` (default returns all visible sources), `"individual"` (only sources owned by a user, team, or agent), or `"system"` (only sources with no individual owner, typically org-level).
559
560        Returns:
561            Successful response
562        """
563        query: dict[str, object] = {}
564        if page is not None:
565            query["page"] = page
566        if page_size is not None:
567            query["page_size"] = page_size
568        if search is not None:
569            query["search"] = search
570        if type is not None:
571            query["type"] = type
572        if team is not None:
573            query["team"] = team
574        if thread is not None:
575            query["thread"] = thread
576        if installation is not None:
577            query["installation"] = installation
578        if agent is not None:
579            query["agent"] = agent
580        if org is not None:
581            query["org"] = org
582        if owner_scope is not None:
583            query["owner_scope"] = owner_scope
584        return self._http.request(
585            "/api/v1/knowledge_sources",
586            query=query,
587            response_type=KnowledgeSourceListResponse,
588        )
589
590    def create(self, input: KnowledgeSourceCreateInput) -> KnowledgeSource:
591        """
592        Create a knowledge source
593        Creates a new knowledge source of the requested type and returns the created object.
594        Only types listed by `GET /api/v1/knowledge_sources/kinds` may be created through this
595        endpoint. Other source types such as `webhook/inbound`, `connectors/*/emails`, and
596        `thread/messages` are provisioned automatically by server-driven flows (webhook
597        auto-provisioning, installation activation, connector lifecycle events) and cannot be
598        created directly via the API.
599        Exactly one of `team`, `user`, `agent`, or `org` must identify the owner of the new
600        source. Omit `org` when an individual owner (`team`, `user`, or `agent`) is supplied;
601        include `org` alone for org-level system-owned sources.
602
603        Args:
604            input: Request body.
605            input.agent: Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`.
606            input.metadata: Arbitrary key-value metadata to attach to the source. Returned as-is on reads.
607            input.org: Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`).
608            input.parent_source: Parent knowledge source ID (`ksrc_...`). Use to create a child source.
609            input.payload: Type-specific configuration for the source. Shape depends on `type`.
610            input.state: Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.
611            input.team: Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`.
612            input.thread: Thread ID (`thr_...`) to associate this source with, if applicable.
613            input.type: Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`.
614            input.user: User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`.
615
616        Returns:
617            The newly created knowledge source.
618        """
619        return self._http.request(
620            "/api/v1/knowledge_sources",
621            method="POST",
622            body=input,
623            response_type=KnowledgeSource,
624        )
625
626    def delete(self, source: str) -> None:
627        """
628        Delete a knowledge source
629        Permanently deletes the knowledge source identified by `source`. This action is
630        irreversible all documents, embeddings, and ingestion history associated with the
631        source are removed.
632        The authenticated caller must own the source or have sufficient permissions within its
633        parent organization. Returns `204 No Content` on success.
634
635        Args:
636            source: Knowledge source ID (`ksrc_...`) to delete.
637
638        Returns:
639            Empty response. The source has been permanently deleted.
640        """
641        self._http.request(f"/api/v1/knowledge_sources/{source}", method="DELETE")
642
643    def get(self, source: str) -> KnowledgeSource:
644        """
645        Retrieve a knowledge source
646        Returns the knowledge source identified by `source`. The authenticated caller must have
647        access to the source's parent organization or be the individual owner of the source.
648        Use the list endpoint to retrieve many sources at once or to discover sources by type
649        or owner.
650
651        Args:
652            source: Knowledge source ID (`ksrc_...`) to retrieve.
653
654        Returns:
655            The requested knowledge source.
656        """
657        return self._http.request(
658            f"/api/v1/knowledge_sources/{source}",
659            response_type=KnowledgeSource,
660        )
661
662    def update(self, source: str, input: KnowledgeSourceUpdateInput) -> KnowledgeSource:
663        """
664        Update a knowledge source
665        Updates the mutable fields of an existing knowledge source and returns the updated
666        object. Only fields provided in the request body are changed; omitted fields retain
667        their current values.
668        You can update the type-specific `payload`, the `metadata` map, and the `state`. To
669        pause a source and prevent automatic ingestion, set `state` to `"paused"`. To resume,
670        set it back to `"active"`.
671
672        Args:
673            source: Knowledge source ID (`ksrc_...`) to update.
674            input: Request body.
675            input.metadata: Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided.
676            input.payload: Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided.
677            input.state: Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.
678
679        Returns:
680            The updated knowledge source.
681        """
682        return self._http.request(
683            f"/api/v1/knowledge_sources/{source}",
684            method="PATCH",
685            body=input,
686            response_type=KnowledgeSource,
687        )
688
689    def ingest(self, source: str, input: KnowledgeSourceIngestInput) -> ContextIngestion:
690        """
691        Trigger ingestion on a knowledge source
692        Starts an ingestion run on the specified knowledge source and returns the ingestion
693        object. Exactly one of two modes must be chosen per request:
694        **Push mode** (`file` or `content`) available for `knowledge/documents` sources only.
695        Supply the document bytes either as a reference to an already-uploaded file (`file`) or
696        as an inline blob (`content`). The runner stores the bytes and indexes the resulting
697        document. `title` and `metadata` are persisted on the document in push mode.
698        **Pull mode** (`pull: true`) re-triggers ingestion using the source's own configured
699        data. Use this to re-scrape a `scrape/site`, re-fetch a `web/link`, or re-process a
700        `file/document`. Not valid for `knowledge/documents` (which has no upstream push new
701        bytes instead) or for source kinds populated by server-driven flows. `title` and
702        `metadata` are ignored in pull mode.
703        If an ingestion is already active for the source, the existing ingestion is returned
704        rather than creating a duplicate.
705
706        Args:
707            source: Knowledge source ID (`ksrc_...`) to ingest.
708            input: Request body.
709            input.content: Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`.
710            input.dedupe: When `true`, reuse the source's existing document if the pushed content is byte-identical to it, instead of creating a duplicate. The reused document keeps its chunks and embeddings, and `title`/`metadata` from this request are still applied to it. Content that differs in any way always creates a new document. Defaults to `false`, which creates a new document on every push. Push mode only not valid with `pull: true`. Check `metadata.document_reused` on the returned ingestion to see whether a document was actually reused.
711            input.file: ID of an already-uploaded file (`fil_...`). The runner reads filename and content type from the stored file. Upload the file via `POST /v1/files` first. Mutually exclusive with `content` and `pull`.
712            input.metadata: Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`.
713            input.pull: When `true`, re-triggers ingestion using the source's own configured data. Re-scrapes a `scrape/site`, re-fetches a `web/link`, or re-processes a `file/document`. Mutually exclusive with `file` and `content`. Not valid for `knowledge/documents` sources.
714            input.title: Display title for the ingested document. Applied in push mode only; ignored when `pull: true`.
715
716        Returns:
717            The created ingestion, or an existing active ingestion if one is already running.
718        """
719        return self._http.request(
720            f"/api/v1/knowledge_sources/{source}/ingest",
721            method="POST",
722            body=input,
723            response_type=ContextIngestion,
724        )
725
726    def search(
727        self, source: str, input: KnowledgeSourceSearchInput
728    ) -> KnowledgeSourceSearchResponse:
729        """
730        Search within a knowledge source
731        Executes a search query against the indexed documents in a single knowledge source and
732        returns matching results ranked by relevance.
733        Three search modes are supported: `"hybrid"` (default) combines vector similarity and
734        full-text scoring, `"vector"` uses embedding-based semantic search only, and
735        `"fulltext"` uses keyword-based search only. Use `"hybrid"` for most use cases;
736        prefer `"vector"` when semantic meaning matters more than exact terms.
737        Optionally restrict results to documents ingested within the last N days using
738        `recency_days`. Results are ordered by relevance score descending.
739
740        Args:
741            source: Knowledge source ID (`ksrc_...`) to search within.
742            input: Request body.
743            input.max_results: Maximum number of results to return. The platform applies its own upper bound; omit to use the default.
744            input.min_similarity: Cosine-similarity floor for the vector leg, 0.0-1.0. Candidates below it are discarded before ranking, so a high value trades recall for precision. Pass `0.0` to disable the floor when a missed match costs more than a weak one note that with no floor every query returns results, so an empty response can no longer be read as "no match". Omit to use the default.
745            input.mode: Search algorithm to use. One of `"hybrid"` (default, combines vector and full-text), `"vector"` (semantic similarity only), or `"fulltext"` (keyword matching only).
746            input.query: Natural language or keyword query string to search for.
747            input.recency_days: When set, limits results to documents ingested within the last N days. Omit to search across all documents regardless of age.
748
749        Returns:
750            Successful response
751        """
752        return self._http.request(
753            f"/api/v1/knowledge_sources/{source}/search",
754            method="POST",
755            body=input,
756            response_type=KnowledgeSourceSearchResponse,
757        )
class KnowledgeSourceCreateInput(typing.TypedDict):
18class KnowledgeSourceCreateInput(TypedDict, total=False):
19    "Create a knowledge source"
20
21    agent: str | None
22    "Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`."
23    metadata: dict[str, Any] | None
24    "Arbitrary key-value metadata to attach to the source. Returned as-is on reads."
25    org: str | None
26    "Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`)."
27    parent_source: str | None
28    "Parent knowledge source ID (`ksrc_...`). Use to create a child source."
29    payload: dict[str, Any] | None
30    "Type-specific configuration for the source. Shape depends on `type`."
31    state: str | None
32    'Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.'
33    team: str | None
34    "Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`."
35    thread: str | None
36    "Thread ID (`thr_...`) to associate this source with, if applicable."
37    type: Required[str]
38    "Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`."
39    user: str | None
40    "User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`."

Create a knowledge source

agent: str | None

Agent ID (agt_...) that owns this source. Mutually exclusive with team and user.

metadata: dict[str, typing.Any] | None

Arbitrary key-value metadata to attach to the source. Returned as-is on reads.

org: str | None

Organization ID (org_...). Required for system-owned sources that have no individual owner (team, user, or agent).

parent_source: str | None

Parent knowledge source ID (ksrc_...). Use to create a child source.

payload: dict[str, typing.Any] | None

Type-specific configuration for the source. Shape depends on type.

state: str | None

Initial state of the source. One of "active" (default) or "paused". Paused sources do not trigger ingestion automatically.

team: str | None

Team ID (team_...) that owns this source. Mutually exclusive with user and agent.

thread: str | None

Thread ID (thr_...) to associate this source with, if applicable.

type: Required[str]

Knowledge source type. Must be one of the values returned by GET /api/v1/knowledge_sources/kinds.

user: str | None

User ID (usr_...) that owns this source. Mutually exclusive with team and agent.

class KnowledgeSourceUpdateInput(typing.TypedDict):
43class KnowledgeSourceUpdateInput(TypedDict, total=False):
44    "Update a knowledge source"
45
46    metadata: dict[str, Any] | None
47    "Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided."
48    payload: dict[str, Any] | None
49    "Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided."
50    state: str | None
51    'Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.'

Update a knowledge source

metadata: dict[str, typing.Any] | None

Arbitrary key-value metadata to attach to the source. Replaces the entire existing metadata map when provided.

payload: dict[str, typing.Any] | None

Type-specific configuration to replace on the source. Shape depends on the source type. Replaces the entire existing payload when provided.

state: str | None

Desired state of the source. One of "active" or "paused". Paused sources do not trigger ingestion automatically.

class KnowledgeSourceIngestInputContent(typing.TypedDict):
54class KnowledgeSourceIngestInputContent(TypedDict, total=False):
55    content_type: str | None
56    'MIME type of the content, e.g. `"application/pdf"` or `"text/plain"`.'
57    data: Required[str]
58    'The raw document bytes. When `data_encoding` is `"base64"`, provide the base64-encoded representation of the binary content.'
59    data_encoding: str | None
60    'Encoding format of `data`. One of `"raw"` (default, plain text) or `"base64"` (binary content such as images or PDFs, decoded server-side before storage).'
61    filename: str | None
62    'Original filename for the document, e.g. `"report.pdf"`.'
content_type: str | None

MIME type of the content, e.g. "application/pdf" or "text/plain".

data: Required[str]

The raw document bytes. When data_encoding is "base64", provide the base64-encoded representation of the binary content.

data_encoding: str | None

Encoding format of data. One of "raw" (default, plain text) or "base64" (binary content such as images or PDFs, decoded server-side before storage).

filename: str | None

Original filename for the document, e.g. "report.pdf".

class KnowledgeSourceIngestInput(typing.TypedDict):
65class KnowledgeSourceIngestInput(TypedDict, total=False):
66    "Trigger ingestion on a knowledge source"
67
68    content: KnowledgeSourceIngestInputContent | None
69    "Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`."
70    dedupe: bool | None
71    "When `true`, reuse the source's existing document if the pushed content is byte-identical to it, instead of creating a duplicate. The reused document keeps its chunks and embeddings, and `title`/`metadata` from this request are still applied to it. Content that differs in any way always creates a new document. Defaults to `false`, which creates a new document on every push. Push mode only not valid with `pull: true`. Check `metadata.document_reused` on the returned ingestion to see whether a document was actually reused."
72    file: str | None
73    "ID of an already-uploaded file (`fil_...`). The runner reads filename and content type from the stored file. Upload the file via `POST /v1/files` first. Mutually exclusive with `content` and `pull`."
74    metadata: dict[str, Any] | None
75    "Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`."
76    pull: bool | None
77    "When `true`, re-triggers ingestion using the source's own configured data. Re-scrapes a `scrape/site`, re-fetches a `web/link`, or re-processes a `file/document`. Mutually exclusive with `file` and `content`. Not valid for `knowledge/documents` sources."
78    title: str | None
79    "Display title for the ingested document. Applied in push mode only; ignored when `pull: true`."

Trigger ingestion on a knowledge source

Inline document bytes to push to the source. Mutually exclusive with file and pull.

dedupe: bool | None

When true, reuse the source's existing document if the pushed content is byte-identical to it, instead of creating a duplicate. The reused document keeps its chunks and embeddings, and title/metadata from this request are still applied to it. Content that differs in any way always creates a new document. Defaults to false, which creates a new document on every push. Push mode only not valid with pull: true. Check metadata.document_reused on the returned ingestion to see whether a document was actually reused.

file: str | None

ID of an already-uploaded file (fil_...). The runner reads filename and content type from the stored file. Upload the file via POST /v1/files first. Mutually exclusive with content and pull.

metadata: dict[str, typing.Any] | None

Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when pull: true.

pull: bool | None

When true, re-triggers ingestion using the source's own configured data. Re-scrapes a scrape/site, re-fetches a web/link, or re-processes a file/document. Mutually exclusive with file and content. Not valid for knowledge/documents sources.

title: str | None

Display title for the ingested document. Applied in push mode only; ignored when pull: true.

class KnowledgeSourceSearchInput(typing.TypedDict):
82class KnowledgeSourceSearchInput(TypedDict, total=False):
83    "Search within a knowledge source"
84
85    max_results: int | None
86    "Maximum number of results to return. The platform applies its own upper bound; omit to use the default."
87    min_similarity: float | None
88    'Cosine-similarity floor for the vector leg, 0.0-1.0. Candidates below it are discarded before ranking, so a high value trades recall for precision. Pass `0.0` to disable the floor when a missed match costs more than a weak one note that with no floor every query returns results, so an empty response can no longer be read as "no match". Omit to use the default.'
89    mode: str | None
90    'Search algorithm to use. One of `"hybrid"` (default, combines vector and full-text), `"vector"` (semantic similarity only), or `"fulltext"` (keyword matching only).'
91    query: Required[str]
92    "Natural language or keyword query string to search for."
93    recency_days: int | None
94    "When set, limits results to documents ingested within the last N days. Omit to search across all documents regardless of age."

Search within a knowledge source

max_results: int | None

Maximum number of results to return. The platform applies its own upper bound; omit to use the default.

min_similarity: float | None

Cosine-similarity floor for the vector leg, 0.0-1.0. Candidates below it are discarded before ranking, so a high value trades recall for precision. Pass 0.0 to disable the floor when a missed match costs more than a weak one note that with no floor every query returns results, so an empty response can no longer be read as "no match". Omit to use the default.

mode: str | None

Search algorithm to use. One of "hybrid" (default, combines vector and full-text), "vector" (semantic similarity only), or "fulltext" (keyword matching only).

query: Required[str]

Natural language or keyword query string to search for.

recency_days: int | None

When set, limits results to documents ingested within the last N days. Omit to search across all documents regardless of age.

class KnowledgeSourceListResponseDataItem(pydantic.main.BaseModel):
 97class KnowledgeSourceListResponseDataItem(BaseModel):
 98    agent: str | None = Field(
 99        default=None,
100        description="ID of the agent that owns this source (`agt_...`). `null` if owned by a human user or team.",
101    )
102    context_installation: str | None = Field(
103        default=None,
104        description="ID of the context installation that provisioned this source (`cin_...`). `null` when the source was created directly rather than through an installation.",
105    )
106    created_at: datetime | None = Field(
107        default=None, description="When this knowledge source was created (ISO 8601)."
108    )
109    id: str = Field(..., description="Knowledge source ID (`cso_...`).")
110    metadata: dict[str, Any] | None = Field(
111        default=None,
112        description="Arbitrary key-value metadata attached to this source. Useful for storing caller-defined labels or references.",
113    )
114    org: str | None = Field(
115        default=None,
116        description="ID of the organization this source belongs to (`org_...`). `null` if not scoped to an org.",
117    )
118    parent_source: str | None = Field(
119        default=None,
120        description="ID of the parent knowledge source (`cso_...`) when this source was derived from another. `null` for top-level sources.",
121    )
122    payload: dict[str, Any] | None = Field(
123        default=None,
124        description="Type-specific configuration object. The keys depend on the source `type`; see the create endpoint for the expected shape per type.",
125    )
126    sandbox: str | None = Field(
127        default=None,
128        description="ID of the developer sandbox this source is scoped to (`sbx_...`). `null` outside sandbox contexts.",
129    )
130    state: str = Field(
131        ...,
132        description='Current lifecycle state of the source. One of `"active"` (ingestion running normally) or `"paused"` (ingestion suspended).',
133    )
134    team: str | None = Field(
135        default=None,
136        description="ID of the team that owns this source (`tea_...`). `null` if owned by a user, agent, or org.",
137    )
138    thread: str | None = Field(
139        default=None,
140        description="ID of the chat thread this source is associated with (`thr_...`). `null` when not thread-scoped.",
141    )
142    type: str = Field(
143        ...,
144        description='Source type identifier (e.g. `"gmail"`, `"github_activity"`). Determines the shape of `payload` and the ingestion behavior.',
145    )
146    updated_at: datetime | None = Field(
147        default=None, description="When this knowledge source was last modified (ISO 8601)."
148    )
149    user: str | None = Field(
150        default=None,
151        description="ID of the user that owns this source (`usr_...`). `null` if owned by a team, agent, or org.",
152    )

!!! abstract "Usage Documentation" Models

A base class for creating Pydantic models.

Attributes:
  • __class_vars__: The names of the class variables defined on the model.
  • __private_attributes__: Metadata about the private attributes of the model.
  • __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.
  • __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
  • __pydantic_core_schema__: The core schema of the model.
  • __pydantic_custom_init__: Whether the model has a custom __init__ function.
  • __pydantic_decorators__: Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
  • __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models. The origin and args items map to the [__origin__][genericalias.__origin__] and [__args__][genericalias.__args__] attributes of [generic aliases][types-genericalias], and the parameter item maps to the __parameter__ attribute of generic classes.
  • __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
  • __pydantic_post_init__: The name of the post-init method for the model, if defined.
  • __pydantic_root_model__: Whether the model is a [RootModel][pydantic.root_model.RootModel].
  • __pydantic_serializer__: The pydantic-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used to validate instances of the model.
  • __pydantic_fields__: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
  • __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
  • __pydantic_extra__: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
  • __pydantic_fields_set__: The names of fields explicitly set during instantiation.
  • __pydantic_private__: Values of private attributes set on the model instance.
agent: str | None = None

ID of the agent that owns this source (agt_...). null if owned by a human user or team.

context_installation: str | None = None

ID of the context installation that provisioned this source (cin_...). null when the source was created directly rather than through an installation.

created_at: datetime.datetime | None = None

When this knowledge source was created (ISO 8601).

id: str = PydanticUndefined

Knowledge source ID (cso_...).

metadata: dict[str, typing.Any] | None = None

Arbitrary key-value metadata attached to this source. Useful for storing caller-defined labels or references.

org: str | None = None

ID of the organization this source belongs to (org_...). null if not scoped to an org.

parent_source: str | None = None

ID of the parent knowledge source (cso_...) when this source was derived from another. null for top-level sources.

payload: dict[str, typing.Any] | None = None

Type-specific configuration object. The keys depend on the source type; see the create endpoint for the expected shape per type.

sandbox: str | None = None

ID of the developer sandbox this source is scoped to (sbx_...). null outside sandbox contexts.

state: str = PydanticUndefined

Current lifecycle state of the source. One of "active" (ingestion running normally) or "paused" (ingestion suspended).

team: str | None = None

ID of the team that owns this source (tea_...). null if owned by a user, agent, or org.

thread: str | None = None

ID of the chat thread this source is associated with (thr_...). null when not thread-scoped.

type: str = PydanticUndefined

Source type identifier (e.g. "gmail", "github_activity"). Determines the shape of payload and the ingestion behavior.

updated_at: datetime.datetime | None = None

When this knowledge source was last modified (ISO 8601).

user: str | None = None

ID of the user that owns this source (usr_...). null if owned by a team, agent, or org.

class KnowledgeSourceListResponse(pydantic.main.BaseModel):
155class KnowledgeSourceListResponse(BaseModel):
156    """
157    Successful response
158    """
159
160    data: list[KnowledgeSourceListResponseDataItem] = Field(
161        ..., description="Array of knowledge source objects for the current page."
162    )
163    has_next: bool = Field(
164        ..., description="`true` if a subsequent page exists, `false` if this is the last page."
165    )
166    has_prev: bool = Field(
167        ..., description="`true` if a previous page exists, `false` if this is the first page."
168    )
169    page: int = Field(..., description="Current page number.")
170    page_size: int = Field(..., description="Number of results returned per page.")
171    total_entries: int = Field(
172        ..., description="Total number of knowledge sources matching the query across all pages."
173    )
174    total_pages: int = Field(..., description="Total number of pages available.")

Successful response

data: list[KnowledgeSourceListResponseDataItem] = PydanticUndefined

Array of knowledge source objects for the current page.

has_next: bool = PydanticUndefined

true if a subsequent page exists, false if this is the last page.

has_prev: bool = PydanticUndefined

true if a previous page exists, false if this is the first page.

page: int = PydanticUndefined

Current page number.

page_size: int = PydanticUndefined

Number of results returned per page.

total_entries: int = PydanticUndefined

Total number of knowledge sources matching the query across all pages.

total_pages: int = PydanticUndefined

Total number of pages available.

class KnowledgeSourceSearchResponseDataItem(pydantic.main.BaseModel):
177class KnowledgeSourceSearchResponseDataItem(BaseModel):
178    content: str | None = Field(
179        default=None, description="Normalized plain-text content of the matched chunk."
180    )
181    content_type: str | None = Field(
182        default=None, description='MIME type of the content, e.g. `"text/plain"` or `"text/html"`.'
183    )
184    created_at: datetime | None = Field(
185        default=None, description="When this item was indexed into the knowledge base (ISO 8601)."
186    )
187    id: str = Field(..., description="Context item ID (`cim_...`).")
188    kind: Literal["chunk"] = Field(
189        default="chunk",
190        description='Result variant discriminator. Always `"chunk"` for this object type.',
191    )
192    metadata: dict[str, Any] | None = Field(
193        default=None,
194        description="Arbitrary key-value metadata attached to this item by the source connector.",
195    )
196    raw_content: dict[str, Any] | None = Field(
197        default=None,
198        description="Raw content payload as stored by the source connector, before normalization.",
199    )
200    structured_data: str | None = Field(
201        default=None,
202        description="Public ID (`sda_...`) of the structured-data record attached to the source message. Present only for such items on source search.",
203    )
204    structured_data_summary: str | None = Field(
205        default=None,
206        description="Search summary of that record, computed when the request is served. When present, `content` is the indexed text and may be stale.",
207    )
208    type: str | None = Field(
209        default=None,
210        description='Type identifier of the parent knowledge source (e.g. `"gmail"`, `"github_activity"`). Returns `"unknown"` when the source association is not loaded.',
211    )

!!! abstract "Usage Documentation" Models

A base class for creating Pydantic models.

Attributes:
  • __class_vars__: The names of the class variables defined on the model.
  • __private_attributes__: Metadata about the private attributes of the model.
  • __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.
  • __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
  • __pydantic_core_schema__: The core schema of the model.
  • __pydantic_custom_init__: Whether the model has a custom __init__ function.
  • __pydantic_decorators__: Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
  • __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models. The origin and args items map to the [__origin__][genericalias.__origin__] and [__args__][genericalias.__args__] attributes of [generic aliases][types-genericalias], and the parameter item maps to the __parameter__ attribute of generic classes.
  • __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
  • __pydantic_post_init__: The name of the post-init method for the model, if defined.
  • __pydantic_root_model__: Whether the model is a [RootModel][pydantic.root_model.RootModel].
  • __pydantic_serializer__: The pydantic-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used to validate instances of the model.
  • __pydantic_fields__: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
  • __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
  • __pydantic_extra__: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
  • __pydantic_fields_set__: The names of fields explicitly set during instantiation.
  • __pydantic_private__: Values of private attributes set on the model instance.
content: str | None = None

Normalized plain-text content of the matched chunk.

content_type: str | None = None

MIME type of the content, e.g. "text/plain" or "text/html".

created_at: datetime.datetime | None = None

When this item was indexed into the knowledge base (ISO 8601).

id: str = PydanticUndefined

Context item ID (cim_...).

kind: Literal['chunk'] = 'chunk'

Result variant discriminator. Always "chunk" for this object type.

metadata: dict[str, typing.Any] | None = None

Arbitrary key-value metadata attached to this item by the source connector.

raw_content: dict[str, typing.Any] | None = None

Raw content payload as stored by the source connector, before normalization.

structured_data: str | None = None

Public ID (sda_...) of the structured-data record attached to the source message. Present only for such items on source search.

structured_data_summary: str | None = None

Search summary of that record, computed when the request is served. When present, content is the indexed text and may be stale.

type: str | None = None

Type identifier of the parent knowledge source (e.g. "gmail", "github_activity"). Returns "unknown" when the source association is not loaded.

class KnowledgeSourceSearchResponse(pydantic.main.BaseModel):
214class KnowledgeSourceSearchResponse(BaseModel):
215    """
216    Successful response
217    """
218
219    data: list[KnowledgeSourceSearchResponseDataItem] = Field(
220        ...,
221        description="Array of matching knowledge items ordered by relevance score descending. An item indexed from a message that has structured data attached also carries `structured_data` and `structured_data_summary`, the record's search summary computed at read time. `content` is still the indexed text and may be stale.",
222    )
223    degraded: bool | None = Field(
224        default=None,
225        description="True when a `hybrid` search ran fulltext only because the vector leg was unavailable. Absent when the query was empty.",
226    )
227    effective_mode: Literal["hybrid", "vector", "fulltext"] | None = Field(
228        default=None,
229        description="Retrieval mode that actually ran. Differs from the requested `mode` when a `hybrid` search fell back to `fulltext`. Absent when the query was empty.",
230    )

Successful response

data: list[KnowledgeSourceSearchResponseDataItem] = PydanticUndefined

Array of matching knowledge items ordered by relevance score descending. An item indexed from a message that has structured data attached also carries structured_data and structured_data_summary, the record's search summary computed at read time. content is still the indexed text and may be stale.

degraded: bool | None = None

True when a hybrid search ran fulltext only because the vector leg was unavailable. Absent when the query was empty.

effective_mode: Optional[Literal['hybrid', 'vector', 'fulltext']] = None

Retrieval mode that actually ran. Differs from the requested mode when a hybrid search fell back to fulltext. Absent when the query was empty.

class AsyncKnowledgeSourceKindResource:
233class AsyncKnowledgeSourceKindResource:
234    def __init__(self, http: HttpClient):
235        self._http = http
236
237    async def list(self) -> KnowledgeSourceKindListResponse:
238        """
239        List creatable knowledge source kinds
240        Returns the fixed set of knowledge source types that can be created directly via
241        `POST /api/v1/knowledge_sources`. Use this endpoint to discover valid values for the
242        `type` param before calling the create endpoint.
243        Source kinds populated by server-driven flows such as `webhook/inbound`,
244        `connectors/*/emails`, and `thread/messages` are intentionally excluded from this
245        list, as they cannot be created through the API.
246
247        Returns:
248            List of knowledge source kinds available for creation via the API.
249        """
250        return await self._http.request(
251            "/api/v1/knowledge_sources/kinds",
252            response_type=KnowledgeSourceKindListResponse,
253        )
AsyncKnowledgeSourceKindResource(http: archastro.platform.runtime.http_client.HttpClient)
234    def __init__(self, http: HttpClient):
235        self._http = http
237    async def list(self) -> KnowledgeSourceKindListResponse:
238        """
239        List creatable knowledge source kinds
240        Returns the fixed set of knowledge source types that can be created directly via
241        `POST /api/v1/knowledge_sources`. Use this endpoint to discover valid values for the
242        `type` param before calling the create endpoint.
243        Source kinds populated by server-driven flows such as `webhook/inbound`,
244        `connectors/*/emails`, and `thread/messages` are intentionally excluded from this
245        list, as they cannot be created through the API.
246
247        Returns:
248            List of knowledge source kinds available for creation via the API.
249        """
250        return await self._http.request(
251            "/api/v1/knowledge_sources/kinds",
252            response_type=KnowledgeSourceKindListResponse,
253        )

List creatable knowledge source kinds Returns the fixed set of knowledge source types that can be created directly via POST /api/v1/knowledge_sources. Use this endpoint to discover valid values for the type param before calling the create endpoint. Source kinds populated by server-driven flows such as webhook/inbound, connectors/*/emails, and thread/messages are intentionally excluded from this list, as they cannot be created through the API.

Returns:

List of knowledge source kinds available for creation via the API.

class AsyncKnowledgeSourceResource:
256class AsyncKnowledgeSourceResource:
257    def __init__(self, http: HttpClient):
258        self._http = http
259        self.kinds = AsyncKnowledgeSourceKindResource(http)
260
261    async def list(
262        self,
263        *,
264        page: int | None = None,
265        page_size: int | None = None,
266        search: str | None = None,
267        type: str | None = None,
268        team: builtins.list[str] | None = None,
269        thread: builtins.list[str] | None = None,
270        installation: str | None = None,
271        agent: str | None = None,
272        org: str | None = None,
273        owner_scope: Literal["any", "individual", "system"] | None = None,
274    ) -> KnowledgeSourceListResponse:
275        """
276        List knowledge sources
277        Returns a paginated list of knowledge sources visible to the authenticated caller.
278        Results are ordered by creation time descending.
279        Use the `type`, `installation`, `agent`, `org`, and `owner_scope` filters to narrow the
280        result set. Combine `owner_scope: "system"` with `org` to list org-level sources that
281        have no individual owner. Combine `owner_scope: "individual"` with `agent` to list
282        sources owned by a specific agent.
283        Pagination is page-number based. The default page size is 25.
284
285        Args:
286            page: Page number to retrieve. Defaults to 1.
287            page_size: Number of knowledge sources to return per page. Defaults to 25.
288            search: Filter sources whose type contains this string. Case-insensitive substring match.
289            type: Exact knowledge source type to filter by, e.g. `"knowledge/documents"`.
290            team: Exact team IDs whose sources to include.
291            thread: Exact backing thread IDs whose sources to include.
292            installation: Installation ID (`ins_...`). Returns only sources associated with this installation.
293            agent: Agent ID (`agt_...`). Returns only sources owned by or associated with this agent.
294            org: Organization ID (`org_...`). Returns only sources belonging to this organization. Combine with `owner_scope: "system"` to retrieve org-level system sources.
295            owner_scope: Filter by ownership scope. One of `"any"` (default returns all visible sources), `"individual"` (only sources owned by a user, team, or agent), or `"system"` (only sources with no individual owner, typically org-level).
296
297        Returns:
298            Successful response
299        """
300        query: dict[str, object] = {}
301        if page is not None:
302            query["page"] = page
303        if page_size is not None:
304            query["page_size"] = page_size
305        if search is not None:
306            query["search"] = search
307        if type is not None:
308            query["type"] = type
309        if team is not None:
310            query["team"] = team
311        if thread is not None:
312            query["thread"] = thread
313        if installation is not None:
314            query["installation"] = installation
315        if agent is not None:
316            query["agent"] = agent
317        if org is not None:
318            query["org"] = org
319        if owner_scope is not None:
320            query["owner_scope"] = owner_scope
321        return await self._http.request(
322            "/api/v1/knowledge_sources",
323            query=query,
324            response_type=KnowledgeSourceListResponse,
325        )
326
327    async def create(self, input: KnowledgeSourceCreateInput) -> KnowledgeSource:
328        """
329        Create a knowledge source
330        Creates a new knowledge source of the requested type and returns the created object.
331        Only types listed by `GET /api/v1/knowledge_sources/kinds` may be created through this
332        endpoint. Other source types such as `webhook/inbound`, `connectors/*/emails`, and
333        `thread/messages` are provisioned automatically by server-driven flows (webhook
334        auto-provisioning, installation activation, connector lifecycle events) and cannot be
335        created directly via the API.
336        Exactly one of `team`, `user`, `agent`, or `org` must identify the owner of the new
337        source. Omit `org` when an individual owner (`team`, `user`, or `agent`) is supplied;
338        include `org` alone for org-level system-owned sources.
339
340        Args:
341            input: Request body.
342            input.agent: Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`.
343            input.metadata: Arbitrary key-value metadata to attach to the source. Returned as-is on reads.
344            input.org: Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`).
345            input.parent_source: Parent knowledge source ID (`ksrc_...`). Use to create a child source.
346            input.payload: Type-specific configuration for the source. Shape depends on `type`.
347            input.state: Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.
348            input.team: Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`.
349            input.thread: Thread ID (`thr_...`) to associate this source with, if applicable.
350            input.type: Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`.
351            input.user: User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`.
352
353        Returns:
354            The newly created knowledge source.
355        """
356        return await self._http.request(
357            "/api/v1/knowledge_sources",
358            method="POST",
359            body=input,
360            response_type=KnowledgeSource,
361        )
362
363    async def delete(self, source: str) -> None:
364        """
365        Delete a knowledge source
366        Permanently deletes the knowledge source identified by `source`. This action is
367        irreversible all documents, embeddings, and ingestion history associated with the
368        source are removed.
369        The authenticated caller must own the source or have sufficient permissions within its
370        parent organization. Returns `204 No Content` on success.
371
372        Args:
373            source: Knowledge source ID (`ksrc_...`) to delete.
374
375        Returns:
376            Empty response. The source has been permanently deleted.
377        """
378        await self._http.request(f"/api/v1/knowledge_sources/{source}", method="DELETE")
379
380    async def get(self, source: str) -> KnowledgeSource:
381        """
382        Retrieve a knowledge source
383        Returns the knowledge source identified by `source`. The authenticated caller must have
384        access to the source's parent organization or be the individual owner of the source.
385        Use the list endpoint to retrieve many sources at once or to discover sources by type
386        or owner.
387
388        Args:
389            source: Knowledge source ID (`ksrc_...`) to retrieve.
390
391        Returns:
392            The requested knowledge source.
393        """
394        return await self._http.request(
395            f"/api/v1/knowledge_sources/{source}",
396            response_type=KnowledgeSource,
397        )
398
399    async def update(self, source: str, input: KnowledgeSourceUpdateInput) -> KnowledgeSource:
400        """
401        Update a knowledge source
402        Updates the mutable fields of an existing knowledge source and returns the updated
403        object. Only fields provided in the request body are changed; omitted fields retain
404        their current values.
405        You can update the type-specific `payload`, the `metadata` map, and the `state`. To
406        pause a source and prevent automatic ingestion, set `state` to `"paused"`. To resume,
407        set it back to `"active"`.
408
409        Args:
410            source: Knowledge source ID (`ksrc_...`) to update.
411            input: Request body.
412            input.metadata: Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided.
413            input.payload: Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided.
414            input.state: Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.
415
416        Returns:
417            The updated knowledge source.
418        """
419        return await self._http.request(
420            f"/api/v1/knowledge_sources/{source}",
421            method="PATCH",
422            body=input,
423            response_type=KnowledgeSource,
424        )
425
426    async def ingest(self, source: str, input: KnowledgeSourceIngestInput) -> ContextIngestion:
427        """
428        Trigger ingestion on a knowledge source
429        Starts an ingestion run on the specified knowledge source and returns the ingestion
430        object. Exactly one of two modes must be chosen per request:
431        **Push mode** (`file` or `content`) available for `knowledge/documents` sources only.
432        Supply the document bytes either as a reference to an already-uploaded file (`file`) or
433        as an inline blob (`content`). The runner stores the bytes and indexes the resulting
434        document. `title` and `metadata` are persisted on the document in push mode.
435        **Pull mode** (`pull: true`) re-triggers ingestion using the source's own configured
436        data. Use this to re-scrape a `scrape/site`, re-fetch a `web/link`, or re-process a
437        `file/document`. Not valid for `knowledge/documents` (which has no upstream push new
438        bytes instead) or for source kinds populated by server-driven flows. `title` and
439        `metadata` are ignored in pull mode.
440        If an ingestion is already active for the source, the existing ingestion is returned
441        rather than creating a duplicate.
442
443        Args:
444            source: Knowledge source ID (`ksrc_...`) to ingest.
445            input: Request body.
446            input.content: Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`.
447            input.dedupe: When `true`, reuse the source's existing document if the pushed content is byte-identical to it, instead of creating a duplicate. The reused document keeps its chunks and embeddings, and `title`/`metadata` from this request are still applied to it. Content that differs in any way always creates a new document. Defaults to `false`, which creates a new document on every push. Push mode only not valid with `pull: true`. Check `metadata.document_reused` on the returned ingestion to see whether a document was actually reused.
448            input.file: ID of an already-uploaded file (`fil_...`). The runner reads filename and content type from the stored file. Upload the file via `POST /v1/files` first. Mutually exclusive with `content` and `pull`.
449            input.metadata: Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`.
450            input.pull: When `true`, re-triggers ingestion using the source's own configured data. Re-scrapes a `scrape/site`, re-fetches a `web/link`, or re-processes a `file/document`. Mutually exclusive with `file` and `content`. Not valid for `knowledge/documents` sources.
451            input.title: Display title for the ingested document. Applied in push mode only; ignored when `pull: true`.
452
453        Returns:
454            The created ingestion, or an existing active ingestion if one is already running.
455        """
456        return await self._http.request(
457            f"/api/v1/knowledge_sources/{source}/ingest",
458            method="POST",
459            body=input,
460            response_type=ContextIngestion,
461        )
462
463    async def search(
464        self, source: str, input: KnowledgeSourceSearchInput
465    ) -> KnowledgeSourceSearchResponse:
466        """
467        Search within a knowledge source
468        Executes a search query against the indexed documents in a single knowledge source and
469        returns matching results ranked by relevance.
470        Three search modes are supported: `"hybrid"` (default) combines vector similarity and
471        full-text scoring, `"vector"` uses embedding-based semantic search only, and
472        `"fulltext"` uses keyword-based search only. Use `"hybrid"` for most use cases;
473        prefer `"vector"` when semantic meaning matters more than exact terms.
474        Optionally restrict results to documents ingested within the last N days using
475        `recency_days`. Results are ordered by relevance score descending.
476
477        Args:
478            source: Knowledge source ID (`ksrc_...`) to search within.
479            input: Request body.
480            input.max_results: Maximum number of results to return. The platform applies its own upper bound; omit to use the default.
481            input.min_similarity: Cosine-similarity floor for the vector leg, 0.0-1.0. Candidates below it are discarded before ranking, so a high value trades recall for precision. Pass `0.0` to disable the floor when a missed match costs more than a weak one note that with no floor every query returns results, so an empty response can no longer be read as "no match". Omit to use the default.
482            input.mode: Search algorithm to use. One of `"hybrid"` (default, combines vector and full-text), `"vector"` (semantic similarity only), or `"fulltext"` (keyword matching only).
483            input.query: Natural language or keyword query string to search for.
484            input.recency_days: When set, limits results to documents ingested within the last N days. Omit to search across all documents regardless of age.
485
486        Returns:
487            Successful response
488        """
489        return await self._http.request(
490            f"/api/v1/knowledge_sources/{source}/search",
491            method="POST",
492            body=input,
493            response_type=KnowledgeSourceSearchResponse,
494        )
AsyncKnowledgeSourceResource(http: archastro.platform.runtime.http_client.HttpClient)
257    def __init__(self, http: HttpClient):
258        self._http = http
259        self.kinds = AsyncKnowledgeSourceKindResource(http)
kinds
async def list( self, *, page: int | None = None, page_size: int | None = None, search: str | None = None, type: str | None = None, team: list[str] | None = None, thread: list[str] | None = None, installation: str | None = None, agent: str | None = None, org: str | None = None, owner_scope: Optional[Literal['any', 'individual', 'system']] = None) -> KnowledgeSourceListResponse:
261    async def list(
262        self,
263        *,
264        page: int | None = None,
265        page_size: int | None = None,
266        search: str | None = None,
267        type: str | None = None,
268        team: builtins.list[str] | None = None,
269        thread: builtins.list[str] | None = None,
270        installation: str | None = None,
271        agent: str | None = None,
272        org: str | None = None,
273        owner_scope: Literal["any", "individual", "system"] | None = None,
274    ) -> KnowledgeSourceListResponse:
275        """
276        List knowledge sources
277        Returns a paginated list of knowledge sources visible to the authenticated caller.
278        Results are ordered by creation time descending.
279        Use the `type`, `installation`, `agent`, `org`, and `owner_scope` filters to narrow the
280        result set. Combine `owner_scope: "system"` with `org` to list org-level sources that
281        have no individual owner. Combine `owner_scope: "individual"` with `agent` to list
282        sources owned by a specific agent.
283        Pagination is page-number based. The default page size is 25.
284
285        Args:
286            page: Page number to retrieve. Defaults to 1.
287            page_size: Number of knowledge sources to return per page. Defaults to 25.
288            search: Filter sources whose type contains this string. Case-insensitive substring match.
289            type: Exact knowledge source type to filter by, e.g. `"knowledge/documents"`.
290            team: Exact team IDs whose sources to include.
291            thread: Exact backing thread IDs whose sources to include.
292            installation: Installation ID (`ins_...`). Returns only sources associated with this installation.
293            agent: Agent ID (`agt_...`). Returns only sources owned by or associated with this agent.
294            org: Organization ID (`org_...`). Returns only sources belonging to this organization. Combine with `owner_scope: "system"` to retrieve org-level system sources.
295            owner_scope: Filter by ownership scope. One of `"any"` (default returns all visible sources), `"individual"` (only sources owned by a user, team, or agent), or `"system"` (only sources with no individual owner, typically org-level).
296
297        Returns:
298            Successful response
299        """
300        query: dict[str, object] = {}
301        if page is not None:
302            query["page"] = page
303        if page_size is not None:
304            query["page_size"] = page_size
305        if search is not None:
306            query["search"] = search
307        if type is not None:
308            query["type"] = type
309        if team is not None:
310            query["team"] = team
311        if thread is not None:
312            query["thread"] = thread
313        if installation is not None:
314            query["installation"] = installation
315        if agent is not None:
316            query["agent"] = agent
317        if org is not None:
318            query["org"] = org
319        if owner_scope is not None:
320            query["owner_scope"] = owner_scope
321        return await self._http.request(
322            "/api/v1/knowledge_sources",
323            query=query,
324            response_type=KnowledgeSourceListResponse,
325        )

List knowledge sources Returns a paginated list of knowledge sources visible to the authenticated caller. Results are ordered by creation time descending. Use the type, installation, agent, org, and owner_scope filters to narrow the result set. Combine owner_scope: "system" with org to list org-level sources that have no individual owner. Combine owner_scope: "individual" with agent to list sources owned by a specific agent. Pagination is page-number based. The default page size is 25.

Arguments:
  • page: Page number to retrieve. Defaults to 1.
  • page_size: Number of knowledge sources to return per page. Defaults to 25.
  • search: Filter sources whose type contains this string. Case-insensitive substring match.
  • type: Exact knowledge source type to filter by, e.g. "knowledge/documents".
  • team: Exact team IDs whose sources to include.
  • thread: Exact backing thread IDs whose sources to include.
  • installation: Installation ID (ins_...). Returns only sources associated with this installation.
  • agent: Agent ID (agt_...). Returns only sources owned by or associated with this agent.
  • org: Organization ID (org_...). Returns only sources belonging to this organization. Combine with owner_scope: "system" to retrieve org-level system sources.
  • owner_scope: Filter by ownership scope. One of "any" (default returns all visible sources), "individual" (only sources owned by a user, team, or agent), or "system" (only sources with no individual owner, typically org-level).
Returns:

Successful response

async def create( self, input: KnowledgeSourceCreateInput) -> archastro.platform.types.common.KnowledgeSource:
327    async def create(self, input: KnowledgeSourceCreateInput) -> KnowledgeSource:
328        """
329        Create a knowledge source
330        Creates a new knowledge source of the requested type and returns the created object.
331        Only types listed by `GET /api/v1/knowledge_sources/kinds` may be created through this
332        endpoint. Other source types such as `webhook/inbound`, `connectors/*/emails`, and
333        `thread/messages` are provisioned automatically by server-driven flows (webhook
334        auto-provisioning, installation activation, connector lifecycle events) and cannot be
335        created directly via the API.
336        Exactly one of `team`, `user`, `agent`, or `org` must identify the owner of the new
337        source. Omit `org` when an individual owner (`team`, `user`, or `agent`) is supplied;
338        include `org` alone for org-level system-owned sources.
339
340        Args:
341            input: Request body.
342            input.agent: Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`.
343            input.metadata: Arbitrary key-value metadata to attach to the source. Returned as-is on reads.
344            input.org: Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`).
345            input.parent_source: Parent knowledge source ID (`ksrc_...`). Use to create a child source.
346            input.payload: Type-specific configuration for the source. Shape depends on `type`.
347            input.state: Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.
348            input.team: Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`.
349            input.thread: Thread ID (`thr_...`) to associate this source with, if applicable.
350            input.type: Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`.
351            input.user: User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`.
352
353        Returns:
354            The newly created knowledge source.
355        """
356        return await self._http.request(
357            "/api/v1/knowledge_sources",
358            method="POST",
359            body=input,
360            response_type=KnowledgeSource,
361        )

Create a knowledge source Creates a new knowledge source of the requested type and returns the created object. Only types listed by GET /api/v1/knowledge_sources/kinds may be created through this endpoint. Other source types such as webhook/inbound, connectors/*/emails, and thread/messages are provisioned automatically by server-driven flows (webhook auto-provisioning, installation activation, connector lifecycle events) and cannot be created directly via the API. Exactly one of team, user, agent, or org must identify the owner of the new source. Omit org when an individual owner (team, user, or agent) is supplied; include org alone for org-level system-owned sources.

Arguments:
  • input: Request body.
  • input.agent: Agent ID (agt_...) that owns this source. Mutually exclusive with team and user.
  • input.metadata: Arbitrary key-value metadata to attach to the source. Returned as-is on reads.
  • input.org: Organization ID (org_...). Required for system-owned sources that have no individual owner (team, user, or agent).
  • input.parent_source: Parent knowledge source ID (ksrc_...). Use to create a child source.
  • input.payload: Type-specific configuration for the source. Shape depends on type.
  • input.state: Initial state of the source. One of "active" (default) or "paused". Paused sources do not trigger ingestion automatically.
  • input.team: Team ID (team_...) that owns this source. Mutually exclusive with user and agent.
  • input.thread: Thread ID (thr_...) to associate this source with, if applicable.
  • input.type: Knowledge source type. Must be one of the values returned by GET /api/v1/knowledge_sources/kinds.
  • input.user: User ID (usr_...) that owns this source. Mutually exclusive with team and agent.
Returns:

The newly created knowledge source.

async def delete(self, source: str) -> None:
363    async def delete(self, source: str) -> None:
364        """
365        Delete a knowledge source
366        Permanently deletes the knowledge source identified by `source`. This action is
367        irreversible all documents, embeddings, and ingestion history associated with the
368        source are removed.
369        The authenticated caller must own the source or have sufficient permissions within its
370        parent organization. Returns `204 No Content` on success.
371
372        Args:
373            source: Knowledge source ID (`ksrc_...`) to delete.
374
375        Returns:
376            Empty response. The source has been permanently deleted.
377        """
378        await self._http.request(f"/api/v1/knowledge_sources/{source}", method="DELETE")

Delete a knowledge source Permanently deletes the knowledge source identified by source. This action is irreversible all documents, embeddings, and ingestion history associated with the source are removed. The authenticated caller must own the source or have sufficient permissions within its parent organization. Returns 204 No Content on success.

Arguments:
  • source: Knowledge source ID (ksrc_...) to delete.
Returns:

Empty response. The source has been permanently deleted.

async def get(self, source: str) -> archastro.platform.types.common.KnowledgeSource:
380    async def get(self, source: str) -> KnowledgeSource:
381        """
382        Retrieve a knowledge source
383        Returns the knowledge source identified by `source`. The authenticated caller must have
384        access to the source's parent organization or be the individual owner of the source.
385        Use the list endpoint to retrieve many sources at once or to discover sources by type
386        or owner.
387
388        Args:
389            source: Knowledge source ID (`ksrc_...`) to retrieve.
390
391        Returns:
392            The requested knowledge source.
393        """
394        return await self._http.request(
395            f"/api/v1/knowledge_sources/{source}",
396            response_type=KnowledgeSource,
397        )

Retrieve a knowledge source Returns the knowledge source identified by source. The authenticated caller must have access to the source's parent organization or be the individual owner of the source. Use the list endpoint to retrieve many sources at once or to discover sources by type or owner.

Arguments:
  • source: Knowledge source ID (ksrc_...) to retrieve.
Returns:

The requested knowledge source.

async def update( self, source: str, input: KnowledgeSourceUpdateInput) -> archastro.platform.types.common.KnowledgeSource:
399    async def update(self, source: str, input: KnowledgeSourceUpdateInput) -> KnowledgeSource:
400        """
401        Update a knowledge source
402        Updates the mutable fields of an existing knowledge source and returns the updated
403        object. Only fields provided in the request body are changed; omitted fields retain
404        their current values.
405        You can update the type-specific `payload`, the `metadata` map, and the `state`. To
406        pause a source and prevent automatic ingestion, set `state` to `"paused"`. To resume,
407        set it back to `"active"`.
408
409        Args:
410            source: Knowledge source ID (`ksrc_...`) to update.
411            input: Request body.
412            input.metadata: Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided.
413            input.payload: Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided.
414            input.state: Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.
415
416        Returns:
417            The updated knowledge source.
418        """
419        return await self._http.request(
420            f"/api/v1/knowledge_sources/{source}",
421            method="PATCH",
422            body=input,
423            response_type=KnowledgeSource,
424        )

Update a knowledge source Updates the mutable fields of an existing knowledge source and returns the updated object. Only fields provided in the request body are changed; omitted fields retain their current values. You can update the type-specific payload, the metadata map, and the state. To pause a source and prevent automatic ingestion, set state to "paused". To resume, set it back to "active".

Arguments:
  • source: Knowledge source ID (ksrc_...) to update.
  • input: Request body.
  • input.metadata: Arbitrary key-value metadata to attach to the source. Replaces the entire existing metadata map when provided.
  • input.payload: Type-specific configuration to replace on the source. Shape depends on the source type. Replaces the entire existing payload when provided.
  • input.state: Desired state of the source. One of "active" or "paused". Paused sources do not trigger ingestion automatically.
Returns:

The updated knowledge source.

async def ingest( self, source: str, input: KnowledgeSourceIngestInput) -> archastro.platform.types.common.ContextIngestion:
426    async def ingest(self, source: str, input: KnowledgeSourceIngestInput) -> ContextIngestion:
427        """
428        Trigger ingestion on a knowledge source
429        Starts an ingestion run on the specified knowledge source and returns the ingestion
430        object. Exactly one of two modes must be chosen per request:
431        **Push mode** (`file` or `content`) available for `knowledge/documents` sources only.
432        Supply the document bytes either as a reference to an already-uploaded file (`file`) or
433        as an inline blob (`content`). The runner stores the bytes and indexes the resulting
434        document. `title` and `metadata` are persisted on the document in push mode.
435        **Pull mode** (`pull: true`) re-triggers ingestion using the source's own configured
436        data. Use this to re-scrape a `scrape/site`, re-fetch a `web/link`, or re-process a
437        `file/document`. Not valid for `knowledge/documents` (which has no upstream push new
438        bytes instead) or for source kinds populated by server-driven flows. `title` and
439        `metadata` are ignored in pull mode.
440        If an ingestion is already active for the source, the existing ingestion is returned
441        rather than creating a duplicate.
442
443        Args:
444            source: Knowledge source ID (`ksrc_...`) to ingest.
445            input: Request body.
446            input.content: Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`.
447            input.dedupe: When `true`, reuse the source's existing document if the pushed content is byte-identical to it, instead of creating a duplicate. The reused document keeps its chunks and embeddings, and `title`/`metadata` from this request are still applied to it. Content that differs in any way always creates a new document. Defaults to `false`, which creates a new document on every push. Push mode only not valid with `pull: true`. Check `metadata.document_reused` on the returned ingestion to see whether a document was actually reused.
448            input.file: ID of an already-uploaded file (`fil_...`). The runner reads filename and content type from the stored file. Upload the file via `POST /v1/files` first. Mutually exclusive with `content` and `pull`.
449            input.metadata: Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`.
450            input.pull: When `true`, re-triggers ingestion using the source's own configured data. Re-scrapes a `scrape/site`, re-fetches a `web/link`, or re-processes a `file/document`. Mutually exclusive with `file` and `content`. Not valid for `knowledge/documents` sources.
451            input.title: Display title for the ingested document. Applied in push mode only; ignored when `pull: true`.
452
453        Returns:
454            The created ingestion, or an existing active ingestion if one is already running.
455        """
456        return await self._http.request(
457            f"/api/v1/knowledge_sources/{source}/ingest",
458            method="POST",
459            body=input,
460            response_type=ContextIngestion,
461        )

Trigger ingestion on a knowledge source Starts an ingestion run on the specified knowledge source and returns the ingestion object. Exactly one of two modes must be chosen per request: Push mode (file or content) available for knowledge/documents sources only. Supply the document bytes either as a reference to an already-uploaded file (file) or as an inline blob (content). The runner stores the bytes and indexes the resulting document. title and metadata are persisted on the document in push mode. Pull mode (pull: true) re-triggers ingestion using the source's own configured data. Use this to re-scrape a scrape/site, re-fetch a web/link, or re-process a file/document. Not valid for knowledge/documents (which has no upstream push new bytes instead) or for source kinds populated by server-driven flows. title and metadata are ignored in pull mode. If an ingestion is already active for the source, the existing ingestion is returned rather than creating a duplicate.

Arguments:
  • source: Knowledge source ID (ksrc_...) to ingest.
  • input: Request body.
  • input.content: Inline document bytes to push to the source. Mutually exclusive with file and pull.
  • input.dedupe: When true, reuse the source's existing document if the pushed content is byte-identical to it, instead of creating a duplicate. The reused document keeps its chunks and embeddings, and title/metadata from this request are still applied to it. Content that differs in any way always creates a new document. Defaults to false, which creates a new document on every push. Push mode only not valid with pull: true. Check metadata.document_reused on the returned ingestion to see whether a document was actually reused.
  • input.file: ID of an already-uploaded file (fil_...). The runner reads filename and content type from the stored file. Upload the file via POST /v1/files first. Mutually exclusive with content and pull.
  • input.metadata: Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when pull: true.
  • input.pull: When true, re-triggers ingestion using the source's own configured data. Re-scrapes a scrape/site, re-fetches a web/link, or re-processes a file/document. Mutually exclusive with file and content. Not valid for knowledge/documents sources.
  • input.title: Display title for the ingested document. Applied in push mode only; ignored when pull: true.
Returns:

The created ingestion, or an existing active ingestion if one is already running.

async def search( self, source: str, input: KnowledgeSourceSearchInput) -> KnowledgeSourceSearchResponse:
463    async def search(
464        self, source: str, input: KnowledgeSourceSearchInput
465    ) -> KnowledgeSourceSearchResponse:
466        """
467        Search within a knowledge source
468        Executes a search query against the indexed documents in a single knowledge source and
469        returns matching results ranked by relevance.
470        Three search modes are supported: `"hybrid"` (default) combines vector similarity and
471        full-text scoring, `"vector"` uses embedding-based semantic search only, and
472        `"fulltext"` uses keyword-based search only. Use `"hybrid"` for most use cases;
473        prefer `"vector"` when semantic meaning matters more than exact terms.
474        Optionally restrict results to documents ingested within the last N days using
475        `recency_days`. Results are ordered by relevance score descending.
476
477        Args:
478            source: Knowledge source ID (`ksrc_...`) to search within.
479            input: Request body.
480            input.max_results: Maximum number of results to return. The platform applies its own upper bound; omit to use the default.
481            input.min_similarity: Cosine-similarity floor for the vector leg, 0.0-1.0. Candidates below it are discarded before ranking, so a high value trades recall for precision. Pass `0.0` to disable the floor when a missed match costs more than a weak one note that with no floor every query returns results, so an empty response can no longer be read as "no match". Omit to use the default.
482            input.mode: Search algorithm to use. One of `"hybrid"` (default, combines vector and full-text), `"vector"` (semantic similarity only), or `"fulltext"` (keyword matching only).
483            input.query: Natural language or keyword query string to search for.
484            input.recency_days: When set, limits results to documents ingested within the last N days. Omit to search across all documents regardless of age.
485
486        Returns:
487            Successful response
488        """
489        return await self._http.request(
490            f"/api/v1/knowledge_sources/{source}/search",
491            method="POST",
492            body=input,
493            response_type=KnowledgeSourceSearchResponse,
494        )

Search within a knowledge source Executes a search query against the indexed documents in a single knowledge source and returns matching results ranked by relevance. Three search modes are supported: "hybrid" (default) combines vector similarity and full-text scoring, "vector" uses embedding-based semantic search only, and "fulltext" uses keyword-based search only. Use "hybrid" for most use cases; prefer "vector" when semantic meaning matters more than exact terms. Optionally restrict results to documents ingested within the last N days using recency_days. Results are ordered by relevance score descending.

Arguments:
  • source: Knowledge source ID (ksrc_...) to search within.
  • input: Request body.
  • input.max_results: Maximum number of results to return. The platform applies its own upper bound; omit to use the default.
  • input.min_similarity: Cosine-similarity floor for the vector leg, 0.0-1.0. Candidates below it are discarded before ranking, so a high value trades recall for precision. Pass 0.0 to disable the floor when a missed match costs more than a weak one note that with no floor every query returns results, so an empty response can no longer be read as "no match". Omit to use the default.
  • input.mode: Search algorithm to use. One of "hybrid" (default, combines vector and full-text), "vector" (semantic similarity only), or "fulltext" (keyword matching only).
  • input.query: Natural language or keyword query string to search for.
  • input.recency_days: When set, limits results to documents ingested within the last N days. Omit to search across all documents regardless of age.
Returns:

Successful response

class KnowledgeSourceKindResource:
497class KnowledgeSourceKindResource:
498    def __init__(self, http: SyncHttpClient):
499        self._http = http
500
501    def list(self) -> KnowledgeSourceKindListResponse:
502        """
503        List creatable knowledge source kinds
504        Returns the fixed set of knowledge source types that can be created directly via
505        `POST /api/v1/knowledge_sources`. Use this endpoint to discover valid values for the
506        `type` param before calling the create endpoint.
507        Source kinds populated by server-driven flows such as `webhook/inbound`,
508        `connectors/*/emails`, and `thread/messages` are intentionally excluded from this
509        list, as they cannot be created through the API.
510
511        Returns:
512            List of knowledge source kinds available for creation via the API.
513        """
514        return self._http.request(
515            "/api/v1/knowledge_sources/kinds",
516            response_type=KnowledgeSourceKindListResponse,
517        )
KnowledgeSourceKindResource(http: archastro.platform.runtime.http_client.SyncHttpClient)
498    def __init__(self, http: SyncHttpClient):
499        self._http = http
501    def list(self) -> KnowledgeSourceKindListResponse:
502        """
503        List creatable knowledge source kinds
504        Returns the fixed set of knowledge source types that can be created directly via
505        `POST /api/v1/knowledge_sources`. Use this endpoint to discover valid values for the
506        `type` param before calling the create endpoint.
507        Source kinds populated by server-driven flows such as `webhook/inbound`,
508        `connectors/*/emails`, and `thread/messages` are intentionally excluded from this
509        list, as they cannot be created through the API.
510
511        Returns:
512            List of knowledge source kinds available for creation via the API.
513        """
514        return self._http.request(
515            "/api/v1/knowledge_sources/kinds",
516            response_type=KnowledgeSourceKindListResponse,
517        )

List creatable knowledge source kinds Returns the fixed set of knowledge source types that can be created directly via POST /api/v1/knowledge_sources. Use this endpoint to discover valid values for the type param before calling the create endpoint. Source kinds populated by server-driven flows such as webhook/inbound, connectors/*/emails, and thread/messages are intentionally excluded from this list, as they cannot be created through the API.

Returns:

List of knowledge source kinds available for creation via the API.

class KnowledgeSourceResource:
520class KnowledgeSourceResource:
521    def __init__(self, http: SyncHttpClient):
522        self._http = http
523        self.kinds = KnowledgeSourceKindResource(http)
524
525    def list(
526        self,
527        *,
528        page: int | None = None,
529        page_size: int | None = None,
530        search: str | None = None,
531        type: str | None = None,
532        team: builtins.list[str] | None = None,
533        thread: builtins.list[str] | None = None,
534        installation: str | None = None,
535        agent: str | None = None,
536        org: str | None = None,
537        owner_scope: Literal["any", "individual", "system"] | None = None,
538    ) -> KnowledgeSourceListResponse:
539        """
540        List knowledge sources
541        Returns a paginated list of knowledge sources visible to the authenticated caller.
542        Results are ordered by creation time descending.
543        Use the `type`, `installation`, `agent`, `org`, and `owner_scope` filters to narrow the
544        result set. Combine `owner_scope: "system"` with `org` to list org-level sources that
545        have no individual owner. Combine `owner_scope: "individual"` with `agent` to list
546        sources owned by a specific agent.
547        Pagination is page-number based. The default page size is 25.
548
549        Args:
550            page: Page number to retrieve. Defaults to 1.
551            page_size: Number of knowledge sources to return per page. Defaults to 25.
552            search: Filter sources whose type contains this string. Case-insensitive substring match.
553            type: Exact knowledge source type to filter by, e.g. `"knowledge/documents"`.
554            team: Exact team IDs whose sources to include.
555            thread: Exact backing thread IDs whose sources to include.
556            installation: Installation ID (`ins_...`). Returns only sources associated with this installation.
557            agent: Agent ID (`agt_...`). Returns only sources owned by or associated with this agent.
558            org: Organization ID (`org_...`). Returns only sources belonging to this organization. Combine with `owner_scope: "system"` to retrieve org-level system sources.
559            owner_scope: Filter by ownership scope. One of `"any"` (default returns all visible sources), `"individual"` (only sources owned by a user, team, or agent), or `"system"` (only sources with no individual owner, typically org-level).
560
561        Returns:
562            Successful response
563        """
564        query: dict[str, object] = {}
565        if page is not None:
566            query["page"] = page
567        if page_size is not None:
568            query["page_size"] = page_size
569        if search is not None:
570            query["search"] = search
571        if type is not None:
572            query["type"] = type
573        if team is not None:
574            query["team"] = team
575        if thread is not None:
576            query["thread"] = thread
577        if installation is not None:
578            query["installation"] = installation
579        if agent is not None:
580            query["agent"] = agent
581        if org is not None:
582            query["org"] = org
583        if owner_scope is not None:
584            query["owner_scope"] = owner_scope
585        return self._http.request(
586            "/api/v1/knowledge_sources",
587            query=query,
588            response_type=KnowledgeSourceListResponse,
589        )
590
591    def create(self, input: KnowledgeSourceCreateInput) -> KnowledgeSource:
592        """
593        Create a knowledge source
594        Creates a new knowledge source of the requested type and returns the created object.
595        Only types listed by `GET /api/v1/knowledge_sources/kinds` may be created through this
596        endpoint. Other source types such as `webhook/inbound`, `connectors/*/emails`, and
597        `thread/messages` are provisioned automatically by server-driven flows (webhook
598        auto-provisioning, installation activation, connector lifecycle events) and cannot be
599        created directly via the API.
600        Exactly one of `team`, `user`, `agent`, or `org` must identify the owner of the new
601        source. Omit `org` when an individual owner (`team`, `user`, or `agent`) is supplied;
602        include `org` alone for org-level system-owned sources.
603
604        Args:
605            input: Request body.
606            input.agent: Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`.
607            input.metadata: Arbitrary key-value metadata to attach to the source. Returned as-is on reads.
608            input.org: Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`).
609            input.parent_source: Parent knowledge source ID (`ksrc_...`). Use to create a child source.
610            input.payload: Type-specific configuration for the source. Shape depends on `type`.
611            input.state: Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.
612            input.team: Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`.
613            input.thread: Thread ID (`thr_...`) to associate this source with, if applicable.
614            input.type: Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`.
615            input.user: User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`.
616
617        Returns:
618            The newly created knowledge source.
619        """
620        return self._http.request(
621            "/api/v1/knowledge_sources",
622            method="POST",
623            body=input,
624            response_type=KnowledgeSource,
625        )
626
627    def delete(self, source: str) -> None:
628        """
629        Delete a knowledge source
630        Permanently deletes the knowledge source identified by `source`. This action is
631        irreversible all documents, embeddings, and ingestion history associated with the
632        source are removed.
633        The authenticated caller must own the source or have sufficient permissions within its
634        parent organization. Returns `204 No Content` on success.
635
636        Args:
637            source: Knowledge source ID (`ksrc_...`) to delete.
638
639        Returns:
640            Empty response. The source has been permanently deleted.
641        """
642        self._http.request(f"/api/v1/knowledge_sources/{source}", method="DELETE")
643
644    def get(self, source: str) -> KnowledgeSource:
645        """
646        Retrieve a knowledge source
647        Returns the knowledge source identified by `source`. The authenticated caller must have
648        access to the source's parent organization or be the individual owner of the source.
649        Use the list endpoint to retrieve many sources at once or to discover sources by type
650        or owner.
651
652        Args:
653            source: Knowledge source ID (`ksrc_...`) to retrieve.
654
655        Returns:
656            The requested knowledge source.
657        """
658        return self._http.request(
659            f"/api/v1/knowledge_sources/{source}",
660            response_type=KnowledgeSource,
661        )
662
663    def update(self, source: str, input: KnowledgeSourceUpdateInput) -> KnowledgeSource:
664        """
665        Update a knowledge source
666        Updates the mutable fields of an existing knowledge source and returns the updated
667        object. Only fields provided in the request body are changed; omitted fields retain
668        their current values.
669        You can update the type-specific `payload`, the `metadata` map, and the `state`. To
670        pause a source and prevent automatic ingestion, set `state` to `"paused"`. To resume,
671        set it back to `"active"`.
672
673        Args:
674            source: Knowledge source ID (`ksrc_...`) to update.
675            input: Request body.
676            input.metadata: Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided.
677            input.payload: Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided.
678            input.state: Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.
679
680        Returns:
681            The updated knowledge source.
682        """
683        return self._http.request(
684            f"/api/v1/knowledge_sources/{source}",
685            method="PATCH",
686            body=input,
687            response_type=KnowledgeSource,
688        )
689
690    def ingest(self, source: str, input: KnowledgeSourceIngestInput) -> ContextIngestion:
691        """
692        Trigger ingestion on a knowledge source
693        Starts an ingestion run on the specified knowledge source and returns the ingestion
694        object. Exactly one of two modes must be chosen per request:
695        **Push mode** (`file` or `content`) available for `knowledge/documents` sources only.
696        Supply the document bytes either as a reference to an already-uploaded file (`file`) or
697        as an inline blob (`content`). The runner stores the bytes and indexes the resulting
698        document. `title` and `metadata` are persisted on the document in push mode.
699        **Pull mode** (`pull: true`) re-triggers ingestion using the source's own configured
700        data. Use this to re-scrape a `scrape/site`, re-fetch a `web/link`, or re-process a
701        `file/document`. Not valid for `knowledge/documents` (which has no upstream push new
702        bytes instead) or for source kinds populated by server-driven flows. `title` and
703        `metadata` are ignored in pull mode.
704        If an ingestion is already active for the source, the existing ingestion is returned
705        rather than creating a duplicate.
706
707        Args:
708            source: Knowledge source ID (`ksrc_...`) to ingest.
709            input: Request body.
710            input.content: Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`.
711            input.dedupe: When `true`, reuse the source's existing document if the pushed content is byte-identical to it, instead of creating a duplicate. The reused document keeps its chunks and embeddings, and `title`/`metadata` from this request are still applied to it. Content that differs in any way always creates a new document. Defaults to `false`, which creates a new document on every push. Push mode only not valid with `pull: true`. Check `metadata.document_reused` on the returned ingestion to see whether a document was actually reused.
712            input.file: ID of an already-uploaded file (`fil_...`). The runner reads filename and content type from the stored file. Upload the file via `POST /v1/files` first. Mutually exclusive with `content` and `pull`.
713            input.metadata: Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`.
714            input.pull: When `true`, re-triggers ingestion using the source's own configured data. Re-scrapes a `scrape/site`, re-fetches a `web/link`, or re-processes a `file/document`. Mutually exclusive with `file` and `content`. Not valid for `knowledge/documents` sources.
715            input.title: Display title for the ingested document. Applied in push mode only; ignored when `pull: true`.
716
717        Returns:
718            The created ingestion, or an existing active ingestion if one is already running.
719        """
720        return self._http.request(
721            f"/api/v1/knowledge_sources/{source}/ingest",
722            method="POST",
723            body=input,
724            response_type=ContextIngestion,
725        )
726
727    def search(
728        self, source: str, input: KnowledgeSourceSearchInput
729    ) -> KnowledgeSourceSearchResponse:
730        """
731        Search within a knowledge source
732        Executes a search query against the indexed documents in a single knowledge source and
733        returns matching results ranked by relevance.
734        Three search modes are supported: `"hybrid"` (default) combines vector similarity and
735        full-text scoring, `"vector"` uses embedding-based semantic search only, and
736        `"fulltext"` uses keyword-based search only. Use `"hybrid"` for most use cases;
737        prefer `"vector"` when semantic meaning matters more than exact terms.
738        Optionally restrict results to documents ingested within the last N days using
739        `recency_days`. Results are ordered by relevance score descending.
740
741        Args:
742            source: Knowledge source ID (`ksrc_...`) to search within.
743            input: Request body.
744            input.max_results: Maximum number of results to return. The platform applies its own upper bound; omit to use the default.
745            input.min_similarity: Cosine-similarity floor for the vector leg, 0.0-1.0. Candidates below it are discarded before ranking, so a high value trades recall for precision. Pass `0.0` to disable the floor when a missed match costs more than a weak one note that with no floor every query returns results, so an empty response can no longer be read as "no match". Omit to use the default.
746            input.mode: Search algorithm to use. One of `"hybrid"` (default, combines vector and full-text), `"vector"` (semantic similarity only), or `"fulltext"` (keyword matching only).
747            input.query: Natural language or keyword query string to search for.
748            input.recency_days: When set, limits results to documents ingested within the last N days. Omit to search across all documents regardless of age.
749
750        Returns:
751            Successful response
752        """
753        return self._http.request(
754            f"/api/v1/knowledge_sources/{source}/search",
755            method="POST",
756            body=input,
757            response_type=KnowledgeSourceSearchResponse,
758        )
KnowledgeSourceResource(http: archastro.platform.runtime.http_client.SyncHttpClient)
521    def __init__(self, http: SyncHttpClient):
522        self._http = http
523        self.kinds = KnowledgeSourceKindResource(http)
kinds
def list( self, *, page: int | None = None, page_size: int | None = None, search: str | None = None, type: str | None = None, team: list[str] | None = None, thread: list[str] | None = None, installation: str | None = None, agent: str | None = None, org: str | None = None, owner_scope: Optional[Literal['any', 'individual', 'system']] = None) -> KnowledgeSourceListResponse:
525    def list(
526        self,
527        *,
528        page: int | None = None,
529        page_size: int | None = None,
530        search: str | None = None,
531        type: str | None = None,
532        team: builtins.list[str] | None = None,
533        thread: builtins.list[str] | None = None,
534        installation: str | None = None,
535        agent: str | None = None,
536        org: str | None = None,
537        owner_scope: Literal["any", "individual", "system"] | None = None,
538    ) -> KnowledgeSourceListResponse:
539        """
540        List knowledge sources
541        Returns a paginated list of knowledge sources visible to the authenticated caller.
542        Results are ordered by creation time descending.
543        Use the `type`, `installation`, `agent`, `org`, and `owner_scope` filters to narrow the
544        result set. Combine `owner_scope: "system"` with `org` to list org-level sources that
545        have no individual owner. Combine `owner_scope: "individual"` with `agent` to list
546        sources owned by a specific agent.
547        Pagination is page-number based. The default page size is 25.
548
549        Args:
550            page: Page number to retrieve. Defaults to 1.
551            page_size: Number of knowledge sources to return per page. Defaults to 25.
552            search: Filter sources whose type contains this string. Case-insensitive substring match.
553            type: Exact knowledge source type to filter by, e.g. `"knowledge/documents"`.
554            team: Exact team IDs whose sources to include.
555            thread: Exact backing thread IDs whose sources to include.
556            installation: Installation ID (`ins_...`). Returns only sources associated with this installation.
557            agent: Agent ID (`agt_...`). Returns only sources owned by or associated with this agent.
558            org: Organization ID (`org_...`). Returns only sources belonging to this organization. Combine with `owner_scope: "system"` to retrieve org-level system sources.
559            owner_scope: Filter by ownership scope. One of `"any"` (default returns all visible sources), `"individual"` (only sources owned by a user, team, or agent), or `"system"` (only sources with no individual owner, typically org-level).
560
561        Returns:
562            Successful response
563        """
564        query: dict[str, object] = {}
565        if page is not None:
566            query["page"] = page
567        if page_size is not None:
568            query["page_size"] = page_size
569        if search is not None:
570            query["search"] = search
571        if type is not None:
572            query["type"] = type
573        if team is not None:
574            query["team"] = team
575        if thread is not None:
576            query["thread"] = thread
577        if installation is not None:
578            query["installation"] = installation
579        if agent is not None:
580            query["agent"] = agent
581        if org is not None:
582            query["org"] = org
583        if owner_scope is not None:
584            query["owner_scope"] = owner_scope
585        return self._http.request(
586            "/api/v1/knowledge_sources",
587            query=query,
588            response_type=KnowledgeSourceListResponse,
589        )

List knowledge sources Returns a paginated list of knowledge sources visible to the authenticated caller. Results are ordered by creation time descending. Use the type, installation, agent, org, and owner_scope filters to narrow the result set. Combine owner_scope: "system" with org to list org-level sources that have no individual owner. Combine owner_scope: "individual" with agent to list sources owned by a specific agent. Pagination is page-number based. The default page size is 25.

Arguments:
  • page: Page number to retrieve. Defaults to 1.
  • page_size: Number of knowledge sources to return per page. Defaults to 25.
  • search: Filter sources whose type contains this string. Case-insensitive substring match.
  • type: Exact knowledge source type to filter by, e.g. "knowledge/documents".
  • team: Exact team IDs whose sources to include.
  • thread: Exact backing thread IDs whose sources to include.
  • installation: Installation ID (ins_...). Returns only sources associated with this installation.
  • agent: Agent ID (agt_...). Returns only sources owned by or associated with this agent.
  • org: Organization ID (org_...). Returns only sources belonging to this organization. Combine with owner_scope: "system" to retrieve org-level system sources.
  • owner_scope: Filter by ownership scope. One of "any" (default returns all visible sources), "individual" (only sources owned by a user, team, or agent), or "system" (only sources with no individual owner, typically org-level).
Returns:

Successful response

591    def create(self, input: KnowledgeSourceCreateInput) -> KnowledgeSource:
592        """
593        Create a knowledge source
594        Creates a new knowledge source of the requested type and returns the created object.
595        Only types listed by `GET /api/v1/knowledge_sources/kinds` may be created through this
596        endpoint. Other source types such as `webhook/inbound`, `connectors/*/emails`, and
597        `thread/messages` are provisioned automatically by server-driven flows (webhook
598        auto-provisioning, installation activation, connector lifecycle events) and cannot be
599        created directly via the API.
600        Exactly one of `team`, `user`, `agent`, or `org` must identify the owner of the new
601        source. Omit `org` when an individual owner (`team`, `user`, or `agent`) is supplied;
602        include `org` alone for org-level system-owned sources.
603
604        Args:
605            input: Request body.
606            input.agent: Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`.
607            input.metadata: Arbitrary key-value metadata to attach to the source. Returned as-is on reads.
608            input.org: Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`).
609            input.parent_source: Parent knowledge source ID (`ksrc_...`). Use to create a child source.
610            input.payload: Type-specific configuration for the source. Shape depends on `type`.
611            input.state: Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.
612            input.team: Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`.
613            input.thread: Thread ID (`thr_...`) to associate this source with, if applicable.
614            input.type: Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`.
615            input.user: User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`.
616
617        Returns:
618            The newly created knowledge source.
619        """
620        return self._http.request(
621            "/api/v1/knowledge_sources",
622            method="POST",
623            body=input,
624            response_type=KnowledgeSource,
625        )

Create a knowledge source Creates a new knowledge source of the requested type and returns the created object. Only types listed by GET /api/v1/knowledge_sources/kinds may be created through this endpoint. Other source types such as webhook/inbound, connectors/*/emails, and thread/messages are provisioned automatically by server-driven flows (webhook auto-provisioning, installation activation, connector lifecycle events) and cannot be created directly via the API. Exactly one of team, user, agent, or org must identify the owner of the new source. Omit org when an individual owner (team, user, or agent) is supplied; include org alone for org-level system-owned sources.

Arguments:
  • input: Request body.
  • input.agent: Agent ID (agt_...) that owns this source. Mutually exclusive with team and user.
  • input.metadata: Arbitrary key-value metadata to attach to the source. Returned as-is on reads.
  • input.org: Organization ID (org_...). Required for system-owned sources that have no individual owner (team, user, or agent).
  • input.parent_source: Parent knowledge source ID (ksrc_...). Use to create a child source.
  • input.payload: Type-specific configuration for the source. Shape depends on type.
  • input.state: Initial state of the source. One of "active" (default) or "paused". Paused sources do not trigger ingestion automatically.
  • input.team: Team ID (team_...) that owns this source. Mutually exclusive with user and agent.
  • input.thread: Thread ID (thr_...) to associate this source with, if applicable.
  • input.type: Knowledge source type. Must be one of the values returned by GET /api/v1/knowledge_sources/kinds.
  • input.user: User ID (usr_...) that owns this source. Mutually exclusive with team and agent.
Returns:

The newly created knowledge source.

def delete(self, source: str) -> None:
627    def delete(self, source: str) -> None:
628        """
629        Delete a knowledge source
630        Permanently deletes the knowledge source identified by `source`. This action is
631        irreversible all documents, embeddings, and ingestion history associated with the
632        source are removed.
633        The authenticated caller must own the source or have sufficient permissions within its
634        parent organization. Returns `204 No Content` on success.
635
636        Args:
637            source: Knowledge source ID (`ksrc_...`) to delete.
638
639        Returns:
640            Empty response. The source has been permanently deleted.
641        """
642        self._http.request(f"/api/v1/knowledge_sources/{source}", method="DELETE")

Delete a knowledge source Permanently deletes the knowledge source identified by source. This action is irreversible all documents, embeddings, and ingestion history associated with the source are removed. The authenticated caller must own the source or have sufficient permissions within its parent organization. Returns 204 No Content on success.

Arguments:
  • source: Knowledge source ID (ksrc_...) to delete.
Returns:

Empty response. The source has been permanently deleted.

def get(self, source: str) -> archastro.platform.types.common.KnowledgeSource:
644    def get(self, source: str) -> KnowledgeSource:
645        """
646        Retrieve a knowledge source
647        Returns the knowledge source identified by `source`. The authenticated caller must have
648        access to the source's parent organization or be the individual owner of the source.
649        Use the list endpoint to retrieve many sources at once or to discover sources by type
650        or owner.
651
652        Args:
653            source: Knowledge source ID (`ksrc_...`) to retrieve.
654
655        Returns:
656            The requested knowledge source.
657        """
658        return self._http.request(
659            f"/api/v1/knowledge_sources/{source}",
660            response_type=KnowledgeSource,
661        )

Retrieve a knowledge source Returns the knowledge source identified by source. The authenticated caller must have access to the source's parent organization or be the individual owner of the source. Use the list endpoint to retrieve many sources at once or to discover sources by type or owner.

Arguments:
  • source: Knowledge source ID (ksrc_...) to retrieve.
Returns:

The requested knowledge source.

def update( self, source: str, input: KnowledgeSourceUpdateInput) -> archastro.platform.types.common.KnowledgeSource:
663    def update(self, source: str, input: KnowledgeSourceUpdateInput) -> KnowledgeSource:
664        """
665        Update a knowledge source
666        Updates the mutable fields of an existing knowledge source and returns the updated
667        object. Only fields provided in the request body are changed; omitted fields retain
668        their current values.
669        You can update the type-specific `payload`, the `metadata` map, and the `state`. To
670        pause a source and prevent automatic ingestion, set `state` to `"paused"`. To resume,
671        set it back to `"active"`.
672
673        Args:
674            source: Knowledge source ID (`ksrc_...`) to update.
675            input: Request body.
676            input.metadata: Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided.
677            input.payload: Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided.
678            input.state: Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.
679
680        Returns:
681            The updated knowledge source.
682        """
683        return self._http.request(
684            f"/api/v1/knowledge_sources/{source}",
685            method="PATCH",
686            body=input,
687            response_type=KnowledgeSource,
688        )

Update a knowledge source Updates the mutable fields of an existing knowledge source and returns the updated object. Only fields provided in the request body are changed; omitted fields retain their current values. You can update the type-specific payload, the metadata map, and the state. To pause a source and prevent automatic ingestion, set state to "paused". To resume, set it back to "active".

Arguments:
  • source: Knowledge source ID (ksrc_...) to update.
  • input: Request body.
  • input.metadata: Arbitrary key-value metadata to attach to the source. Replaces the entire existing metadata map when provided.
  • input.payload: Type-specific configuration to replace on the source. Shape depends on the source type. Replaces the entire existing payload when provided.
  • input.state: Desired state of the source. One of "active" or "paused". Paused sources do not trigger ingestion automatically.
Returns:

The updated knowledge source.

def ingest( self, source: str, input: KnowledgeSourceIngestInput) -> archastro.platform.types.common.ContextIngestion:
690    def ingest(self, source: str, input: KnowledgeSourceIngestInput) -> ContextIngestion:
691        """
692        Trigger ingestion on a knowledge source
693        Starts an ingestion run on the specified knowledge source and returns the ingestion
694        object. Exactly one of two modes must be chosen per request:
695        **Push mode** (`file` or `content`) available for `knowledge/documents` sources only.
696        Supply the document bytes either as a reference to an already-uploaded file (`file`) or
697        as an inline blob (`content`). The runner stores the bytes and indexes the resulting
698        document. `title` and `metadata` are persisted on the document in push mode.
699        **Pull mode** (`pull: true`) re-triggers ingestion using the source's own configured
700        data. Use this to re-scrape a `scrape/site`, re-fetch a `web/link`, or re-process a
701        `file/document`. Not valid for `knowledge/documents` (which has no upstream push new
702        bytes instead) or for source kinds populated by server-driven flows. `title` and
703        `metadata` are ignored in pull mode.
704        If an ingestion is already active for the source, the existing ingestion is returned
705        rather than creating a duplicate.
706
707        Args:
708            source: Knowledge source ID (`ksrc_...`) to ingest.
709            input: Request body.
710            input.content: Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`.
711            input.dedupe: When `true`, reuse the source's existing document if the pushed content is byte-identical to it, instead of creating a duplicate. The reused document keeps its chunks and embeddings, and `title`/`metadata` from this request are still applied to it. Content that differs in any way always creates a new document. Defaults to `false`, which creates a new document on every push. Push mode only not valid with `pull: true`. Check `metadata.document_reused` on the returned ingestion to see whether a document was actually reused.
712            input.file: ID of an already-uploaded file (`fil_...`). The runner reads filename and content type from the stored file. Upload the file via `POST /v1/files` first. Mutually exclusive with `content` and `pull`.
713            input.metadata: Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`.
714            input.pull: When `true`, re-triggers ingestion using the source's own configured data. Re-scrapes a `scrape/site`, re-fetches a `web/link`, or re-processes a `file/document`. Mutually exclusive with `file` and `content`. Not valid for `knowledge/documents` sources.
715            input.title: Display title for the ingested document. Applied in push mode only; ignored when `pull: true`.
716
717        Returns:
718            The created ingestion, or an existing active ingestion if one is already running.
719        """
720        return self._http.request(
721            f"/api/v1/knowledge_sources/{source}/ingest",
722            method="POST",
723            body=input,
724            response_type=ContextIngestion,
725        )

Trigger ingestion on a knowledge source Starts an ingestion run on the specified knowledge source and returns the ingestion object. Exactly one of two modes must be chosen per request: Push mode (file or content) available for knowledge/documents sources only. Supply the document bytes either as a reference to an already-uploaded file (file) or as an inline blob (content). The runner stores the bytes and indexes the resulting document. title and metadata are persisted on the document in push mode. Pull mode (pull: true) re-triggers ingestion using the source's own configured data. Use this to re-scrape a scrape/site, re-fetch a web/link, or re-process a file/document. Not valid for knowledge/documents (which has no upstream push new bytes instead) or for source kinds populated by server-driven flows. title and metadata are ignored in pull mode. If an ingestion is already active for the source, the existing ingestion is returned rather than creating a duplicate.

Arguments:
  • source: Knowledge source ID (ksrc_...) to ingest.
  • input: Request body.
  • input.content: Inline document bytes to push to the source. Mutually exclusive with file and pull.
  • input.dedupe: When true, reuse the source's existing document if the pushed content is byte-identical to it, instead of creating a duplicate. The reused document keeps its chunks and embeddings, and title/metadata from this request are still applied to it. Content that differs in any way always creates a new document. Defaults to false, which creates a new document on every push. Push mode only not valid with pull: true. Check metadata.document_reused on the returned ingestion to see whether a document was actually reused.
  • input.file: ID of an already-uploaded file (fil_...). The runner reads filename and content type from the stored file. Upload the file via POST /v1/files first. Mutually exclusive with content and pull.
  • input.metadata: Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when pull: true.
  • input.pull: When true, re-triggers ingestion using the source's own configured data. Re-scrapes a scrape/site, re-fetches a web/link, or re-processes a file/document. Mutually exclusive with file and content. Not valid for knowledge/documents sources.
  • input.title: Display title for the ingested document. Applied in push mode only; ignored when pull: true.
Returns:

The created ingestion, or an existing active ingestion if one is already running.

def search( self, source: str, input: KnowledgeSourceSearchInput) -> KnowledgeSourceSearchResponse:
727    def search(
728        self, source: str, input: KnowledgeSourceSearchInput
729    ) -> KnowledgeSourceSearchResponse:
730        """
731        Search within a knowledge source
732        Executes a search query against the indexed documents in a single knowledge source and
733        returns matching results ranked by relevance.
734        Three search modes are supported: `"hybrid"` (default) combines vector similarity and
735        full-text scoring, `"vector"` uses embedding-based semantic search only, and
736        `"fulltext"` uses keyword-based search only. Use `"hybrid"` for most use cases;
737        prefer `"vector"` when semantic meaning matters more than exact terms.
738        Optionally restrict results to documents ingested within the last N days using
739        `recency_days`. Results are ordered by relevance score descending.
740
741        Args:
742            source: Knowledge source ID (`ksrc_...`) to search within.
743            input: Request body.
744            input.max_results: Maximum number of results to return. The platform applies its own upper bound; omit to use the default.
745            input.min_similarity: Cosine-similarity floor for the vector leg, 0.0-1.0. Candidates below it are discarded before ranking, so a high value trades recall for precision. Pass `0.0` to disable the floor when a missed match costs more than a weak one note that with no floor every query returns results, so an empty response can no longer be read as "no match". Omit to use the default.
746            input.mode: Search algorithm to use. One of `"hybrid"` (default, combines vector and full-text), `"vector"` (semantic similarity only), or `"fulltext"` (keyword matching only).
747            input.query: Natural language or keyword query string to search for.
748            input.recency_days: When set, limits results to documents ingested within the last N days. Omit to search across all documents regardless of age.
749
750        Returns:
751            Successful response
752        """
753        return self._http.request(
754            f"/api/v1/knowledge_sources/{source}/search",
755            method="POST",
756            body=input,
757            response_type=KnowledgeSourceSearchResponse,
758        )

Search within a knowledge source Executes a search query against the indexed documents in a single knowledge source and returns matching results ranked by relevance. Three search modes are supported: "hybrid" (default) combines vector similarity and full-text scoring, "vector" uses embedding-based semantic search only, and "fulltext" uses keyword-based search only. Use "hybrid" for most use cases; prefer "vector" when semantic meaning matters more than exact terms. Optionally restrict results to documents ingested within the last N days using recency_days. Results are ordered by relevance score descending.

Arguments:
  • source: Knowledge source ID (ksrc_...) to search within.
  • input: Request body.
  • input.max_results: Maximum number of results to return. The platform applies its own upper bound; omit to use the default.
  • input.min_similarity: Cosine-similarity floor for the vector leg, 0.0-1.0. Candidates below it are discarded before ranking, so a high value trades recall for precision. Pass 0.0 to disable the floor when a missed match costs more than a weak one note that with no floor every query returns results, so an empty response can no longer be read as "no match". Omit to use the default.
  • input.mode: Search algorithm to use. One of "hybrid" (default, combines vector and full-text), "vector" (semantic similarity only), or "fulltext" (keyword matching only).
  • input.query: Natural language or keyword query string to search for.
  • input.recency_days: When set, limits results to documents ingested within the last N days. Omit to search across all documents regardless of age.
Returns:

Successful response