Skip to main content
This is the complete, maintained agent guide. Continue with the sections below; no separate documentation-index fetch is needed.

TL;DR: Critical endpoints

  1. POST /databases (client.databases.create()): Create an isolated database. Creation is asynchronous.
  2. GET /databases/status (client.databases.status()): Poll until infra.ready_for_ingestion is true before you ingest or query.
  3. POST /context/ingest (client.context.ingest()): Ingest files, app sources, or memories with type="knowledge" or type="memory". Indexing is asynchronous.
  4. GET /context/status (client.context.status()): Poll by ids until indexing_status is completed before you query. graph_creation means the source is becoming searchable while its graph builds, but a query sent the moment it appears can still miss the source. errored means indexing failed: read error_code and error_message. Details in 7. Context status and lifecycle.
  5. POST /query (client.query()): Retrieve chunks with type: "knowledge", "memory", or "all".
  6. POST /feedback (client.feedback.submit()): Tell us when a query did not give you what you needed, and once the task is done, how the context held up. See Sending feedback.
Every other endpoint and SDK method is in 15. SDK method reference.

1. Critical rules for LLMs

API versioning and auth

  • Base URL: https://api.hydradb.com
  • Raw HTTP calls must include:
    • Authorization: Bearer <api_key>
    • API-Version: 2
  • Official SDKs set API-Version: 2 automatically.
  • Use HYDRADB_API_KEY as the environment variable in examples.

Response envelope

Raw HTTP responses are wrapped:
  • Read the payload from data, never from the top level. This applies to /databases, /context/*, /query, /feedback, and the webhook management endpoints (/webhooks/indexing*).
  • The SDKs do not unwrap it: they return the full envelope object, so read response.data (for example response.data.infra, response.data.statuses, response.data.results). On failure they raise a typed exception instead of returning an envelope with error set.
  • Exceptions: connector endpoints (/connectors*) and PATCH /databases/{database}/metadata-schema return their success body directly, without the envelope. In the SDKs that is every connectors.* method, list_providers(), and update_metadata_schema(). Their errors still use the envelope.
  • Log meta.request_id for failed requests.
  • Treat meta as an open object: ignore keys you do not recognize.
  • meta carries an optional deprecation list (with a Deprecation: true response header) when a request uses a legacy tenants route (any path under /tenants) or a deprecated field (tenant_id/sub_tenant_id, or sub_tenant_ids on /query). It is a non-breaking nudge: the status code is unchanged. Every entry has deprecated, message, and deprecated_since. deprecated_field and preferred_field are optional: the sub_tenant_ids notice on /query carries them, the tenant_id/sub_tenant_id notice does not. Read message for the migration, and do not key logic off the two optional fields. To avoid the notice, use the /databases routes and the database/collection/collections fields.

Query parameter naming

type selects the store on POST /query and on the context lifecycle APIs: "knowledge", "memory", or "all" for both. POST /context/ingest takes "knowledge" or "memory" only.

Metadata naming

  • metadata: schema-aligned fields, declared at database creation; the fast filter path. Filter on them with top-level metadata_filters keys.
  • additional_metadata: free-form fields; anything not in the metadata schema. Filter on them with metadata_filters.additional_metadata.
  • Set both per source on /context/ingest: on each document_metadata[] item (file uploads), each app_knowledge[] item, or each memory item. There is no top-level metadata or additional_metadata form field.
Schema fields, placement, and filter operators are in 10. Metadata guide.

Do not mix scopes accidentally

  • database (formerly tenant_id) is the hard isolation boundary.
  • collection (formerly sub_tenant_id) is an optional group inside a database. Use separate collections only for context that must never meet in one query, such as each user’s memories. Otherwise (for example, a company brain) keep all knowledge and connectors in one collection and isolate results with metadata_filters and acl. Patterns are in Databases and collections.
  • Use the same collection on writes, status checks, and reads. Context written under one collection does not appear in a query that names another.

Send acl on user queries

  • If your application answers on behalf of signed-in users, send the caller’s identity as acl on every POST /query, for example "acl": ["[email protected]"].
  • A query with no acl, [], or ["*"] is not filtered: it returns everything in scope, including sources restricted to other people.
  • Derive acl from your authenticated session, never from client input. See Access control.
  • Do not turn on a connector’s enforce_acl for an application that serves many users through one API key. With enforce_acl on, HydraDB ignores the request’s acl for that connector’s content and uses the email of whoever created the API key, so every user sees what the key’s creator may see. Leave it off and send acl yourself.

Sending feedback

POST /feedback (client.feedback.submit()) records how a query performed. It is optional, and there is no penalty for skipping it. You are the only party that knows whether the retrieved context answered the question, and that judgement is what tunes retrieval. Send it when you have something specific to report:
  • A query did not give you what you needed: nothing relevant came back, the top result was wrong, or you had to fall back to another source. One report on a query that disappointed you is worth far more than a stream of routine ones.
  • A query worked well: rating: "positive" tells us what to preserve.
  • The task is finished (recommended): send one short report on how the context performed. See End-of-task report.
Rules:
  • Take request_id from the query’s own response. Never invent one. It is in meta.request_id and in the X-Request-ID response header. Send it back verbatim: an ID you made up, or one from another query, correlates to nothing.
  • Set source: "agent". It separates your reports from human ones, which fail in different ways.
  • Say what was wrong, not that something was wrong. “Returned the 2023 policy, current one is in the Q3 handbook” is actionable; “bad results” is not.
  • Do not block the user on it. Feedback is fire-and-forget: if the feedback call itself fails, drop it and carry on. Never retry in a loop, and never surface that error to the user.
  • Catch broadly, so that nothing escapes. Narrowing to the SDK error type would still let a timeout or a DNS failure surface an error the user cannot act on, from a call they did not ask for.
  • Feedback never changes the query’s result. It is a signal, not a correction, and you cannot read it back.
  • Each submission is its own record. A second report about the same query adds to the first instead of replacing it, so refine as you learn more.

End-of-task report

At the end of the task you know what you could not know at query time: whether a chunk that looked plausible turned out to be stale, contradicted by another source, or never used at all. A single report then is worth more than one per query, and rating: "positive" is as valuable as a negative one, because you know which part of the context did the work. Make the report stand on its own. We see only a request_id and the prose you send, nothing about what you were doing. Worth a sentence each:
  • What the user was trying to do.
  • Which chunks carried the answer, and which you discarded and why.
  • Whether you had to go outside HydraDB to finish, and what was missing when you did.

Ground truth

If you know the right answer, send it as ground_truth. When you run against a labelled set, or you know which source should have been returned, that is a far stronger signal than a comment, because it can be scored without a human reading it. With ground_truth present, feedback prose is optional:
Send answer, source_ids, or both. Do not guess: only send ground truth you have. A fabricated answer key is worse than none, because it is scored as if it were true.

Failed requests are not feedback

“Did not give me what I needed” is not the same as “errored”. A query that returned 200 with unhelpful results is what this endpoint is for. A query that never returned (4xx/5xx, or the SDK raised) is not: a failed request has no retrieval result to judge. Fix the request instead: a 404 means the database name is wrong, a 429 means back off, a 400 means the body was malformed.

Request fields and limits

Limit: 100 submissions per minute per organization, far above what reporting only the queries that fell short reaches. If you do hit 429, honour Retry-After or skip that report. Never spin.

2. Core primitives

Databases and collections

Scoping rules are in Do not mix scopes accidentally. Recommended patterns:

Knowledge

Knowledge is the documents, app sources, and facts your AI reasons over: PDFs, Markdown, CSVs, Slack threads, Notion pages, Gmail threads, tickets, webpages, and so on. Ingest and query it with type: "knowledge".
  • It can be private: restrict sources with acl (see Access control).
  • Mutability is explicit: re-ingest with the same ID and upsert: true, edit metadata in place with PATCH /context/{id}/metadata, or delete.

Memories

Memories are preferences, decisions, past conversations, behavioral signals, and inferred traits. Ingest them with type: "memory" into the collection you will query them from, and query with type: "memory" or type: "all". Item fields, including infer, are in 6. Source ingestion.

Query

POST /query is the single retrieval endpoint for knowledge, memories, or both. Fields, recommended configurations, and the response shape are in 8. Query API.

Context graph

HydraDB builds a graph of entity/relation triplets from ingested content. When graph_context: true (default), a query can return:
  • graph_context.query_paths
  • graph_context.chunk_relations
  • graph_context.chunk_id_to_group_ids
Graph context augments the result; it does not replace chunks.

Forceful relations

Forceful relations are links you declare between sources at ingest:
  • Use ids.
  • Declare relations on document_metadata[] and app_knowledge[] items. They link knowledge sources; memory items do not take relations.
  • A query pulls the related chunks into additional_context only in mode: "thinking" with query_forceful_relations: true (the default).

Access control

A source’s acl lists who may retrieve it; a query’s acl says who is asking. The query-side rule is in Send acl on user queries.
  • Set acl on app_knowledge[] items at ingest, or on any existing source with PATCH /context/{id}/metadata, where it replaces the stored list.
  • Connectors copy permissions from Slack, Google Drive, GitHub, Confluence, Jira, and other providers on every sync.
  • Principals: an email ([email protected]), domain:acme.com, group:<provider>:<id>, or __public__.
  • On a query, the caller’s email also matches its domain: principal and __public__ automatically. Group membership is never derived from an email; send group: principals yourself.
  • A source with no acl is unrestricted.
Example: a source with "acl": ["[email protected]"] comes back for a query with "acl": ["[email protected]"] and stays hidden from "acl": ["[email protected]"]. A source with "acl": ["domain:acme.com"] comes back for both.

Connectors

Connectors sync context from 70 apps, including Slack, Gmail, Google Drive, Notion, Jira, Confluence, GitHub, Linear, HubSpot, and Zendesk, into a database on a schedule, with no ingestion code. Prefer a connector over hand-written app_knowledge ingestion when the app is in the catalog; GET /connectors/providers lists it. Setup is four calls, made once:
  1. GET /connectors/providers?id={provider}: read credential_schema, the credentials it needs.
  2. POST /connectors: store the credentials, with database and collection.
  3. GET /connectors/{id}/discover: list the channels, repositories, or pages the credentials reach.
  4. POST /connectors/{id}/configure: choose resources; the first sync starts right away.
Then poll GET /connectors/{id}/status until lifecycle is active, and query as usual. Syncs repeat every sync_interval_seconds (one hour by default).
Rules:
  • To change one resource, use PATCH /connectors/{id}/resources/{resource_id}. POST /connectors/{id}/resources adds new resources only: on an existing resource it returns 409 and changes nothing.
  • Every synced source carries connector_id and provider in metadata, and connector_id and resource_id in additional_metadata; filter on them to scope a query.
  • custom_instructions on the connector or one resource tells HydraDB how to read its documents, from the next sync on.

3. Installation and client setup

Python SDK

Async client:

TypeScript SDK

SDK naming:
  • Python methods and fields are snake_case: databases.get_metadata_schema(), page_size, query_by.
  • TypeScript methods and fields are camelCase: databases.getMetadataSchema(), pageSize, queryBy.
  • Values passed as JSON strings (memories, app_knowledge, document_metadata) keep snake_case keys inside the stringified payload in both SDKs, because that is raw wire data.

4. Minimal end-to-end flow

Python

TypeScript


5. Databases API

Create database

POST /databases · client.databases.create()
Notes:
  • database should be stable. Use lowercase letters, numbers, and underscores for portability.
  • Plan database_metadata_schema before ingestion. What you can change later is in 10. Metadata guide.
  • POST /databases may return 409 DATABASE_ALREADY_EXISTS for duplicate database IDs and 403 FORBIDDEN when the API key or plan cannot create more databases.

Check readiness

GET /databases/status?database=... · client.databases.status() The database is ready when infra.ready_for_ingestion is true. The response also carries the underlying signals:
  • infra.scheduler_status
  • infra.graph_status
  • infra.vectorstore_status.knowledge
  • infra.vectorstore_status.memories

Other database endpoints

The collections, stats, and delete routes also take database as a query parameter, for example GET /databases/collections?database=.... DELETE /databases?database=... deletes the database and all its data. The full list is in 15. SDK method reference.

6. Source ingestion

POST /context/ingest is the single write endpoint for knowledge and memories. It takes multipart form data.

Common form fields

Knowledge from files

Use for files HydraDB should parse. Supported extensions:
  • Any other extension, including source code (.py, .ts, .go), .html, and .zip, is rejected. The request still returns 202; the rejected file comes back in data.results with status: "failed" and error_code: "E1002", and has no status record to poll. Check every result item before polling.
  • To ingest source code, upload it with .txt added to the filename (auth.py.txt) and keep the real path in additional_metadata, or send its text as an app source.
  • The Content-Type of the part is used only when the filename has no extension.
document_metadata is how you attach anything to an uploaded file. Send one item per file, in the same order as documents. The item count must match the file count, and an unrecognized key returns 400.

Knowledge from app sources

Use app_knowledge when you already extracted the text from Slack, Gmail, Jira, Linear, Zendesk, Notion, Confluence, Salesforce, webpages, and so on.
Recommended app-source fields: Kinds in OpenAPI are email, message, ticket, knowledge_base, comment, meeting, and custom. An older shape with type and content.text in place of kind and fields is still accepted; do not use it in new code. See Context for the keys each kind takes in fields. At minimum provide a stable id, kind, fields, and the metadata you filter on.

Memories

Use type="memory" and a JSON-stringified memories array.
Memory item fields:

7. Context status and lifecycle

Poll indexing

GET /context/status · client.context.status() Parameters:
  • database: required.
  • ids: required array.
  • collection: required if you ingested into one. The lookup is scoped: omitting collection, or sending the wrong one, returns indexing_status: "errored" with error_code: "FILE_NOT_FOUND" and message: "ID not found" for a source that exists and is fully searchable. That is a scope miss, not an indexing failure, and you can tell the two apart only by reading error_code.
error_message is "", not null, on some failures (including a scope miss), so branch on error_code, and in TypeScript fall back with ||, not ??.

Webhooks instead of polling

Register a webhook on /webhooks/indexing to receive terminal indexing events instead of polling. The management endpoints and SDK methods are in 15. SDK method reference. Supported event: indexing.status_changed. Payload shape:
Headers: X-HydraDB-Delivery-ID, X-HydraDB-Event, and X-HydraDB-Signature when a signing secret is configured. Signature scheme:
The sha256= prefix is part of the header value. The digest is lowercase hex, not base64. The HMAC covers the raw body bytes as received; re-serialising the parsed JSON produces different bytes and will not match. Managing the secret:
  • POST /webhooks/indexing with {"generate_signing_secret": true} registers and enables signing in one call, returning the secret once. Mutually exclusive with signing_secret; sending both is a 422.
  • POST /webhooks/indexing/signing-secret with no body generates one and returns the secret once. Send {"signing_secret": "..."} to supply your own (minimum 16 characters).
  • DELETE /webhooks/indexing/signing-secret disables signing.
  • Omitting signing_secret on POST /webhooks/indexing preserves the existing secret. It does not disable signing.
Rules:
  • The webhook URL must be public HTTPS; localhost and private networks are blocked.
  • Store delivery_id to deduplicate retries.
  • Verify X-HydraDB-Signature with a constant-time comparison. Use verify_webhook_signature (Python SDK) or verifyWebhookSignature (TypeScript SDK) from the SDK helpers module.
  • Fail closed: reject the request when the signing secret is absent from the environment, instead of skipping verification.

8. Query API

POST /query · client.query()

Request fields that matter

type: "all" reads both stores from the same scope. When shared knowledge lives in its own collection, send collections: ["<shared>", "<user>"].

Query examples

Knowledge RAG:
Personalized answer using knowledge and memories:
Exact phrase:
Metadata-scoped query:

Query response

The successful data object / SDK return is a RetrievalResult:
Each chunk’s id is the ID of the source it came from, and source_title is that source’s title: cite with these. The public result has no sources array. Use chunks as the primary LLM context. Preserve server order, which is the ranking; do not re-sort unless you have a deliberate reranking step.

9. Turning query results into LLM prompts

  • Do not pass raw result JSON to the LLM if token budget matters. Use the SDK formatting helper to produce a compact context string: build_string(result) from hydra_db.helpers (Python) or buildString(result) from @hydradb/sdk/helpers (TypeScript).
  • Include a grounding instruction: answer only from the provided context, and say when the context is insufficient.
  • Start with max_results: 10; reduce it for tight context windows.
  • Use graph context only when it helps the question.
  • Use additional_context to attach forcefully related chunks by chunk_uuid / extra_context_ids.
  • For personalized answers, type: "all" is simplest: one result set already merges knowledge and memories.
Python:
TypeScript:

10. Metadata guide

Metadata schema

Declared at POST /databases:
Field options:

Where metadata belongs

Rules:
  • Plan hot filter fields before the first ingest. PATCH /databases/{database}/metadata-schema can add fields later, but cannot rename, retype, or reflag existing ones, and rejects enable_dense_embedding / enable_sparse_embedding (declare those at database creation). Changing an existing field definition requires a new database and re-ingestion.
  • Top-level metadata_filters keys must be declared in the metadata schema. They support equals, contains, and contains_any. Range and fuzzy matching belong in the query or a downstream reranker.
  • To change metadata on an indexed source, call PATCH /context/{id}/metadata (merges keys), or re-ingest with the same id and upsert: true.
  • Do not rename metadata keys without re-ingesting the affected sources.

11. Browse, fetch, relations, delete

List sources

POST /context/list · client.context.list()
Parameters: database, collection, type: "knowledge" | "memory" | "all", ids, page, page_size (1 to 100), filters.metadata, filters.additional_metadata, filters.source_fields, and include_fields for projection.

Fetch original content

GET /context/inspect · client.context.inspect()

Inspect graph relations

GET /context/relations · client.context.relations()
Use it for graph debugging and provenance inspection. It paginates with cursor.

Delete sources

DELETE /context · client.context.delete()
Use type: "memory" to delete memory IDs.

12. Error handling

HTTP status codes

Retry only 429, 500, 502, and 503, with bounded exponential backoff and jitter. The SDKs already retry 408, 429, and 5xx responses twice with exponential backoff before raising, and the Python SDK also retries 409. Do not wrap SDK calls in a second retry loop: raise the count with request_options={"max_retries": 5} on a Python call, or maxRetries on the TypeScript client or call.

Common error codes

There is no INVALID_PARAMETERS and no SOURCE_NOT_FOUND: no HydraDB response carries either. Match on INVALID_INPUT and FILE_NOT_FOUND. SDK errors:

13. Common integration patterns

Most integrations follow the same architecture:
  1. Create a database with a metadata schema for hot filters.
  2. Ingest shared knowledge and app sources with stable IDs.
  3. Ingest user and session memories with collection.
  4. Poll status or use webhooks.
  5. Query with type: "knowledge", "memory", or "all".
  6. Format chunks, graph paths, and additional context into an LLM prompt.
  7. Cite sources and handle missing context explicitly.

14. Common mistakes checklist

Each item is a rule stated in full in the section named. Check all of them before you finish. Section 1, critical rules:
  • Forgetting API-Version: 2 in raw HTTP calls.
  • Reading a payload from the top level instead of data, in raw HTTP or in the SDKs.
  • Writing with one collection and reading with another, or omitting collection for user memories.
  • Splitting a company brain into many collections instead of one collection with metadata_filters and acl.
  • Querying on behalf of a user without acl, which returns everything in scope.
  • Turning on a connector’s enforce_acl behind one shared API key, which runs every query as the key’s creator.
Sections 2 to 7, ingestion and lifecycle:
  • Uploading a file with an unsupported extension, such as source code, and polling an ID that was rejected with E1002.
  • Hand-writing app_knowledge ingestion for an app a connector already syncs.
  • Editing an existing connector resource with POST /connectors/{id}/resources, which returns 409 and changes nothing.
  • Querying right after database creation without polling readiness.
  • Querying right after ingestion without polling context.status or using webhooks.
  • Treating processing or queued context as searchable.
  • Not handling errored as the failure status.
  • Omitting collection on context.status and reading the resulting FILE_NOT_FOUND as a genuine indexing failure.
  • Using ?? on errorMessage, which is "", not null, on some failures, so the fallback never fires.
  • Forgetting to verify webhook signatures when a signing secret is configured.
Sections 8 to 10, query and metadata:
  • Using undeclared metadata keys in metadata_filters.
  • Using operator without query_by: "text".
  • Expecting query_forceful_relations to work in mode: "fast".
  • Setting graph_context: false and expecting graph fields.
  • Reading data.sources, which the public result does not return; cite from each chunk’s id and source_title.
  • Re-sorting chunks before prompting without a deliberate reranker.
  • Passing raw result JSON or too many chunks to the LLM.
  • Putting hot filters in free-form metadata instead of the metadata schema.

15. SDK method reference

Every method is on the client: client.<method> in both SDKs. Return shapes are in Response envelope; naming is in 3. Installation and client setup.

15.1 Minimal cURL example

The flow from 4. Minimal end-to-end flow over raw HTTP:

15.2 Raw HTTP: ingest app-source knowledge

The raw HTTP form of Knowledge from app sources. app_knowledge must be a JSON string in multipart form data.
Query it with app-aware retrieval:

16. Navigation and support

  • Guides: https://docs.hydradb.com/essentials/v2/context and the other Core Concepts pages
  • API reference: https://docs.hydradb.com/api-reference/v2
  • OpenAPI spec: https://docs.hydradb.com/api-reference/v2/openapi.json
  • Dashboard/API keys: https://dashboard.hydradb.com
  • Support email: [email protected]