Create Document by Text
Creates a document in a knowledge base from raw text. Indexing runs asynchronously; track it with the returned batch ID via Get Document Indexing Status.
Authorizations
Every request authenticates with an API key: Authorization: Bearer {API_KEY}. App endpoints take an app API key; knowledge endpoints take a knowledge base API key (Get Started).
Keep keys server-side; never embed them in client code. Requests with a missing or invalid key fail with HTTP 401 (unauthorized).
Path Parameters
Knowledge base ID, from List Knowledge Bases. For a scoped key, copy the ID from the Dify URL.
Body
Document text content.
Required when adding the first document to a knowledge base. Subsequent documents inherit the knowledge base's indexing technique if omitted. high_quality uses embedding models for precise search; economy uses keyword-based indexing.
high_quality, economy Embedding model name. Use the model field from Get Available Models with model_type=text-embedding.
Embedding model provider. Use the provider field from Get Available Models with model_type=text-embedding.
Original document ID for versioning. Get it from List Documents.