archastro.platform.v1.resources.knowledge_sources

  1# Copyright (c) 2026 ArchAstro Inc. All Rights Reserved.
  2# This file is auto-generated by @archastro/sdk-generator. Do not edit.
  3# Content hash: 709d3b629164
  4
  5from __future__ import annotations
  6
  7from datetime import datetime
  8from typing import Any, Literal, Required, TypedDict
  9
 10from pydantic import BaseModel, Field
 11
 12from ...runtime.http_client import HttpClient, SyncHttpClient
 13from ...types.common import ContextIngestion, KnowledgeSource, KnowledgeSourceKindListResponse
 14
 15
 16class KnowledgeSourceCreateInput(TypedDict, total=False):
 17    "Create a knowledge source"
 18
 19    agent: str | None
 20    "Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`."
 21    metadata: dict[str, Any] | None
 22    "Arbitrary key-value metadata to attach to the source. Returned as-is on reads."
 23    org: str | None
 24    "Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`)."
 25    parent_source: str | None
 26    "Parent knowledge source ID (`ksrc_...`). Use to create a child source."
 27    payload: dict[str, Any] | None
 28    "Type-specific configuration for the source. Shape depends on `type`."
 29    state: str | None
 30    'Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.'
 31    team: str | None
 32    "Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`."
 33    thread: str | None
 34    "Thread ID (`thr_...`) to associate this source with, if applicable."
 35    type: Required[str]
 36    "Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`."
 37    user: str | None
 38    "User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`."
 39
 40
 41class KnowledgeSourceUpdateInput(TypedDict, total=False):
 42    "Update a knowledge source"
 43
 44    metadata: dict[str, Any] | None
 45    "Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided."
 46    payload: dict[str, Any] | None
 47    "Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided."
 48    state: str | None
 49    'Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.'
 50
 51
 52class KnowledgeSourceIngestInputContent(TypedDict, total=False):
 53    content_type: str | None
 54    'MIME type of the content, e.g. `"application/pdf"` or `"text/plain"`.'
 55    data: Required[str]
 56    'The raw document bytes. When `data_encoding` is `"base64"`, provide the base64-encoded representation of the binary content.'
 57    data_encoding: str | None
 58    'Encoding format of `data`. One of `"raw"` (default, plain text) or `"base64"` (binary content such as images or PDFs, decoded server-side before storage).'
 59    filename: str | None
 60    'Original filename for the document, e.g. `"report.pdf"`.'
 61
 62
 63class KnowledgeSourceIngestInput(TypedDict, total=False):
 64    "Trigger ingestion on a knowledge source"
 65
 66    content: KnowledgeSourceIngestInputContent | None
 67    "Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`."
 68    file: str | None
 69    "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`."
 70    metadata: dict[str, Any] | None
 71    "Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`."
 72    pull: bool | None
 73    "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."
 74    title: str | None
 75    "Display title for the ingested document. Applied in push mode only; ignored when `pull: true`."
 76
 77
 78class KnowledgeSourceListResponseDataItem(BaseModel):
 79    agent: str | None = Field(
 80        default=None,
 81        description="ID of the agent that owns this source (`agt_...`). `null` if owned by a human user or team.",
 82    )
 83    context_installation: str | None = Field(
 84        default=None,
 85        description="ID of the context installation that provisioned this source (`cin_...`). `null` when the source was created directly rather than through an installation.",
 86    )
 87    created_at: datetime | None = Field(
 88        default=None, description="When this knowledge source was created (ISO 8601)."
 89    )
 90    id: str = Field(..., description="Knowledge source ID (`cso_...`).")
 91    metadata: dict[str, Any] | None = Field(
 92        default=None,
 93        description="Arbitrary key-value metadata attached to this source. Useful for storing caller-defined labels or references.",
 94    )
 95    org: str | None = Field(
 96        default=None,
 97        description="ID of the organization this source belongs to (`org_...`). `null` if not scoped to an org.",
 98    )
 99    parent_source: str | None = Field(
100        default=None,
101        description="ID of the parent knowledge source (`cso_...`) when this source was derived from another. `null` for top-level sources.",
102    )
103    payload: dict[str, Any] | None = Field(
104        default=None,
105        description="Type-specific configuration object. The keys depend on the source `type`; see the create endpoint for the expected shape per type.",
106    )
107    sandbox: str | None = Field(
108        default=None,
109        description="ID of the developer sandbox this source is scoped to (`sbx_...`). `null` outside sandbox contexts.",
110    )
111    state: str = Field(
112        ...,
113        description='Current lifecycle state of the source. One of `"active"` (ingestion running normally) or `"paused"` (ingestion suspended).',
114    )
115    team: str | None = Field(
116        default=None,
117        description="ID of the team that owns this source (`tea_...`). `null` if owned by a user, agent, or org.",
118    )
119    thread: str | None = Field(
120        default=None,
121        description="ID of the chat thread this source is associated with (`thr_...`). `null` when not thread-scoped.",
122    )
123    type: str = Field(
124        ...,
125        description='Source type identifier (e.g. `"gmail"`, `"github_activity"`). Determines the shape of `payload` and the ingestion behavior.',
126    )
127    updated_at: datetime | None = Field(
128        default=None, description="When this knowledge source was last modified (ISO 8601)."
129    )
130    user: str | None = Field(
131        default=None,
132        description="ID of the user that owns this source (`usr_...`). `null` if owned by a team, agent, or org.",
133    )
134
135
136class KnowledgeSourceListResponse(BaseModel):
137    """
138    Successful response
139    """
140
141    data: list[KnowledgeSourceListResponseDataItem] = Field(
142        ..., description="Array of knowledge source objects for the current page."
143    )
144    has_next: bool = Field(
145        ..., description="`true` if a subsequent page exists, `false` if this is the last page."
146    )
147    has_prev: bool = Field(
148        ..., description="`true` if a previous page exists, `false` if this is the first page."
149    )
150    page: int = Field(..., description="Current page number.")
151    page_size: int = Field(..., description="Number of results returned per page.")
152    total_entries: int = Field(
153        ..., description="Total number of knowledge sources matching the query across all pages."
154    )
155    total_pages: int = Field(..., description="Total number of pages available.")
156
157
158class AsyncKnowledgeSourceKindResource:
159    def __init__(self, http: HttpClient):
160        self._http = http
161
162    async def list(self) -> KnowledgeSourceKindListResponse:
163        """
164        List creatable knowledge source kinds
165        Returns the fixed set of knowledge source types that can be created directly via
166        `POST /api/v1/knowledge_sources`. Use this endpoint to discover valid values for the
167        `type` param before calling the create endpoint.
168        Source kinds populated by server-driven flows such as `webhook/inbound`,
169        `connectors/*/emails`, and `thread/messages` are intentionally excluded from this
170        list, as they cannot be created through the API.
171
172        Returns:
173            List of knowledge source kinds available for creation via the API.
174        """
175        return await self._http.request(
176            "/api/v1/knowledge_sources/kinds",
177            response_type=KnowledgeSourceKindListResponse,
178        )
179
180
181class AsyncKnowledgeSourceResource:
182    def __init__(self, http: HttpClient):
183        self._http = http
184        self.kinds = AsyncKnowledgeSourceKindResource(http)
185
186    async def list(
187        self,
188        *,
189        page: int | None = None,
190        page_size: int | None = None,
191        search: str | None = None,
192        type: str | None = None,
193        installation: str | None = None,
194        agent: str | None = None,
195        org: str | None = None,
196        owner_scope: Literal["any", "individual", "system"] | None = None,
197    ) -> KnowledgeSourceListResponse:
198        """
199        List knowledge sources
200        Returns a paginated list of knowledge sources visible to the authenticated caller.
201        Results are ordered by creation time descending.
202        Use the `type`, `installation`, `agent`, `org`, and `owner_scope` filters to narrow the
203        result set. Combine `owner_scope: "system"` with `org` to list org-level sources that
204        have no individual owner. Combine `owner_scope: "individual"` with `agent` to list
205        sources owned by a specific agent.
206        Pagination is page-number based. The default page size is 25.
207
208        Args:
209            page: Page number to retrieve. Defaults to 1.
210            page_size: Number of knowledge sources to return per page. Defaults to 25.
211            search: Filter sources whose type contains this string. Case-insensitive substring match.
212            type: Exact knowledge source type to filter by, e.g. `"knowledge/documents"`.
213            installation: Installation ID (`ins_...`). Returns only sources associated with this installation.
214            agent: Agent ID (`agt_...`). Returns only sources owned by or associated with this agent.
215            org: Organization ID (`org_...`). Returns only sources belonging to this organization. Combine with `owner_scope: "system"` to retrieve org-level system sources.
216            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).
217
218        Returns:
219            Successful response
220        """
221        query: dict[str, object] = {}
222        if page is not None:
223            query["page"] = page
224        if page_size is not None:
225            query["page_size"] = page_size
226        if search is not None:
227            query["search"] = search
228        if type is not None:
229            query["type"] = type
230        if installation is not None:
231            query["installation"] = installation
232        if agent is not None:
233            query["agent"] = agent
234        if org is not None:
235            query["org"] = org
236        if owner_scope is not None:
237            query["owner_scope"] = owner_scope
238        return await self._http.request(
239            "/api/v1/knowledge_sources",
240            query=query,
241            response_type=KnowledgeSourceListResponse,
242        )
243
244    async def create(self, input: KnowledgeSourceCreateInput) -> KnowledgeSource:
245        """
246        Create a knowledge source
247        Creates a new knowledge source of the requested type and returns the created object.
248        Only types listed by `GET /api/v1/knowledge_sources/kinds` may be created through this
249        endpoint. Other source types such as `webhook/inbound`, `connectors/*/emails`, and
250        `thread/messages` are provisioned automatically by server-driven flows (webhook
251        auto-provisioning, installation activation, connector lifecycle events) and cannot be
252        created directly via the API.
253        Exactly one of `team`, `user`, `agent`, or `org` must identify the owner of the new
254        source. Omit `org` when an individual owner (`team`, `user`, or `agent`) is supplied;
255        include `org` alone for org-level system-owned sources.
256
257        Args:
258            input: Request body.
259            input.agent: Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`.
260            input.metadata: Arbitrary key-value metadata to attach to the source. Returned as-is on reads.
261            input.org: Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`).
262            input.parent_source: Parent knowledge source ID (`ksrc_...`). Use to create a child source.
263            input.payload: Type-specific configuration for the source. Shape depends on `type`.
264            input.state: Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.
265            input.team: Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`.
266            input.thread: Thread ID (`thr_...`) to associate this source with, if applicable.
267            input.type: Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`.
268            input.user: User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`.
269
270        Returns:
271            The newly created knowledge source.
272        """
273        return await self._http.request(
274            "/api/v1/knowledge_sources",
275            method="POST",
276            body=input,
277            response_type=KnowledgeSource,
278        )
279
280    async def delete(self, source: str) -> None:
281        """
282        Delete a knowledge source
283        Permanently deletes the knowledge source identified by `source`. This action is
284        irreversible all documents, embeddings, and ingestion history associated with the
285        source are removed.
286        The authenticated caller must own the source or have sufficient permissions within its
287        parent organization. Returns `204 No Content` on success.
288
289        Args:
290            source: Knowledge source ID (`ksrc_...`) to delete.
291
292        Returns:
293            Empty response. The source has been permanently deleted.
294        """
295        await self._http.request(f"/api/v1/knowledge_sources/{source}", method="DELETE")
296
297    async def get(self, source: str) -> KnowledgeSource:
298        """
299        Retrieve a knowledge source
300        Returns the knowledge source identified by `source`. The authenticated caller must have
301        access to the source's parent organization or be the individual owner of the source.
302        Use the list endpoint to retrieve many sources at once or to discover sources by type
303        or owner.
304
305        Args:
306            source: Knowledge source ID (`ksrc_...`) to retrieve.
307
308        Returns:
309            The requested knowledge source.
310        """
311        return await self._http.request(
312            f"/api/v1/knowledge_sources/{source}",
313            response_type=KnowledgeSource,
314        )
315
316    async def update(self, source: str, input: KnowledgeSourceUpdateInput) -> KnowledgeSource:
317        """
318        Update a knowledge source
319        Updates the mutable fields of an existing knowledge source and returns the updated
320        object. Only fields provided in the request body are changed; omitted fields retain
321        their current values.
322        You can update the type-specific `payload`, the `metadata` map, and the `state`. To
323        pause a source and prevent automatic ingestion, set `state` to `"paused"`. To resume,
324        set it back to `"active"`.
325
326        Args:
327            source: Knowledge source ID (`ksrc_...`) to update.
328            input: Request body.
329            input.metadata: Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided.
330            input.payload: Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided.
331            input.state: Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.
332
333        Returns:
334            The updated knowledge source.
335        """
336        return await self._http.request(
337            f"/api/v1/knowledge_sources/{source}",
338            method="PATCH",
339            body=input,
340            response_type=KnowledgeSource,
341        )
342
343    async def ingest(self, source: str, input: KnowledgeSourceIngestInput) -> ContextIngestion:
344        """
345        Trigger ingestion on a knowledge source
346        Starts an ingestion run on the specified knowledge source and returns the ingestion
347        object. Exactly one of two modes must be chosen per request:
348        **Push mode** (`file` or `content`) available for `knowledge/documents` sources only.
349        Supply the document bytes either as a reference to an already-uploaded file (`file`) or
350        as an inline blob (`content`). The runner stores the bytes and indexes the resulting
351        document. `title` and `metadata` are persisted on the document in push mode.
352        **Pull mode** (`pull: true`) re-triggers ingestion using the source's own configured
353        data. Use this to re-scrape a `scrape/site`, re-fetch a `web/link`, or re-process a
354        `file/document`. Not valid for `knowledge/documents` (which has no upstream push new
355        bytes instead) or for source kinds populated by server-driven flows. `title` and
356        `metadata` are ignored in pull mode.
357        If an ingestion is already active for the source, the existing ingestion is returned
358        rather than creating a duplicate.
359
360        Args:
361            source: Knowledge source ID (`ksrc_...`) to ingest.
362            input: Request body.
363            input.content: Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`.
364            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`.
365            input.metadata: Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`.
366            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.
367            input.title: Display title for the ingested document. Applied in push mode only; ignored when `pull: true`.
368
369        Returns:
370            The created ingestion, or an existing active ingestion if one is already running.
371        """
372        return await self._http.request(
373            f"/api/v1/knowledge_sources/{source}/ingest",
374            method="POST",
375            body=input,
376            response_type=ContextIngestion,
377        )
378
379
380class KnowledgeSourceKindResource:
381    def __init__(self, http: SyncHttpClient):
382        self._http = http
383
384    def list(self) -> KnowledgeSourceKindListResponse:
385        """
386        List creatable knowledge source kinds
387        Returns the fixed set of knowledge source types that can be created directly via
388        `POST /api/v1/knowledge_sources`. Use this endpoint to discover valid values for the
389        `type` param before calling the create endpoint.
390        Source kinds populated by server-driven flows such as `webhook/inbound`,
391        `connectors/*/emails`, and `thread/messages` are intentionally excluded from this
392        list, as they cannot be created through the API.
393
394        Returns:
395            List of knowledge source kinds available for creation via the API.
396        """
397        return self._http.request(
398            "/api/v1/knowledge_sources/kinds",
399            response_type=KnowledgeSourceKindListResponse,
400        )
401
402
403class KnowledgeSourceResource:
404    def __init__(self, http: SyncHttpClient):
405        self._http = http
406        self.kinds = KnowledgeSourceKindResource(http)
407
408    def list(
409        self,
410        *,
411        page: int | None = None,
412        page_size: int | None = None,
413        search: str | None = None,
414        type: str | None = None,
415        installation: str | None = None,
416        agent: str | None = None,
417        org: str | None = None,
418        owner_scope: Literal["any", "individual", "system"] | None = None,
419    ) -> KnowledgeSourceListResponse:
420        """
421        List knowledge sources
422        Returns a paginated list of knowledge sources visible to the authenticated caller.
423        Results are ordered by creation time descending.
424        Use the `type`, `installation`, `agent`, `org`, and `owner_scope` filters to narrow the
425        result set. Combine `owner_scope: "system"` with `org` to list org-level sources that
426        have no individual owner. Combine `owner_scope: "individual"` with `agent` to list
427        sources owned by a specific agent.
428        Pagination is page-number based. The default page size is 25.
429
430        Args:
431            page: Page number to retrieve. Defaults to 1.
432            page_size: Number of knowledge sources to return per page. Defaults to 25.
433            search: Filter sources whose type contains this string. Case-insensitive substring match.
434            type: Exact knowledge source type to filter by, e.g. `"knowledge/documents"`.
435            installation: Installation ID (`ins_...`). Returns only sources associated with this installation.
436            agent: Agent ID (`agt_...`). Returns only sources owned by or associated with this agent.
437            org: Organization ID (`org_...`). Returns only sources belonging to this organization. Combine with `owner_scope: "system"` to retrieve org-level system sources.
438            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).
439
440        Returns:
441            Successful response
442        """
443        query: dict[str, object] = {}
444        if page is not None:
445            query["page"] = page
446        if page_size is not None:
447            query["page_size"] = page_size
448        if search is not None:
449            query["search"] = search
450        if type is not None:
451            query["type"] = type
452        if installation is not None:
453            query["installation"] = installation
454        if agent is not None:
455            query["agent"] = agent
456        if org is not None:
457            query["org"] = org
458        if owner_scope is not None:
459            query["owner_scope"] = owner_scope
460        return self._http.request(
461            "/api/v1/knowledge_sources",
462            query=query,
463            response_type=KnowledgeSourceListResponse,
464        )
465
466    def create(self, input: KnowledgeSourceCreateInput) -> KnowledgeSource:
467        """
468        Create a knowledge source
469        Creates a new knowledge source of the requested type and returns the created object.
470        Only types listed by `GET /api/v1/knowledge_sources/kinds` may be created through this
471        endpoint. Other source types such as `webhook/inbound`, `connectors/*/emails`, and
472        `thread/messages` are provisioned automatically by server-driven flows (webhook
473        auto-provisioning, installation activation, connector lifecycle events) and cannot be
474        created directly via the API.
475        Exactly one of `team`, `user`, `agent`, or `org` must identify the owner of the new
476        source. Omit `org` when an individual owner (`team`, `user`, or `agent`) is supplied;
477        include `org` alone for org-level system-owned sources.
478
479        Args:
480            input: Request body.
481            input.agent: Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`.
482            input.metadata: Arbitrary key-value metadata to attach to the source. Returned as-is on reads.
483            input.org: Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`).
484            input.parent_source: Parent knowledge source ID (`ksrc_...`). Use to create a child source.
485            input.payload: Type-specific configuration for the source. Shape depends on `type`.
486            input.state: Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.
487            input.team: Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`.
488            input.thread: Thread ID (`thr_...`) to associate this source with, if applicable.
489            input.type: Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`.
490            input.user: User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`.
491
492        Returns:
493            The newly created knowledge source.
494        """
495        return self._http.request(
496            "/api/v1/knowledge_sources",
497            method="POST",
498            body=input,
499            response_type=KnowledgeSource,
500        )
501
502    def delete(self, source: str) -> None:
503        """
504        Delete a knowledge source
505        Permanently deletes the knowledge source identified by `source`. This action is
506        irreversible all documents, embeddings, and ingestion history associated with the
507        source are removed.
508        The authenticated caller must own the source or have sufficient permissions within its
509        parent organization. Returns `204 No Content` on success.
510
511        Args:
512            source: Knowledge source ID (`ksrc_...`) to delete.
513
514        Returns:
515            Empty response. The source has been permanently deleted.
516        """
517        self._http.request(f"/api/v1/knowledge_sources/{source}", method="DELETE")
518
519    def get(self, source: str) -> KnowledgeSource:
520        """
521        Retrieve a knowledge source
522        Returns the knowledge source identified by `source`. The authenticated caller must have
523        access to the source's parent organization or be the individual owner of the source.
524        Use the list endpoint to retrieve many sources at once or to discover sources by type
525        or owner.
526
527        Args:
528            source: Knowledge source ID (`ksrc_...`) to retrieve.
529
530        Returns:
531            The requested knowledge source.
532        """
533        return self._http.request(
534            f"/api/v1/knowledge_sources/{source}",
535            response_type=KnowledgeSource,
536        )
537
538    def update(self, source: str, input: KnowledgeSourceUpdateInput) -> KnowledgeSource:
539        """
540        Update a knowledge source
541        Updates the mutable fields of an existing knowledge source and returns the updated
542        object. Only fields provided in the request body are changed; omitted fields retain
543        their current values.
544        You can update the type-specific `payload`, the `metadata` map, and the `state`. To
545        pause a source and prevent automatic ingestion, set `state` to `"paused"`. To resume,
546        set it back to `"active"`.
547
548        Args:
549            source: Knowledge source ID (`ksrc_...`) to update.
550            input: Request body.
551            input.metadata: Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided.
552            input.payload: Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided.
553            input.state: Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.
554
555        Returns:
556            The updated knowledge source.
557        """
558        return self._http.request(
559            f"/api/v1/knowledge_sources/{source}",
560            method="PATCH",
561            body=input,
562            response_type=KnowledgeSource,
563        )
564
565    def ingest(self, source: str, input: KnowledgeSourceIngestInput) -> ContextIngestion:
566        """
567        Trigger ingestion on a knowledge source
568        Starts an ingestion run on the specified knowledge source and returns the ingestion
569        object. Exactly one of two modes must be chosen per request:
570        **Push mode** (`file` or `content`) available for `knowledge/documents` sources only.
571        Supply the document bytes either as a reference to an already-uploaded file (`file`) or
572        as an inline blob (`content`). The runner stores the bytes and indexes the resulting
573        document. `title` and `metadata` are persisted on the document in push mode.
574        **Pull mode** (`pull: true`) re-triggers ingestion using the source's own configured
575        data. Use this to re-scrape a `scrape/site`, re-fetch a `web/link`, or re-process a
576        `file/document`. Not valid for `knowledge/documents` (which has no upstream push new
577        bytes instead) or for source kinds populated by server-driven flows. `title` and
578        `metadata` are ignored in pull mode.
579        If an ingestion is already active for the source, the existing ingestion is returned
580        rather than creating a duplicate.
581
582        Args:
583            source: Knowledge source ID (`ksrc_...`) to ingest.
584            input: Request body.
585            input.content: Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`.
586            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`.
587            input.metadata: Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`.
588            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.
589            input.title: Display title for the ingested document. Applied in push mode only; ignored when `pull: true`.
590
591        Returns:
592            The created ingestion, or an existing active ingestion if one is already running.
593        """
594        return self._http.request(
595            f"/api/v1/knowledge_sources/{source}/ingest",
596            method="POST",
597            body=input,
598            response_type=ContextIngestion,
599        )
class KnowledgeSourceCreateInput(typing.TypedDict):
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`."

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):
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.'

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):
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"`.'
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):
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    file: str | None
70    "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`."
71    metadata: dict[str, Any] | None
72    "Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`."
73    pull: bool | None
74    "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."
75    title: str | None
76    "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.

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

!!! 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):
137class KnowledgeSourceListResponse(BaseModel):
138    """
139    Successful response
140    """
141
142    data: list[KnowledgeSourceListResponseDataItem] = Field(
143        ..., description="Array of knowledge source objects for the current page."
144    )
145    has_next: bool = Field(
146        ..., description="`true` if a subsequent page exists, `false` if this is the last page."
147    )
148    has_prev: bool = Field(
149        ..., description="`true` if a previous page exists, `false` if this is the first page."
150    )
151    page: int = Field(..., description="Current page number.")
152    page_size: int = Field(..., description="Number of results returned per page.")
153    total_entries: int = Field(
154        ..., description="Total number of knowledge sources matching the query across all pages."
155    )
156    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 AsyncKnowledgeSourceKindResource:
159class AsyncKnowledgeSourceKindResource:
160    def __init__(self, http: HttpClient):
161        self._http = http
162
163    async def list(self) -> KnowledgeSourceKindListResponse:
164        """
165        List creatable knowledge source kinds
166        Returns the fixed set of knowledge source types that can be created directly via
167        `POST /api/v1/knowledge_sources`. Use this endpoint to discover valid values for the
168        `type` param before calling the create endpoint.
169        Source kinds populated by server-driven flows such as `webhook/inbound`,
170        `connectors/*/emails`, and `thread/messages` are intentionally excluded from this
171        list, as they cannot be created through the API.
172
173        Returns:
174            List of knowledge source kinds available for creation via the API.
175        """
176        return await self._http.request(
177            "/api/v1/knowledge_sources/kinds",
178            response_type=KnowledgeSourceKindListResponse,
179        )
AsyncKnowledgeSourceKindResource(http: archastro.platform.runtime.http_client.HttpClient)
160    def __init__(self, http: HttpClient):
161        self._http = http
163    async def list(self) -> KnowledgeSourceKindListResponse:
164        """
165        List creatable knowledge source kinds
166        Returns the fixed set of knowledge source types that can be created directly via
167        `POST /api/v1/knowledge_sources`. Use this endpoint to discover valid values for the
168        `type` param before calling the create endpoint.
169        Source kinds populated by server-driven flows such as `webhook/inbound`,
170        `connectors/*/emails`, and `thread/messages` are intentionally excluded from this
171        list, as they cannot be created through the API.
172
173        Returns:
174            List of knowledge source kinds available for creation via the API.
175        """
176        return await self._http.request(
177            "/api/v1/knowledge_sources/kinds",
178            response_type=KnowledgeSourceKindListResponse,
179        )

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:
182class AsyncKnowledgeSourceResource:
183    def __init__(self, http: HttpClient):
184        self._http = http
185        self.kinds = AsyncKnowledgeSourceKindResource(http)
186
187    async def list(
188        self,
189        *,
190        page: int | None = None,
191        page_size: int | None = None,
192        search: str | None = None,
193        type: str | None = None,
194        installation: str | None = None,
195        agent: str | None = None,
196        org: str | None = None,
197        owner_scope: Literal["any", "individual", "system"] | None = None,
198    ) -> KnowledgeSourceListResponse:
199        """
200        List knowledge sources
201        Returns a paginated list of knowledge sources visible to the authenticated caller.
202        Results are ordered by creation time descending.
203        Use the `type`, `installation`, `agent`, `org`, and `owner_scope` filters to narrow the
204        result set. Combine `owner_scope: "system"` with `org` to list org-level sources that
205        have no individual owner. Combine `owner_scope: "individual"` with `agent` to list
206        sources owned by a specific agent.
207        Pagination is page-number based. The default page size is 25.
208
209        Args:
210            page: Page number to retrieve. Defaults to 1.
211            page_size: Number of knowledge sources to return per page. Defaults to 25.
212            search: Filter sources whose type contains this string. Case-insensitive substring match.
213            type: Exact knowledge source type to filter by, e.g. `"knowledge/documents"`.
214            installation: Installation ID (`ins_...`). Returns only sources associated with this installation.
215            agent: Agent ID (`agt_...`). Returns only sources owned by or associated with this agent.
216            org: Organization ID (`org_...`). Returns only sources belonging to this organization. Combine with `owner_scope: "system"` to retrieve org-level system sources.
217            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).
218
219        Returns:
220            Successful response
221        """
222        query: dict[str, object] = {}
223        if page is not None:
224            query["page"] = page
225        if page_size is not None:
226            query["page_size"] = page_size
227        if search is not None:
228            query["search"] = search
229        if type is not None:
230            query["type"] = type
231        if installation is not None:
232            query["installation"] = installation
233        if agent is not None:
234            query["agent"] = agent
235        if org is not None:
236            query["org"] = org
237        if owner_scope is not None:
238            query["owner_scope"] = owner_scope
239        return await self._http.request(
240            "/api/v1/knowledge_sources",
241            query=query,
242            response_type=KnowledgeSourceListResponse,
243        )
244
245    async def create(self, input: KnowledgeSourceCreateInput) -> KnowledgeSource:
246        """
247        Create a knowledge source
248        Creates a new knowledge source of the requested type and returns the created object.
249        Only types listed by `GET /api/v1/knowledge_sources/kinds` may be created through this
250        endpoint. Other source types such as `webhook/inbound`, `connectors/*/emails`, and
251        `thread/messages` are provisioned automatically by server-driven flows (webhook
252        auto-provisioning, installation activation, connector lifecycle events) and cannot be
253        created directly via the API.
254        Exactly one of `team`, `user`, `agent`, or `org` must identify the owner of the new
255        source. Omit `org` when an individual owner (`team`, `user`, or `agent`) is supplied;
256        include `org` alone for org-level system-owned sources.
257
258        Args:
259            input: Request body.
260            input.agent: Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`.
261            input.metadata: Arbitrary key-value metadata to attach to the source. Returned as-is on reads.
262            input.org: Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`).
263            input.parent_source: Parent knowledge source ID (`ksrc_...`). Use to create a child source.
264            input.payload: Type-specific configuration for the source. Shape depends on `type`.
265            input.state: Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.
266            input.team: Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`.
267            input.thread: Thread ID (`thr_...`) to associate this source with, if applicable.
268            input.type: Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`.
269            input.user: User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`.
270
271        Returns:
272            The newly created knowledge source.
273        """
274        return await self._http.request(
275            "/api/v1/knowledge_sources",
276            method="POST",
277            body=input,
278            response_type=KnowledgeSource,
279        )
280
281    async def delete(self, source: str) -> None:
282        """
283        Delete a knowledge source
284        Permanently deletes the knowledge source identified by `source`. This action is
285        irreversible all documents, embeddings, and ingestion history associated with the
286        source are removed.
287        The authenticated caller must own the source or have sufficient permissions within its
288        parent organization. Returns `204 No Content` on success.
289
290        Args:
291            source: Knowledge source ID (`ksrc_...`) to delete.
292
293        Returns:
294            Empty response. The source has been permanently deleted.
295        """
296        await self._http.request(f"/api/v1/knowledge_sources/{source}", method="DELETE")
297
298    async def get(self, source: str) -> KnowledgeSource:
299        """
300        Retrieve a knowledge source
301        Returns the knowledge source identified by `source`. The authenticated caller must have
302        access to the source's parent organization or be the individual owner of the source.
303        Use the list endpoint to retrieve many sources at once or to discover sources by type
304        or owner.
305
306        Args:
307            source: Knowledge source ID (`ksrc_...`) to retrieve.
308
309        Returns:
310            The requested knowledge source.
311        """
312        return await self._http.request(
313            f"/api/v1/knowledge_sources/{source}",
314            response_type=KnowledgeSource,
315        )
316
317    async def update(self, source: str, input: KnowledgeSourceUpdateInput) -> KnowledgeSource:
318        """
319        Update a knowledge source
320        Updates the mutable fields of an existing knowledge source and returns the updated
321        object. Only fields provided in the request body are changed; omitted fields retain
322        their current values.
323        You can update the type-specific `payload`, the `metadata` map, and the `state`. To
324        pause a source and prevent automatic ingestion, set `state` to `"paused"`. To resume,
325        set it back to `"active"`.
326
327        Args:
328            source: Knowledge source ID (`ksrc_...`) to update.
329            input: Request body.
330            input.metadata: Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided.
331            input.payload: Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided.
332            input.state: Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.
333
334        Returns:
335            The updated knowledge source.
336        """
337        return await self._http.request(
338            f"/api/v1/knowledge_sources/{source}",
339            method="PATCH",
340            body=input,
341            response_type=KnowledgeSource,
342        )
343
344    async def ingest(self, source: str, input: KnowledgeSourceIngestInput) -> ContextIngestion:
345        """
346        Trigger ingestion on a knowledge source
347        Starts an ingestion run on the specified knowledge source and returns the ingestion
348        object. Exactly one of two modes must be chosen per request:
349        **Push mode** (`file` or `content`) available for `knowledge/documents` sources only.
350        Supply the document bytes either as a reference to an already-uploaded file (`file`) or
351        as an inline blob (`content`). The runner stores the bytes and indexes the resulting
352        document. `title` and `metadata` are persisted on the document in push mode.
353        **Pull mode** (`pull: true`) re-triggers ingestion using the source's own configured
354        data. Use this to re-scrape a `scrape/site`, re-fetch a `web/link`, or re-process a
355        `file/document`. Not valid for `knowledge/documents` (which has no upstream push new
356        bytes instead) or for source kinds populated by server-driven flows. `title` and
357        `metadata` are ignored in pull mode.
358        If an ingestion is already active for the source, the existing ingestion is returned
359        rather than creating a duplicate.
360
361        Args:
362            source: Knowledge source ID (`ksrc_...`) to ingest.
363            input: Request body.
364            input.content: Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`.
365            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`.
366            input.metadata: Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`.
367            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.
368            input.title: Display title for the ingested document. Applied in push mode only; ignored when `pull: true`.
369
370        Returns:
371            The created ingestion, or an existing active ingestion if one is already running.
372        """
373        return await self._http.request(
374            f"/api/v1/knowledge_sources/{source}/ingest",
375            method="POST",
376            body=input,
377            response_type=ContextIngestion,
378        )
AsyncKnowledgeSourceResource(http: archastro.platform.runtime.http_client.HttpClient)
183    def __init__(self, http: HttpClient):
184        self._http = http
185        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, installation: str | None = None, agent: str | None = None, org: str | None = None, owner_scope: Optional[Literal['any', 'individual', 'system']] = None) -> KnowledgeSourceListResponse:
187    async def list(
188        self,
189        *,
190        page: int | None = None,
191        page_size: int | None = None,
192        search: str | None = None,
193        type: str | None = None,
194        installation: str | None = None,
195        agent: str | None = None,
196        org: str | None = None,
197        owner_scope: Literal["any", "individual", "system"] | None = None,
198    ) -> KnowledgeSourceListResponse:
199        """
200        List knowledge sources
201        Returns a paginated list of knowledge sources visible to the authenticated caller.
202        Results are ordered by creation time descending.
203        Use the `type`, `installation`, `agent`, `org`, and `owner_scope` filters to narrow the
204        result set. Combine `owner_scope: "system"` with `org` to list org-level sources that
205        have no individual owner. Combine `owner_scope: "individual"` with `agent` to list
206        sources owned by a specific agent.
207        Pagination is page-number based. The default page size is 25.
208
209        Args:
210            page: Page number to retrieve. Defaults to 1.
211            page_size: Number of knowledge sources to return per page. Defaults to 25.
212            search: Filter sources whose type contains this string. Case-insensitive substring match.
213            type: Exact knowledge source type to filter by, e.g. `"knowledge/documents"`.
214            installation: Installation ID (`ins_...`). Returns only sources associated with this installation.
215            agent: Agent ID (`agt_...`). Returns only sources owned by or associated with this agent.
216            org: Organization ID (`org_...`). Returns only sources belonging to this organization. Combine with `owner_scope: "system"` to retrieve org-level system sources.
217            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).
218
219        Returns:
220            Successful response
221        """
222        query: dict[str, object] = {}
223        if page is not None:
224            query["page"] = page
225        if page_size is not None:
226            query["page_size"] = page_size
227        if search is not None:
228            query["search"] = search
229        if type is not None:
230            query["type"] = type
231        if installation is not None:
232            query["installation"] = installation
233        if agent is not None:
234            query["agent"] = agent
235        if org is not None:
236            query["org"] = org
237        if owner_scope is not None:
238            query["owner_scope"] = owner_scope
239        return await self._http.request(
240            "/api/v1/knowledge_sources",
241            query=query,
242            response_type=KnowledgeSourceListResponse,
243        )

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".
  • 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:
245    async def create(self, input: KnowledgeSourceCreateInput) -> KnowledgeSource:
246        """
247        Create a knowledge source
248        Creates a new knowledge source of the requested type and returns the created object.
249        Only types listed by `GET /api/v1/knowledge_sources/kinds` may be created through this
250        endpoint. Other source types such as `webhook/inbound`, `connectors/*/emails`, and
251        `thread/messages` are provisioned automatically by server-driven flows (webhook
252        auto-provisioning, installation activation, connector lifecycle events) and cannot be
253        created directly via the API.
254        Exactly one of `team`, `user`, `agent`, or `org` must identify the owner of the new
255        source. Omit `org` when an individual owner (`team`, `user`, or `agent`) is supplied;
256        include `org` alone for org-level system-owned sources.
257
258        Args:
259            input: Request body.
260            input.agent: Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`.
261            input.metadata: Arbitrary key-value metadata to attach to the source. Returned as-is on reads.
262            input.org: Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`).
263            input.parent_source: Parent knowledge source ID (`ksrc_...`). Use to create a child source.
264            input.payload: Type-specific configuration for the source. Shape depends on `type`.
265            input.state: Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.
266            input.team: Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`.
267            input.thread: Thread ID (`thr_...`) to associate this source with, if applicable.
268            input.type: Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`.
269            input.user: User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`.
270
271        Returns:
272            The newly created knowledge source.
273        """
274        return await self._http.request(
275            "/api/v1/knowledge_sources",
276            method="POST",
277            body=input,
278            response_type=KnowledgeSource,
279        )

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:
281    async def delete(self, source: str) -> None:
282        """
283        Delete a knowledge source
284        Permanently deletes the knowledge source identified by `source`. This action is
285        irreversible all documents, embeddings, and ingestion history associated with the
286        source are removed.
287        The authenticated caller must own the source or have sufficient permissions within its
288        parent organization. Returns `204 No Content` on success.
289
290        Args:
291            source: Knowledge source ID (`ksrc_...`) to delete.
292
293        Returns:
294            Empty response. The source has been permanently deleted.
295        """
296        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:
298    async def get(self, source: str) -> KnowledgeSource:
299        """
300        Retrieve a knowledge source
301        Returns the knowledge source identified by `source`. The authenticated caller must have
302        access to the source's parent organization or be the individual owner of the source.
303        Use the list endpoint to retrieve many sources at once or to discover sources by type
304        or owner.
305
306        Args:
307            source: Knowledge source ID (`ksrc_...`) to retrieve.
308
309        Returns:
310            The requested knowledge source.
311        """
312        return await self._http.request(
313            f"/api/v1/knowledge_sources/{source}",
314            response_type=KnowledgeSource,
315        )

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:
317    async def update(self, source: str, input: KnowledgeSourceUpdateInput) -> KnowledgeSource:
318        """
319        Update a knowledge source
320        Updates the mutable fields of an existing knowledge source and returns the updated
321        object. Only fields provided in the request body are changed; omitted fields retain
322        their current values.
323        You can update the type-specific `payload`, the `metadata` map, and the `state`. To
324        pause a source and prevent automatic ingestion, set `state` to `"paused"`. To resume,
325        set it back to `"active"`.
326
327        Args:
328            source: Knowledge source ID (`ksrc_...`) to update.
329            input: Request body.
330            input.metadata: Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided.
331            input.payload: Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided.
332            input.state: Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.
333
334        Returns:
335            The updated knowledge source.
336        """
337        return await self._http.request(
338            f"/api/v1/knowledge_sources/{source}",
339            method="PATCH",
340            body=input,
341            response_type=KnowledgeSource,
342        )

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:
344    async def ingest(self, source: str, input: KnowledgeSourceIngestInput) -> ContextIngestion:
345        """
346        Trigger ingestion on a knowledge source
347        Starts an ingestion run on the specified knowledge source and returns the ingestion
348        object. Exactly one of two modes must be chosen per request:
349        **Push mode** (`file` or `content`) available for `knowledge/documents` sources only.
350        Supply the document bytes either as a reference to an already-uploaded file (`file`) or
351        as an inline blob (`content`). The runner stores the bytes and indexes the resulting
352        document. `title` and `metadata` are persisted on the document in push mode.
353        **Pull mode** (`pull: true`) re-triggers ingestion using the source's own configured
354        data. Use this to re-scrape a `scrape/site`, re-fetch a `web/link`, or re-process a
355        `file/document`. Not valid for `knowledge/documents` (which has no upstream push new
356        bytes instead) or for source kinds populated by server-driven flows. `title` and
357        `metadata` are ignored in pull mode.
358        If an ingestion is already active for the source, the existing ingestion is returned
359        rather than creating a duplicate.
360
361        Args:
362            source: Knowledge source ID (`ksrc_...`) to ingest.
363            input: Request body.
364            input.content: Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`.
365            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`.
366            input.metadata: Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`.
367            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.
368            input.title: Display title for the ingested document. Applied in push mode only; ignored when `pull: true`.
369
370        Returns:
371            The created ingestion, or an existing active ingestion if one is already running.
372        """
373        return await self._http.request(
374            f"/api/v1/knowledge_sources/{source}/ingest",
375            method="POST",
376            body=input,
377            response_type=ContextIngestion,
378        )

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

class KnowledgeSourceKindResource:
381class KnowledgeSourceKindResource:
382    def __init__(self, http: SyncHttpClient):
383        self._http = http
384
385    def list(self) -> KnowledgeSourceKindListResponse:
386        """
387        List creatable knowledge source kinds
388        Returns the fixed set of knowledge source types that can be created directly via
389        `POST /api/v1/knowledge_sources`. Use this endpoint to discover valid values for the
390        `type` param before calling the create endpoint.
391        Source kinds populated by server-driven flows such as `webhook/inbound`,
392        `connectors/*/emails`, and `thread/messages` are intentionally excluded from this
393        list, as they cannot be created through the API.
394
395        Returns:
396            List of knowledge source kinds available for creation via the API.
397        """
398        return self._http.request(
399            "/api/v1/knowledge_sources/kinds",
400            response_type=KnowledgeSourceKindListResponse,
401        )
KnowledgeSourceKindResource(http: archastro.platform.runtime.http_client.SyncHttpClient)
382    def __init__(self, http: SyncHttpClient):
383        self._http = http
385    def list(self) -> KnowledgeSourceKindListResponse:
386        """
387        List creatable knowledge source kinds
388        Returns the fixed set of knowledge source types that can be created directly via
389        `POST /api/v1/knowledge_sources`. Use this endpoint to discover valid values for the
390        `type` param before calling the create endpoint.
391        Source kinds populated by server-driven flows such as `webhook/inbound`,
392        `connectors/*/emails`, and `thread/messages` are intentionally excluded from this
393        list, as they cannot be created through the API.
394
395        Returns:
396            List of knowledge source kinds available for creation via the API.
397        """
398        return self._http.request(
399            "/api/v1/knowledge_sources/kinds",
400            response_type=KnowledgeSourceKindListResponse,
401        )

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:
404class KnowledgeSourceResource:
405    def __init__(self, http: SyncHttpClient):
406        self._http = http
407        self.kinds = KnowledgeSourceKindResource(http)
408
409    def list(
410        self,
411        *,
412        page: int | None = None,
413        page_size: int | None = None,
414        search: str | None = None,
415        type: str | None = None,
416        installation: str | None = None,
417        agent: str | None = None,
418        org: str | None = None,
419        owner_scope: Literal["any", "individual", "system"] | None = None,
420    ) -> KnowledgeSourceListResponse:
421        """
422        List knowledge sources
423        Returns a paginated list of knowledge sources visible to the authenticated caller.
424        Results are ordered by creation time descending.
425        Use the `type`, `installation`, `agent`, `org`, and `owner_scope` filters to narrow the
426        result set. Combine `owner_scope: "system"` with `org` to list org-level sources that
427        have no individual owner. Combine `owner_scope: "individual"` with `agent` to list
428        sources owned by a specific agent.
429        Pagination is page-number based. The default page size is 25.
430
431        Args:
432            page: Page number to retrieve. Defaults to 1.
433            page_size: Number of knowledge sources to return per page. Defaults to 25.
434            search: Filter sources whose type contains this string. Case-insensitive substring match.
435            type: Exact knowledge source type to filter by, e.g. `"knowledge/documents"`.
436            installation: Installation ID (`ins_...`). Returns only sources associated with this installation.
437            agent: Agent ID (`agt_...`). Returns only sources owned by or associated with this agent.
438            org: Organization ID (`org_...`). Returns only sources belonging to this organization. Combine with `owner_scope: "system"` to retrieve org-level system sources.
439            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).
440
441        Returns:
442            Successful response
443        """
444        query: dict[str, object] = {}
445        if page is not None:
446            query["page"] = page
447        if page_size is not None:
448            query["page_size"] = page_size
449        if search is not None:
450            query["search"] = search
451        if type is not None:
452            query["type"] = type
453        if installation is not None:
454            query["installation"] = installation
455        if agent is not None:
456            query["agent"] = agent
457        if org is not None:
458            query["org"] = org
459        if owner_scope is not None:
460            query["owner_scope"] = owner_scope
461        return self._http.request(
462            "/api/v1/knowledge_sources",
463            query=query,
464            response_type=KnowledgeSourceListResponse,
465        )
466
467    def create(self, input: KnowledgeSourceCreateInput) -> KnowledgeSource:
468        """
469        Create a knowledge source
470        Creates a new knowledge source of the requested type and returns the created object.
471        Only types listed by `GET /api/v1/knowledge_sources/kinds` may be created through this
472        endpoint. Other source types such as `webhook/inbound`, `connectors/*/emails`, and
473        `thread/messages` are provisioned automatically by server-driven flows (webhook
474        auto-provisioning, installation activation, connector lifecycle events) and cannot be
475        created directly via the API.
476        Exactly one of `team`, `user`, `agent`, or `org` must identify the owner of the new
477        source. Omit `org` when an individual owner (`team`, `user`, or `agent`) is supplied;
478        include `org` alone for org-level system-owned sources.
479
480        Args:
481            input: Request body.
482            input.agent: Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`.
483            input.metadata: Arbitrary key-value metadata to attach to the source. Returned as-is on reads.
484            input.org: Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`).
485            input.parent_source: Parent knowledge source ID (`ksrc_...`). Use to create a child source.
486            input.payload: Type-specific configuration for the source. Shape depends on `type`.
487            input.state: Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.
488            input.team: Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`.
489            input.thread: Thread ID (`thr_...`) to associate this source with, if applicable.
490            input.type: Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`.
491            input.user: User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`.
492
493        Returns:
494            The newly created knowledge source.
495        """
496        return self._http.request(
497            "/api/v1/knowledge_sources",
498            method="POST",
499            body=input,
500            response_type=KnowledgeSource,
501        )
502
503    def delete(self, source: str) -> None:
504        """
505        Delete a knowledge source
506        Permanently deletes the knowledge source identified by `source`. This action is
507        irreversible all documents, embeddings, and ingestion history associated with the
508        source are removed.
509        The authenticated caller must own the source or have sufficient permissions within its
510        parent organization. Returns `204 No Content` on success.
511
512        Args:
513            source: Knowledge source ID (`ksrc_...`) to delete.
514
515        Returns:
516            Empty response. The source has been permanently deleted.
517        """
518        self._http.request(f"/api/v1/knowledge_sources/{source}", method="DELETE")
519
520    def get(self, source: str) -> KnowledgeSource:
521        """
522        Retrieve a knowledge source
523        Returns the knowledge source identified by `source`. The authenticated caller must have
524        access to the source's parent organization or be the individual owner of the source.
525        Use the list endpoint to retrieve many sources at once or to discover sources by type
526        or owner.
527
528        Args:
529            source: Knowledge source ID (`ksrc_...`) to retrieve.
530
531        Returns:
532            The requested knowledge source.
533        """
534        return self._http.request(
535            f"/api/v1/knowledge_sources/{source}",
536            response_type=KnowledgeSource,
537        )
538
539    def update(self, source: str, input: KnowledgeSourceUpdateInput) -> KnowledgeSource:
540        """
541        Update a knowledge source
542        Updates the mutable fields of an existing knowledge source and returns the updated
543        object. Only fields provided in the request body are changed; omitted fields retain
544        their current values.
545        You can update the type-specific `payload`, the `metadata` map, and the `state`. To
546        pause a source and prevent automatic ingestion, set `state` to `"paused"`. To resume,
547        set it back to `"active"`.
548
549        Args:
550            source: Knowledge source ID (`ksrc_...`) to update.
551            input: Request body.
552            input.metadata: Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided.
553            input.payload: Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided.
554            input.state: Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.
555
556        Returns:
557            The updated knowledge source.
558        """
559        return self._http.request(
560            f"/api/v1/knowledge_sources/{source}",
561            method="PATCH",
562            body=input,
563            response_type=KnowledgeSource,
564        )
565
566    def ingest(self, source: str, input: KnowledgeSourceIngestInput) -> ContextIngestion:
567        """
568        Trigger ingestion on a knowledge source
569        Starts an ingestion run on the specified knowledge source and returns the ingestion
570        object. Exactly one of two modes must be chosen per request:
571        **Push mode** (`file` or `content`) available for `knowledge/documents` sources only.
572        Supply the document bytes either as a reference to an already-uploaded file (`file`) or
573        as an inline blob (`content`). The runner stores the bytes and indexes the resulting
574        document. `title` and `metadata` are persisted on the document in push mode.
575        **Pull mode** (`pull: true`) re-triggers ingestion using the source's own configured
576        data. Use this to re-scrape a `scrape/site`, re-fetch a `web/link`, or re-process a
577        `file/document`. Not valid for `knowledge/documents` (which has no upstream push new
578        bytes instead) or for source kinds populated by server-driven flows. `title` and
579        `metadata` are ignored in pull mode.
580        If an ingestion is already active for the source, the existing ingestion is returned
581        rather than creating a duplicate.
582
583        Args:
584            source: Knowledge source ID (`ksrc_...`) to ingest.
585            input: Request body.
586            input.content: Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`.
587            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`.
588            input.metadata: Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`.
589            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.
590            input.title: Display title for the ingested document. Applied in push mode only; ignored when `pull: true`.
591
592        Returns:
593            The created ingestion, or an existing active ingestion if one is already running.
594        """
595        return self._http.request(
596            f"/api/v1/knowledge_sources/{source}/ingest",
597            method="POST",
598            body=input,
599            response_type=ContextIngestion,
600        )
KnowledgeSourceResource(http: archastro.platform.runtime.http_client.SyncHttpClient)
405    def __init__(self, http: SyncHttpClient):
406        self._http = http
407        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, installation: str | None = None, agent: str | None = None, org: str | None = None, owner_scope: Optional[Literal['any', 'individual', 'system']] = None) -> KnowledgeSourceListResponse:
409    def list(
410        self,
411        *,
412        page: int | None = None,
413        page_size: int | None = None,
414        search: str | None = None,
415        type: str | None = None,
416        installation: str | None = None,
417        agent: str | None = None,
418        org: str | None = None,
419        owner_scope: Literal["any", "individual", "system"] | None = None,
420    ) -> KnowledgeSourceListResponse:
421        """
422        List knowledge sources
423        Returns a paginated list of knowledge sources visible to the authenticated caller.
424        Results are ordered by creation time descending.
425        Use the `type`, `installation`, `agent`, `org`, and `owner_scope` filters to narrow the
426        result set. Combine `owner_scope: "system"` with `org` to list org-level sources that
427        have no individual owner. Combine `owner_scope: "individual"` with `agent` to list
428        sources owned by a specific agent.
429        Pagination is page-number based. The default page size is 25.
430
431        Args:
432            page: Page number to retrieve. Defaults to 1.
433            page_size: Number of knowledge sources to return per page. Defaults to 25.
434            search: Filter sources whose type contains this string. Case-insensitive substring match.
435            type: Exact knowledge source type to filter by, e.g. `"knowledge/documents"`.
436            installation: Installation ID (`ins_...`). Returns only sources associated with this installation.
437            agent: Agent ID (`agt_...`). Returns only sources owned by or associated with this agent.
438            org: Organization ID (`org_...`). Returns only sources belonging to this organization. Combine with `owner_scope: "system"` to retrieve org-level system sources.
439            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).
440
441        Returns:
442            Successful response
443        """
444        query: dict[str, object] = {}
445        if page is not None:
446            query["page"] = page
447        if page_size is not None:
448            query["page_size"] = page_size
449        if search is not None:
450            query["search"] = search
451        if type is not None:
452            query["type"] = type
453        if installation is not None:
454            query["installation"] = installation
455        if agent is not None:
456            query["agent"] = agent
457        if org is not None:
458            query["org"] = org
459        if owner_scope is not None:
460            query["owner_scope"] = owner_scope
461        return self._http.request(
462            "/api/v1/knowledge_sources",
463            query=query,
464            response_type=KnowledgeSourceListResponse,
465        )

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".
  • 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

467    def create(self, input: KnowledgeSourceCreateInput) -> KnowledgeSource:
468        """
469        Create a knowledge source
470        Creates a new knowledge source of the requested type and returns the created object.
471        Only types listed by `GET /api/v1/knowledge_sources/kinds` may be created through this
472        endpoint. Other source types such as `webhook/inbound`, `connectors/*/emails`, and
473        `thread/messages` are provisioned automatically by server-driven flows (webhook
474        auto-provisioning, installation activation, connector lifecycle events) and cannot be
475        created directly via the API.
476        Exactly one of `team`, `user`, `agent`, or `org` must identify the owner of the new
477        source. Omit `org` when an individual owner (`team`, `user`, or `agent`) is supplied;
478        include `org` alone for org-level system-owned sources.
479
480        Args:
481            input: Request body.
482            input.agent: Agent ID (`agt_...`) that owns this source. Mutually exclusive with `team` and `user`.
483            input.metadata: Arbitrary key-value metadata to attach to the source. Returned as-is on reads.
484            input.org: Organization ID (`org_...`). Required for system-owned sources that have no individual owner (`team`, `user`, or `agent`).
485            input.parent_source: Parent knowledge source ID (`ksrc_...`). Use to create a child source.
486            input.payload: Type-specific configuration for the source. Shape depends on `type`.
487            input.state: Initial state of the source. One of `"active"` (default) or `"paused"`. Paused sources do not trigger ingestion automatically.
488            input.team: Team ID (`team_...`) that owns this source. Mutually exclusive with `user` and `agent`.
489            input.thread: Thread ID (`thr_...`) to associate this source with, if applicable.
490            input.type: Knowledge source type. Must be one of the values returned by `GET /api/v1/knowledge_sources/kinds`.
491            input.user: User ID (`usr_...`) that owns this source. Mutually exclusive with `team` and `agent`.
492
493        Returns:
494            The newly created knowledge source.
495        """
496        return self._http.request(
497            "/api/v1/knowledge_sources",
498            method="POST",
499            body=input,
500            response_type=KnowledgeSource,
501        )

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:
503    def delete(self, source: str) -> None:
504        """
505        Delete a knowledge source
506        Permanently deletes the knowledge source identified by `source`. This action is
507        irreversible all documents, embeddings, and ingestion history associated with the
508        source are removed.
509        The authenticated caller must own the source or have sufficient permissions within its
510        parent organization. Returns `204 No Content` on success.
511
512        Args:
513            source: Knowledge source ID (`ksrc_...`) to delete.
514
515        Returns:
516            Empty response. The source has been permanently deleted.
517        """
518        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:
520    def get(self, source: str) -> KnowledgeSource:
521        """
522        Retrieve a knowledge source
523        Returns the knowledge source identified by `source`. The authenticated caller must have
524        access to the source's parent organization or be the individual owner of the source.
525        Use the list endpoint to retrieve many sources at once or to discover sources by type
526        or owner.
527
528        Args:
529            source: Knowledge source ID (`ksrc_...`) to retrieve.
530
531        Returns:
532            The requested knowledge source.
533        """
534        return self._http.request(
535            f"/api/v1/knowledge_sources/{source}",
536            response_type=KnowledgeSource,
537        )

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:
539    def update(self, source: str, input: KnowledgeSourceUpdateInput) -> KnowledgeSource:
540        """
541        Update a knowledge source
542        Updates the mutable fields of an existing knowledge source and returns the updated
543        object. Only fields provided in the request body are changed; omitted fields retain
544        their current values.
545        You can update the type-specific `payload`, the `metadata` map, and the `state`. To
546        pause a source and prevent automatic ingestion, set `state` to `"paused"`. To resume,
547        set it back to `"active"`.
548
549        Args:
550            source: Knowledge source ID (`ksrc_...`) to update.
551            input: Request body.
552            input.metadata: Arbitrary key-value metadata to attach to the source. Replaces the entire existing `metadata` map when provided.
553            input.payload: Type-specific configuration to replace on the source. Shape depends on the source `type`. Replaces the entire existing `payload` when provided.
554            input.state: Desired state of the source. One of `"active"` or `"paused"`. Paused sources do not trigger ingestion automatically.
555
556        Returns:
557            The updated knowledge source.
558        """
559        return self._http.request(
560            f"/api/v1/knowledge_sources/{source}",
561            method="PATCH",
562            body=input,
563            response_type=KnowledgeSource,
564        )

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:
566    def ingest(self, source: str, input: KnowledgeSourceIngestInput) -> ContextIngestion:
567        """
568        Trigger ingestion on a knowledge source
569        Starts an ingestion run on the specified knowledge source and returns the ingestion
570        object. Exactly one of two modes must be chosen per request:
571        **Push mode** (`file` or `content`) available for `knowledge/documents` sources only.
572        Supply the document bytes either as a reference to an already-uploaded file (`file`) or
573        as an inline blob (`content`). The runner stores the bytes and indexes the resulting
574        document. `title` and `metadata` are persisted on the document in push mode.
575        **Pull mode** (`pull: true`) re-triggers ingestion using the source's own configured
576        data. Use this to re-scrape a `scrape/site`, re-fetch a `web/link`, or re-process a
577        `file/document`. Not valid for `knowledge/documents` (which has no upstream push new
578        bytes instead) or for source kinds populated by server-driven flows. `title` and
579        `metadata` are ignored in pull mode.
580        If an ingestion is already active for the source, the existing ingestion is returned
581        rather than creating a duplicate.
582
583        Args:
584            source: Knowledge source ID (`ksrc_...`) to ingest.
585            input: Request body.
586            input.content: Inline document bytes to push to the source. Mutually exclusive with `file` and `pull`.
587            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`.
588            input.metadata: Arbitrary key-value metadata to attach to the ingested document. Applied in push mode only; ignored when `pull: true`.
589            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.
590            input.title: Display title for the ingested document. Applied in push mode only; ignored when `pull: true`.
591
592        Returns:
593            The created ingestion, or an existing active ingestion if one is already running.
594        """
595        return self._http.request(
596            f"/api/v1/knowledge_sources/{source}/ingest",
597            method="POST",
598            body=input,
599            response_type=ContextIngestion,
600        )

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