Skip to main content
POST
/
knowledge
Python
import os
from datagrid_ai import Datagrid

client = Datagrid(
    api_key=os.environ.get("DATAGRID_API_KEY"),  # This is the default and can be omitted
)
knowledge = client.knowledge.create(
    files=[b"Example data"],
)
print(knowledge.id)
{
  "object": "knowledge",
  "id": "<string>",
  "name": "<string>",
  "teamspace_id": "<string>",
  "scope": "teamspace",
  "parent": {
    "type": "page",
    "page_id": "<string>"
  },
  "created_at": "2023-11-07T05:31:56Z",
  "status": "pending",
  "last_error": {
    "code": "out_of_credits",
    "message": "<string>"
  },
  "row_counts": {
    "total": 123,
    "completed": 123,
    "failed": 123
  },
  "credits": {
    "consumed": 123
  },
  "sync": {
    "connection_id": "config_123abc",
    "enabled": true,
    "trigger": {
      "type": "cron",
      "cron_expression": "0 0 * * *",
      "timezone": "America/New_York",
      "description": "<string>"
    }
  },
  "updated_at": "2023-11-07T05:31:56Z"
}

Documentation Index

Fetch the complete documentation index at: https://developers.datagrid.com/llms.txt

Use this file to discover all available pages before exploring further.

Upload size limits

Each file must be within your plan’s per-file size cap. If a file is too large, the API returns 413 (payload_too_large) with guidance and a link to Knowledge upload limits.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

multipart/form-data
files
file[]
required

The files to be uploaded and learned. Supported media types are pdf, json, csv, text, png, jpeg, excel, google sheets, docx, pptx.

name
string | null

The name of the knowledge.

parent
object

The parent page reference, indicating where this page is nested

Response

Successfully created knowledge

The knowledge object represents knowledge that an agent may leverage to respond.

object
enum<string>
required

The object type, which is always knowledge.

Available options:
knowledge
id
string
required

The knowledge identifier, which can be referenced in the API endpoints.

name
string
required

The name of the knowledge.

teamspace_id
string
required

The ID of the teamspace that owns this knowledge.

scope
enum<string>
required

The visibility scope of the knowledge. 'teamspace' means visible only within the owning teamspace. 'organization' means visible across all teamspaces in the same organization.

Available options:
teamspace,
organization
parent
object
required

The parent page reference, indicating where this page is nested

created_at
string<date-time>
required

The ISO string for when the knowledge was created.

status
enum<string>
required

The current knowledge status. pending indicates that processing has started but no rows have been learned yet. partial indicates that some rows are available, but processing is either still running or ended with incomplete results. ready indicates that processing finished successfully and the knowledge is fully available. failed indicates that no rows are currently available and the knowledge reached a terminal failure state, either because the latest asynchronous processing or re-index run ended unsuccessfully before any rows became available, or because every row ended in a persistent failed state.

Available options:
pending,
partial,
ready,
failed
last_error
object
required

The last terminal processing error for this knowledge, if any. Present when the latest asynchronous processing or re-index run ended unsuccessfully; null when the knowledge is failed only because every row ended in a persistent failed state.

row_counts
object
required

Row count statistics for the knowledge.

credits
object
required

Credit consumption for this knowledge. null when the knowledge is still being processed and the final cost is not yet known (e.g. immediately after creation or reindexing), or when the credit lookup fails. When present, consumed is the current summed spend for the knowledge's active tables — it is not necessarily the cost of the most recent request, nor the full lifetime spend.

sync
object
required

Sync information for knowledge that syncs data from a connection

updated_at
string<date-time>

The ISO string for when the knowledge was last updated.