TL;DR: Critical endpoints
POST /databases(client.databases.create()): Create an isolated database. Creation is asynchronous.GET /databases/status(client.databases.status()): Poll untilinfra.ready_for_ingestionis true before you ingest or query.POST /context/ingest(client.context.ingest()): Ingest files, app sources, or memories withtype="knowledge"ortype="memory". Indexing is asynchronous.GET /context/status(client.context.status()): Poll byidsuntilindexing_statusiscompletedbefore you query.graph_creationmeans the source is becoming searchable while its graph builds, but a query sent the moment it appears can still miss the source.erroredmeans indexing failed: readerror_codeanderror_message. Details in 7. Context status and lifecycle.POST /query(client.query()): Retrieve chunks withtype: "knowledge","memory", or"all".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.
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: 2automatically. - Use
HYDRADB_API_KEYas 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 exampleresponse.data.infra,response.data.statuses,response.data.results). On failure they raise a typed exception instead of returning an envelope witherrorset. - Exceptions: connector endpoints (
/connectors*) andPATCH /databases/{database}/metadata-schemareturn their success body directly, without the envelope. In the SDKs that is everyconnectors.*method,list_providers(), andupdate_metadata_schema(). Their errors still use the envelope. - Log
meta.request_idfor failed requests. - Treat
metaas an open object: ignore keys you do not recognize. metacarries an optionaldeprecationlist (with aDeprecation: trueresponse header) when a request uses a legacy tenants route (any path under /tenants) or a deprecated field (tenant_id/sub_tenant_id, orsub_tenant_idson/query). It is a non-breaking nudge: the status code is unchanged. Every entry hasdeprecated,message, anddeprecated_since.deprecated_fieldandpreferred_fieldare optional: thesub_tenant_idsnotice on/querycarries them, thetenant_id/sub_tenant_idnotice does not. Readmessagefor the migration, and do not key logic off the two optional fields. To avoid the notice, use the/databasesroutes and thedatabase/collection/collectionsfields.
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-levelmetadata_filterskeys.additional_metadata: free-form fields; anything not in themetadataschema. Filter on them withmetadata_filters.additional_metadata.- Set both per source on
/context/ingest: on eachdocument_metadata[]item (file uploads), eachapp_knowledge[]item, or each memory item. There is no top-levelmetadataoradditional_metadataform field.
Do not mix scopes accidentally
database(formerlytenant_id) is the hard isolation boundary.collection(formerlysub_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 withmetadata_filtersandacl. Patterns are in Databases and collections.- Use the same
collectionon 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
aclon everyPOST /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
aclfrom your authenticated session, never from client input. See Access control. - Do not turn on a connector’s
enforce_aclfor an application that serves many users through one API key. Withenforce_aclon, HydraDB ignores the request’saclfor 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 sendaclyourself.
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.
- Take
request_idfrom the query’s own response. Never invent one. It is inmeta.request_idand in theX-Request-IDresponse 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, andrating: "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 asground_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:
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 returned200 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 withtype: "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 withPATCH /context/{id}/metadata, or delete.
Memories
Memories are preferences, decisions, past conversations, behavioral signals, and inferred traits. Ingest them withtype: "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. Whengraph_context: true (default), a query can return:
graph_context.query_pathsgraph_context.chunk_relationsgraph_context.chunk_id_to_group_ids
chunks.
Forceful relations
Forceful relations are links you declare between sources at ingest:- Use
ids. - Declare
relationsondocument_metadata[]andapp_knowledge[]items. They link knowledge sources; memory items do not takerelations. - A query pulls the related chunks into
additional_contextonly inmode: "thinking"withquery_forceful_relations: true(the default).
Access control
A source’sacl 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
aclonapp_knowledge[]items at ingest, or on any existing source withPATCH /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; sendgroup:principals yourself. - A source with no
aclis unrestricted.
"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-writtenapp_knowledge ingestion when the app is in the catalog; GET /connectors/providers lists it.
Setup is four calls, made once:
GET /connectors/providers?id={provider}: readcredential_schema, the credentials it needs.POST /connectors: store the credentials, withdatabaseandcollection.GET /connectors/{id}/discover: list the channels, repositories, or pages the credentials reach.POST /connectors/{id}/configure: choose resources; the first sync starts right away.
GET /connectors/{id}/status until lifecycle is active, and query as usual. Syncs repeat every sync_interval_seconds (one hour by default).
- To change one resource, use
PATCH /connectors/{id}/resources/{resource_id}.POST /connectors/{id}/resourcesadds new resources only: on an existing resource it returns409and changes nothing. - Every synced source carries
connector_idandproviderinmetadata, andconnector_idandresource_idinadditional_metadata; filter on them to scope a query. custom_instructionson the connector or one resource tells HydraDB how to read its documents, from the next sync on.
3. Installation and client setup
Python SDK
TypeScript SDK
- 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()
databaseshould be stable. Use lowercase letters, numbers, and underscores for portability.- Plan
database_metadata_schemabefore ingestion. What you can change later is in 10. Metadata guide. POST /databasesmay return409 DATABASE_ALREADY_EXISTSfor duplicate database IDs and403 FORBIDDENwhen 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_statusinfra.graph_statusinfra.vectorstore_status.knowledgeinfra.vectorstore_status.memories
Other database endpoints
The collections, stats, and delete routes also takedatabase 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 returns202; the rejected file comes back indata.resultswithstatus: "failed"anderror_code: "E1002", and has no status record to poll. Check every result item before polling. - To ingest source code, upload it with
.txtadded to the filename (auth.py.txt) and keep the real path inadditional_metadata, or send its text as an app source. - The
Content-Typeof 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
Useapp_knowledge when you already extracted the text from Slack, Gmail, Jira, Linear, Zendesk, Notion, Confluence, Salesforce, webpages, and so on.
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
Usetype="memory" and a JSON-stringified memories array.
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: omittingcollection, or sending the wrong one, returnsindexing_status: "errored"witherror_code: "FILE_NOT_FOUND"andmessage: "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 readingerror_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:
X-HydraDB-Delivery-ID, X-HydraDB-Event, and X-HydraDB-Signature when a signing secret is configured.
Signature scheme:
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/indexingwith{"generate_signing_secret": true}registers and enables signing in one call, returning the secret once. Mutually exclusive withsigning_secret; sending both is a422.POST /webhooks/indexing/signing-secretwith no body generates one and returns the secret once. Send{"signing_secret": "..."}to supply your own (minimum 16 characters).DELETE /webhooks/indexing/signing-secretdisables signing.- Omitting
signing_secretonPOST /webhooks/indexingpreserves the existing secret. It does not disable signing.
- The webhook URL must be public HTTPS; localhost and private networks are blocked.
- Store
delivery_idto deduplicate retries. - Verify
X-HydraDB-Signaturewith a constant-time comparison. Useverify_webhook_signature(Python SDK) orverifyWebhookSignature(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>"].
Recommended configurations
Query examples
Knowledge RAG:Query response
The successfuldata object / SDK return is a RetrievalResult:
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)fromhydra_db.helpers(Python) orbuildString(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_contextto attach forcefully related chunks bychunk_uuid/extra_context_ids. - For personalized answers,
type: "all"is simplest: one result set already merges knowledge and memories.
10. Metadata guide
Metadata schema
Declared atPOST /databases:
Where metadata belongs
Rules:
- Plan hot filter fields before the first ingest.
PATCH /databases/{database}/metadata-schemacan add fields later, but cannot rename, retype, or reflag existing ones, and rejectsenable_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_filterskeys must be declared in the metadata schema. They supportequals,contains, andcontains_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 sameidandupsert: 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()
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()
cursor.
Delete sources
DELETE /context · client.context.delete()
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:- Create a database with a metadata schema for hot filters.
- Ingest shared knowledge and app sources with stable IDs.
- Ingest user and session memories with
collection. - Poll status or use webhooks.
- Query with
type: "knowledge","memory", or"all". - Format chunks, graph paths, and additional context into an LLM prompt.
- 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: 2in raw HTTP calls. - Reading a payload from the top level instead of
data, in raw HTTP or in the SDKs. - Writing with one
collectionand reading with another, or omittingcollectionfor user memories. - Splitting a company brain into many collections instead of one collection with
metadata_filtersandacl. - Querying on behalf of a user without
acl, which returns everything in scope. - Turning on a connector’s
enforce_aclbehind one shared API key, which runs every query as the key’s creator.
- Uploading a file with an unsupported extension, such as source code, and polling an ID that was rejected with
E1002. - Hand-writing
app_knowledgeingestion for an app a connector already syncs. - Editing an existing connector resource with
POST /connectors/{id}/resources, which returns409and changes nothing. - Querying right after database creation without polling readiness.
- Querying right after ingestion without polling
context.statusor using webhooks. - Treating
processingorqueuedcontext as searchable. - Not handling
erroredas the failure status. - Omitting
collectiononcontext.statusand reading the resultingFILE_NOT_FOUNDas a genuine indexing failure. - Using
??onerrorMessage, which is"", not null, on some failures, so the fallback never fires. - Forgetting to verify webhook signatures when a signing secret is configured.
- Using undeclared
metadatakeys inmetadata_filters. - Using
operatorwithoutquery_by: "text". - Expecting
query_forceful_relationsto work inmode: "fast". - Setting
graph_context: falseand expecting graph fields. - Reading
data.sources, which the public result does not return; cite from each chunk’sidandsource_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.
16. Navigation and support
- Guides:
https://docs.hydradb.com/essentials/v2/contextand 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]
