Skip to main content
Context is everything you give HydraDB so your AI can find it later. It comes in two types, and most applications use both: The two types work the same way. Both go to 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:
Set up your SDK client before running the Python or TypeScript example.
The response lists each file in data.results with its id and a status of queued. The payload is wrapped in the standard envelope, so read it from response.data:
Each document_metadata item takes these properties: The key list is closed. Any other key, including 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 in documents, 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.
The response is the same as for a file upload, with one entry in data.results.

Send a private app record

Send a record that only some users may retrieve as an app_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.
The response is the same as for a file upload, with one entry in 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 as user_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:
Set up your SDK client before running the Python or TypeScript example.
The response lists each memory in 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".
A user has been toggling dark mode in your application. Instead of extracting the preference yourself, send the raw behavior log and let HydraDB infer the memory.
Later, when 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 either text 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. Set is_markdown: true when 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": "..." }.
Markdown notes, stored as written:
A plain statement, with the preference extracted:
A conversation, with the preference extracted:

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 returns 202 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_creation the 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 completed the source and its graph are ready. Wait for completed when you query straight after ingesting. Most documents complete in 1 to 5 minutes.
Ingestion Status has the full status table. To skip polling, register a webhook.
Each status in the 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.
Both types are read from the collections you name. Shared knowledge usually lives in one collection and each user’s memories in their own, so list both in 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.
Knowledge and memories come back together in data.chunks, ranked as one list. To let the user’s memories outrank the shared documents, send weights instead of a list:

5. Update or delete context

To change a source or a memory, send it again with the same id. 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. 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 the additional_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.
query_forceful_relations defaults to true; set it to false to skip the linked sources.
Knowledge 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 as entities, with your own ID for each:
HydraDB still extracts the facts from the text. Each mention it can attribute to one declared person goes on that person’s ID, so 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.
cURL
To search only what mentions one person, filter on the ID:
  • id: your own ID for the person, matched exactly. Contact_101 and contact_101 are 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 with 400. To key companies or other entities by ID, send graph_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 id or a name, or one ID listed under two names in the same source, is rejected with 400. The message names the entry to fix.
  • Changing the people: send the source again with the same id. PATCH /context/{id}/metadata refuses a change to entities, because the graph has to be rebuilt.
  • Sources you already ingested: they keep their current people until you send them again with entities.
If you send your own graph with graph_payload, give each entity an id instead. See Key entities by your own ID.

Field reference

memories is a JSON string. Inside each item, metadata and additional_metadata are plain objects; do not stringify them again.

Common mistakes