NEWpromptev for Android and Chrome: your agents on your phone and in your browser. Get the apps→

Context Engine HTTP API reference

Two routes, one project API key: POST /api/v1/documents puts documents in, POST /api/v1/knowledge searches them. What each takes, what it returns and which status codes it answers with.

Overview

The Context Engine is hosted by promptev. The base URL is https://api.promptev.ai. The Python and TypeScript SDKs call these same routes, so use them when you can: they check limits before sending, retry passing errors and raise one error class per status.

RouteBodyWhat it does
POST /api/v1/documentsmultipart/form-dataPut up to 20 files into the key’s project knowledge base (ingestion).
POST /api/v1/knowledgeapplication/jsonRead the key’s project knowledge base with one action (retrieval).

Authentication

Create a project API key under the project’s API keys in the promptev console. Send it on every request:

Header
Authorization: Bearer fk_...

A key belongs to one project. It reads and writes that project’s knowledge base and nothing outside it, so no request names a project. Keep the key on your server.

POST /api/v1/documents

Put documents into the project, in the same Uploads source the console writes to. The project’s agents can use them on their next turn. The request returns when every file is ready, so allow a long timeout for large files.

Form fieldTypeMeaning
filesfile, repeatedRequired. One part per file, up to 20, 25 MB each. The filename’s extension decides how the file is read.
mode"hybrid" | "graph"Optional. "graph" also extracts entities and relationships into the Context Graph. Leave it out for the workspace’s default.
updatestring, repeatedOptional. The name of a file in this request that should update the uploaded document of the same name in place, as the console offers. A file not named here is a new document.
curl
curl https://api.promptev.ai/api/v1/documents \
  -H "Authorization: Bearer $PROMPTEV_API_KEY" \
  -F "files=@handbook.pdf" \
  -F "files=@pricing.xlsx" \
  -F "mode=graph"
curl: update in place
# Replace the uploaded handbook.pdf in place instead of adding a second one
curl https://api.promptev.ai/api/v1/documents \
  -H "Authorization: Bearer $PROMPTEV_API_KEY" \
  -F "files=@handbook.pdf" \
  -F "update=handbook.pdf"

The answer has one row per file, in order. A file that fails is reported in its own row (status "failed" and an error) and never fails the others:

200 JSON
{
  "results": [
    {
      "filename": "handbook.pdf",
      "status": "…",
      "document_id": "…",
      "chunks": 42,
      "units": 12,
      "error": null
    },
    {
      "filename": "pricing.xlsx",
      "status": "failed",
      "document_id": null,
      "chunks": 0,
      "units": 0,
      "error": "…"
    }
  ]
}

An upload costs 1 credit per page, slide or MB, at least 1 per file.

POST /api/v1/knowledge

Read the project’s knowledge base. It is the same tool, with the same actions and fields, as search_knowledge_base on the project’s MCP server. The body is a JSON object: action plus that action’s fields. Start with discover.

curl: discover
curl https://api.promptev.ai/api/v1/knowledge \
  -H "Authorization: Bearer $PROMPTEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action": "discover"}'
curl: search
curl https://api.promptev.ai/api/v1/knowledge \
  -H "Authorization: Bearer $PROMPTEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action": "search", "query": "how many days do customers have to ask for a refund", "top_k": 5}'
curl: get_doc
curl https://api.promptev.ai/api/v1/knowledge \
  -H "Authorization: Bearer $PROMPTEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action": "get_doc", "document_id": "…"}'

Each call costs 1 credit, plus 1 for a search (5 when the graph is searched). There is no extra API-call charge.

Actions and fields

The graph actions (get_neighbors, traverse, find_related, community_summary) need documents uploaded in graph mode. discover says which actions the project can run.

ActionWhat you getFields
discoverEach document and what is inside it (a sheet’s columns, a document’s sections), the extracted fields, and which actions the project can run. Call it first.source_ids, document_ids, limit, cursor
searchPassages by meaning or keywords, as hits. For an ID, code or invoice number, search the bare identifier.query, top_k, mode, source_ids, document_ids
get_docOne whole document by id.document_id
get_docsSeveral whole documents at once.document_ids, max_chars
get_chunksOne long document in order, up to 25 passages at a time.document_id, start, end
listBrowse the documents without searching.source_ids, document_ids, limit, cursor
query_metaThe structured fields a question names (dates, amounts, parties) and each document’s value.query, source_ids, limit
computeA figure from the spreadsheets (total, average, count, ranking) or the exact row for one value, over every row.query, source_ids, document_ids
map_reduceThe same question asked of every document in scope, one answer per document.query, source_ids, document_ids
get_neighborsWhat is one step from a named thing in the Context Graph.entity, limit
traverseEverything within a few steps of a named thing, or how two things connect.entity, depth, category, limit
find_relatedConnections of one kind across the knowledge base.category, label, entity_type, limit
community_summaryThe main themes and groups the knowledge base falls into.query, limit
FieldTypeMeaning
actionstringRequired. One of the actions above.
querystringWhat you are looking for, in words, or a bare identifier you are looking up.
top_kintegerHow many passages a search returns. Default 10.
mode"hybrid" | "graph"How a search ranks. Leave it out and the right one is chosen.
document_idstringOne document’s id, from discover, list or a search hit.
document_idsstring[]Narrow to these documents.
source_idsstring[]Narrow to these sources.
limitintegerHow many rows: documents for discover and list (default 50), candidates for query_meta (20), links for the graph actions (50), groups for community_summary (3).
cursorstringThe next_cursor a previous page returned.
entitystringWhere a graph action starts: an entity id from an earlier graph answer (best), or a name as written in the documents.
depthintegerHow many steps traverse walks, 1 to 5. Default 2.
categorystringThe kind of connection to follow or find.
labelstringThe exact relationship wording, for example reports_to.
entity_typestringKeep only connections with this type of entity on one end.
startintegerFirst passage to read, from 0.
endintegerLast passage to read, inclusive.
max_charsintegerHow much text get_docs returns before it stops.

Responses

A search answers with hits, best first:

200 JSON
{
  "hits": [
    {
      "document_id": "…",
      "document_name": "refund-policy.pdf",
      "chunk_text": "Refunds are accepted within 30 days …",
      "score": 0.82,
      "source_id": "…",
      "chunk_idx": 4
    }
  ]
}

discover and list page through documents. When has_more is true, send next_cursor back as cursor, or simply send next_page as the next body:

200 JSON: list
{
  "documents": [
    { "id": "…", "name": "handbook.pdf", "source_id": "…", "kind": "text" }
  ],
  "count": 50,
  "has_more": true,
  "next_cursor": "…",
  "next_page": { "action": "list", "cursor": "…" }
}

An answer may carry a next_action: the next call, already filled in. Errors carry a message that says what to fix. field is there when the server knows which field is at fault:

4xx JSON
{
  "error": {
    "message": "…",
    "field": "files"
  }
}

Status codes

StatusMeaning
200Done. The body is the answer. An upload reports each file in results, failures included.
401The key is missing, malformed, revoked or expired.
402The workspace has no credits left. Top up; a retry does not help.
404The key reaches no project.
422The request is wrong: no files, too many, too large, a type that is not accepted, a mode that cannot be served, an unknown action, a field the action does not take, or an action that could not answer. The message says why.
429Too many requests. Wait for the seconds in the Retry-After header.
502, 503, 504A passing server error. Retry after a short wait. Uploading the same bytes again never adds a copy.
1,000 free credits for a 30-day trial · No card required · No subscription1,000 free credits · 30-day trial · No card