POST /context/ingest, both are saved in a collection, both are indexed in the background, and both come back from POST /query. Each item you ingest is a source; HydraDB splits it into searchable passages called chunks and builds a context graph from it.
They are stored separately, so a query chooses what to read: type: "knowledge", type: "memory", or type: "all" for both in one ranked list. A support agent, for example, answers from the help center (knowledge) and from the fact that this customer already tried restarting (a memory).
1. Ingest knowledge
There are three ways to ingest knowledge:- Files: upload PDF, DOCX, Markdown, CSV, or TXT files, and HydraDB reads them for you.
- App sources: send records your application already holds from an app, such as a Slack message or a Jira ticket.
- Connectors: connect an app such as Slack, Google Drive, Notion, or GitHub once, and HydraDB keeps it in sync.
Upload files
The request is multipart/form-data with these fields:Upload files: Python, TypeScript, or cURL
Upload files: Python, TypeScript, or cURL
data.results with its id and a status of queued. The payload is wrapped in the standard envelope, so read it from response.data:document_metadata item takes these properties:
title, type, url, and timestamp, returns 400. Ingest Context lists the supported file formats.
Send app sources
When your application already holds the text of a Slack message, a Jira ticket, a Notion page, or a CRM record, send that text as a plain-text file. You do not need a file on disk: build the file in memory and upload it indocuments, as in Upload files.
Put the record’s details in its document_metadata item: your ID for it in id, and app details such as the channel, the provider’s ID, or the author in additional_metadata. To filter on a value with top-level metadata_filters, send it in metadata instead, after you declare its key in the database’s metadata schema; an undeclared metadata key returns 400. To link it to other records, such as the rest of its thread, use relations (see Link sources that belong together). A file upload cannot carry an acl, so upload a record this way only when every user of the collection may retrieve it. For a record that only some users may retrieve, see Send a private app record.
Ingest a Slack message: Python, TypeScript, or cURL
Ingest a Slack message: Python, TypeScript, or cURL
data.results.Send a private app record
Send a record that only some users may retrieve as anapp_knowledge item with acl, the list of principals allowed to retrieve it. The acl is stored with the record in the ingest request, so a query that sends a caller outside the list in acl never returns it. The filter applies only when the query sends the caller’s acl: a query that omits acl, or sends [] or ["*"], is not filtered. Send the caller’s identity as acl on every user query, as in Query on behalf of a user. Do not upload the record as a file and set acl later: until that update succeeds, any query can return the record.
app_knowledge is a JSON string on the same endpoint, in place of documents. kind says what the record is (email, message, ticket, knowledge_base, comment, meeting, or custom), and fields carries its content; fields.kind must equal kind.
Ingest a private Slack message: Python, TypeScript, or cURL
Ingest a private Slack message: Python, TypeScript, or cURL
data.results. A query with "acl": ["grace@acme.com"] can return the record; a query with any other caller’s acl cannot.2. Save memories
HydraDB does not capture memories on its own: your application saves one when a user states a preference, makes a decision, finishes a task, or corrects the agent. Give each user their own collection, such asuser_john_123, and send it on every ingest, status check, and query. Your backend picks it from the signed-in session; the name itself does not authenticate anyone.
The request is the same as for knowledge, with type=memory and a memories list in place of files:
Save a memory: Python, TypeScript, or cURL
Save a memory: Python, TypeScript, or cURL
data.results with its id and a status of queued. The payload is wrapped in the standard envelope, so read it from response.data:Let HydraDB infer the memory
infer controls whether HydraDB extracts the memory from what you send or stores it as written.
custom_instructions takes effect only when infer: true. Use it to guide extraction, for example: "Focus on UI and notification preferences only".
Infer a preference from a behavior log: Python, TypeScript, or cURL
Infer a preference from a behavior log: Python, TypeScript, or cURL
POST /query runs with type: "memory" and a query like "what UI settings does the user prefer?", HydraDB can return the inferred preference (for example, "prefers dark mode") rather than the raw event log.If you sent the same input with infer: false, HydraDB would index the event log verbatim. That is useful only when you want to retrieve the log itself.Send text or a conversation
Each memory item takes eithertext or user_assistant_pairs, not both (sending both returns 400).
text: prose of any kind, such as observations, captured facts, meeting notes, or semi-structured records. Setis_markdown: truewhen the content uses Markdown (headings, lists, code blocks) so HydraDB keeps that structure during chunking and embedding.user_assistant_pairs: dialogue, especially when the preference is implied rather than stated. Each pair is{ "user": "...", "assistant": "..." }.
Input shapes: text, Markdown, and user-assistant pairs
Input shapes: text, Markdown, and user-assistant pairs
3. Wait for indexing
Knowledge and memories are indexed the same way, in the background: HydraDB parses each source, splits it into chunks, infers the memory if you asked it to, finds the people, teams, and topics it mentions and how they relate, and builds the search indexes. The ingest request returns202 Accepted with each source’s id.
Poll GET /context/status with those ids and the same collection every few seconds. A source’s indexing_status moves forward through queued, processing, graph_creation, and completed, or lands in errored on failure:
- At
graph_creationthe source becomes searchable within a few seconds, while its graph is still building. A query sent the moment this status appears can miss the source, and a collection that is new can still be reported as not existing. - At
completedthe source and its graph are ready. Wait forcompletedwhen you query straight after ingesting. Most documents complete in 1 to 5 minutes.
Poll until indexed: Python, TypeScript, or cURL
Poll until indexed: Python, TypeScript, or cURL
data payload looks like this:4. Query knowledge and memories together
POST /query reaches each type through the type parameter:
type: "knowledge"(the default) searches files and app sources.type: "memory"searches memories.type: "all"searches both and returns one merged, ranked list.
collections. If some sources carry an acl, also send the caller’s identity as acl. Query covers the other parameters and how to pass the result to a model.
5. Update or delete context
To change a source or a memory, send it again with the sameid. upsert defaults to true, so the saved one is replaced; include everything you want to keep. Wait for the previous ingestion to reach completed or errored before sending the next update for the same id.
To remove one, call DELETE /context with its id and the same collection.
6. Link sources that belong together
Forceful relations are links you declare between knowledge sources when you ingest them. When a query matches a source that has forceful relations, HydraDB returns the linked sources in theadditional_context field of the response, alongside the primary chunks.
This is separate from the context graph HydraDB builds on its own. Use forceful relations for documents that belong together when the text does not say so: a contract and its addendum, or a runbook and its troubleshooting guide. They link whole sources. To declare the entity and relation graph within one document, replacing extraction for it, use Bring Your Own Graph.
Set relations.ids on the source’s document_metadata item. relations.ids is what makes the linked text come back with query results.
Link a runbook to its troubleshooting guide: Python, TypeScript, or cURL
Link a runbook to its troubleshooting guide: Python, TypeScript, or cURL
id auth-troubleshooting. Ingest that page first and wait for completed.query_forceful_relations defaults to true; set it to false to skip the linked sources.
thinking mode only: Forceful relations stay within one store, so pointing a knowledge source at a memory ID silently returns nothing. Linked context is fetched only when mode: "thinking" is set on the query, or when mode: "auto" routes to thinking. In fast mode, query_forceful_relations is ignored even if set to true.7. Keep people who share a name apart
When HydraDB builds the graph from text, it identifies a person by name. Two different people who are both written as “Daniel” become one entity, with the facts of both. If your system already knows who each person is, declare the people a source mentions asentities, with your own ID for each:
contact_101 and contact_202 stay two people even when both are called Daniel. Every source that declares contact_101 adds to the same person. Entities in query results and in Context Relations carry the ID in identifier.
Send entities in additional_metadata on a document_metadata item for a file, or on a memory.
Declare the people in a file: cURL
Declare the people in a file: cURL
id: your own ID for the person, matched exactly.Contact_101andcontact_101are two people, so send each ID the same way every time. At most 256 bytes, with no leading or trailing spaces.name: the name as the text uses it. If the text says “Daniel”, send “Daniel”. At most 256 bytes.- People only: only people are keyed this way. An entry may carry
"type": "PERSON"; any other type is rejected with400. To key companies or other entities by ID, sendgraph_payload. - Declare everyone the source mentions: a mention that HydraDB cannot attribute to exactly one declared person stays under the plain name.
- Limits: at most 50 people per source, and the list counts toward the 1 KiB cap on
additional_metadata. That fits about a dozen people with UUID IDs. - Errors: an entry without an
idor aname, or one ID listed under two names in the same source, is rejected with400. The message names the entry to fix. - Changing the people: send the source again with the same
id.PATCH /context/{id}/metadatarefuses a change toentities, because the graph has to be rebuilt. - Sources you already ingested: they keep their current people until you send them again with
entities.
graph_payload, give each entity an id instead. See Key entities by your own ID.
Field reference
Ingest request fields
Ingest request fields
Memory item fields
Memory item fields
memories is a JSON string. Inside each item, metadata and additional_metadata are plain objects; do not stringify them again.Common mistakes
Related
- Query: search context and pass the result to a model
- Databases and Collections: where context is saved, and how to keep users apart
- Metadata Filters: fields to filter on
- Connectors: keep an app’s knowledge in sync
- Ingest Context: API Reference
