hejstack API for developers
API v1 · Last updated: 4 November 2026 · Interactive reference · OpenAPI (JSON)
What the API is for
The hejstack API lets your apps and scripts work with a company's knowledge in hejstack: search knowledge groups, get answers backed by sources, and read or write wiki pages. It is built for Windmill apps and partner integrations and uses service accounts, not user logins. A service account only sees what the company's administrator has released to it.
This page is the guide. The complete, always current reference with every field and example lives at https://api.hejstack.com/api/v1/docs; the raw specification at https://api.hejstack.com/api/v1/openapi.json.
Getting access
- Service account. The hejstack platform administrator creates a service account for your app and hands over the token (format
sk-hejstack-sa-…). The token is shown exactly once; store it in a secret store (for Windmill: a variable marked secret). If it leaks, the administrator revokes it and issues a new one. - Release. The administrator of the company whose knowledge you access releases, under Zugriff für Apps (app access), which knowledge groups and wikis the service account may see, for wikis with the right read or write. Nothing is visible by default.
- Check. Call
GET /me(below). It lists the scopes of the token and everything that has been released.
Base URL, authentication and headers
Base URL: https://api.hejstack.com/api/v1. All requests and responses are JSON, except wiki pages, which travel as text/markdown.
| Header | Value | Required |
|---|---|---|
| Authorization | Bearer <token> | yes |
| X-hejstack-App | Origin of the call, e.g. your Windmill path f/purchasing/supplier_check. Written to the company's audit log next to time, service account and endpoint. | recommended |
| Content-Type | application/json for POST and PUT bodies | with a body |
| If-Match | ETag of the wiki page you read, e.g. "3" – required on PUT and DELETE of pages | wiki writes |
Scopes are attached to the token: knowledge:read (search and ask), wiki:read, wiki:write. A scope alone is not enough – the group or wiki also has to be released to the service account.
Fill in your details
The examples on this page are rewritten with what you enter here, ready to copy. Everything stays in this browser tab: the page stores nothing and sends nothing anywhere. The Python, TypeScript and Windmill samples keep reading the token from the environment on purpose.
First call
curl -s https://api.hejstack.com/api/v1/me \
-H "Authorization: Bearer $HEJSTACK_TOKEN" \
-H "X-hejstack-App: my-first-script"Response:
{
"tenant": { "id": "0a1b2c3d-…", "name": "Example GmbH", "slug": "example-gmbh" },
"service_account": { "id": "5c6d7e8f-…", "name": "purchasing-app" },
"scopes": ["knowledge:read", "wiki:read"],
"knowledge_groups": [{ "id": "7f1c2a4e-…", "name": "Purchasing" }],
"wikis": [{ "id": "9b8a7c6d-…", "name": "Processes", "access": "read" }]
}Groups and wikis can be addressed by id, by name or by their slug in every other call. Prefer the id in code that runs unattended: it is stable even if the company renames the group.
Endpoints at a glance
| Method | Path (relative to the base URL) | Purpose | Scope |
|---|---|---|---|
| GET | /me | Your access: company, scopes, assigned knowledge groups and wikis | – |
| POST | /knowledge/search | Semantic search in one knowledge group; passages with score and source | knowledge:read |
| POST | /knowledge/ask | Sourced answer from one knowledge group (uses the company's language model) | knowledge:read |
| GET | /wikis | Assigned wikis with right read or write | wiki:read |
| GET | /wikis/{wiki}/pages | Pages of a wiki with path, title, type, ETag, last change | wiki:read |
| GET | /wikis/{wiki}/pages/{path} | One page as an OKF file (text/markdown) plus header ETag | wiki:read |
| POST | /wikis/{wiki}/pages | Create a page (409 if the path exists) | wiki:write |
| PUT | /wikis/{wiki}/pages/{path} | Replace a page; If-Match required | wiki:write |
| DELETE | /wikis/{wiki}/pages/{path} | Move a page to the wiki's trash; If-Match required | wiki:write |
Search and ask
knowledge/search returns the best matching text passages of one knowledge group with a relevance score and their source (document, page, folder, link to the original). No language model writes an answer; only the search text is converted into a vector (embedding), and that small cost is booked to the company's usage. Use it when your app formats or filters results itself.
knowledge/ask answers a question solely from the group's knowledge with the language model the company has released. The answer contains citations like [Quelle 1] and the response lists only the documents actually cited. It counts against the company's quota; when the quota is exhausted or blocked you get 429 without Retry-After.
curl – search
curl -s https://api.hejstack.com/api/v1/knowledge/search \
-H "Authorization: Bearer $HEJSTACK_TOKEN" \
-H "X-hejstack-App: my-first-script" \
-H "Content-Type: application/json" \
-d '{"query": "payment terms supplier Müller", "group": "Purchasing", "limit": 5}'Python – ask
import os
import requests
API = "https://api.hejstack.com/api/v1"
HEADERS = {
"Authorization": "Bearer " + os.environ["HEJSTACK_TOKEN"],
"X-hejstack-App": "supplier-check",
}
response = requests.post(
API + "/knowledge/ask",
headers=HEADERS,
json={"question": "Which payment terms did we agree with Müller & Söhne?", "group": "Purchasing"},
timeout=60,
)
if response.status_code == 429:
retry_after = response.headers.get("Retry-After")
if retry_after is None: # quota used up: retrying will not help
raise RuntimeError("hejstack quota: " + response.json()["detail"])
raise RuntimeError(f"rate limited, retry in {int(retry_after)} s")
response.raise_for_status()
data = response.json()
print(data["answer"])
for source in data["sources"]:
print("-", source["filename"], source.get("page"))TypeScript – search
const API = "https://api.hejstack.com/api/v1";
async function search(query: string, group: string) {
const res = await fetch(API + "/knowledge/search", {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.HEJSTACK_TOKEN,
"X-hejstack-App": "supplier-check",
"Content-Type": "application/json",
},
body: JSON.stringify({ query, group, limit: 5 }),
});
if (!res.ok) {
throw new Error("hejstack API " + res.status + ": " + (await res.text()));
}
return (await res.json()) as {
group: { id: string; name: string };
hits: { text: string; score: number; source: { filename: string; page: number | null } }[];
};
}Wiki pages
A wiki page travels as an OKF file (Open Knowledge Format): Markdown with a YAML front matter block. type is the only required field; title, description, tags, owner and updated are optional – hejstack fills in updated and owner when they are missing. The same file format is used by the company's data export.
---
type: process
title: Expense reports
description: Process and deadlines for travel expense reports
tags: [finance, travel]
---
## Process
1. Upload the receipts in the portal within 14 days after returning.
2. Accounting checks them and pays out with the next payroll run.Conflict protection with ETag and If-Match
Every page has a revision, returned as the ETag header (it starts at 1 and increases with every save, from the editor or the API). PUT and DELETE require If-Match with exactly the ETag you read: without it you get 428, and if somebody saved in between you get 409. Then read the page again, merge your change and send it again. This protects a company's wiki from being overwritten by a script that worked on stale content.
# 1) read the page – note the ETag header
curl -si https://api.hejstack.com/api/v1/wikis/Processes/pages/processes/expense-reports.md \
-H "Authorization: Bearer $HEJSTACK_TOKEN" \
-H "X-hejstack-App: wiki-sync"
# HTTP/1.1 200 OK
# ETag: "3"
# Content-Type: text/markdown; charset=utf-8
# ---
# type: process
# …# 2) replace it – send exactly the ETag you read
curl -s -X PUT https://api.hejstack.com/api/v1/wikis/Processes/pages/processes/expense-reports.md \
-H "Authorization: Bearer $HEJSTACK_TOKEN" \
-H "X-hejstack-App: wiki-sync" \
-H 'If-Match: "3"' \
-H "Content-Type: application/json" \
-d @page.json # {"content": "---\ntype: process\n…"}
# 200 -> new ETag "4" · 409 -> someone else saved first: read again, merge, retry · 428 -> If-Match missingCreating and deleting
curl -s -X POST https://api.hejstack.com/api/v1/wikis/Processes/pages \
-H "Authorization: Bearer $HEJSTACK_TOKEN" \
-H "X-hejstack-App: wiki-sync" \
-H "Content-Type: application/json" \
-d '{"path": "processes/expense-reports.md", "content": "---\ntype: process\ntitle: Expense reports\n---\n\n## Process\n…"}'
# 201 + ETag "1" · 409 -> the path already exists (read it back instead)DELETE moves a page to the wiki's trash (with If-Match as well); the company's administrator can restore it in hejstack. A page in the trash keeps its path: creating the same path again revives it with its history. Every write by the API shows up in the page history with the service account as author and the channel api.
Rate limits and retries
- 60 calls per minute per service account. Above that the API answers
429withRetry-After(seconds) andX-RateLimit-Limit/X-RateLimit-Remaining. - Retry
429afterRetry-Afterand5xxwith exponential backoff and a cap; do not retry4xxother than 429. A429withoutRetry-Aftermeans the company's quota is used up: stop instead of retrying. - Wiki writes are safe to retry: a repeated
PUTorDELETEwith the sameIf-Matchgets409if the first attempt already went through, so read the page back to confirm. A repeated create gets409when the first one succeeded. - Keep requests small:
queryup to 2,000 characters,questionup to 4,000, a wiki page up to 220,000 characters, at most 20 hits per search.
Errors
Errors are JSON with a detail field containing a human-readable message (in German, the product language). Rely on the status code, not on the text. The one exception is request validation (422): there detail is a list with one entry per invalid field (loc, msg, type).
| Status | Meaning |
|---|---|
| 400 | Invalid page path (empty, .., disallowed characters). |
| 401 | Token missing, invalid or revoked. |
| 403 | Scope missing, or the group / wiki is not assigned to the service account (or read-only). |
| 404 | Unknown group, wiki or page. A wiki that is not assigned answers 404 as well, never 403. |
| 409 | Wiki: the page changed since you read it (ETag mismatch) or the path is already taken. |
| 422 | Request formally invalid: detail is a list with one entry per invalid field. Wiki writes: also a text when the OKF file cannot be read (e.g. no type). |
| 423 | The company's knowledge base is temporarily locked. Retry later. |
| 428 | Wiki: If-Match header missing on PUT or DELETE. |
| 429 | Rate limit reached: honour Retry-After. knowledge/ask also answers 429 without Retry-After when the company's quota is used up; do not retry that automatically. |
Windmill example
hejstack apps are typically built with Windmill. The token belongs in a Windmill variable marked secret, never in the script. Send the script or flow path as X-hejstack-App; the company sees it in the audit log.
// Windmill script (TypeScript / Bun). The token lives in a Windmill variable marked
// "secret"; the X-hejstack-App header carries the script path so the company's
// audit log shows which app accessed the data.
import * as wmill from "windmill-client";
const API = "https://api.hejstack.com/api/v1";
export async function main(question: string, group: string) {
const token = await wmill.getVariable("f/hejstack/api_token");
const res = await fetch(API + "/knowledge/ask", {
method: "POST",
headers: {
Authorization: "Bearer " + token,
"X-hejstack-App": "f/purchasing/supplier_check",
"Content-Type": "application/json",
},
body: JSON.stringify({ question, group }),
});
if (res.status === 429) {
const retryAfter = res.headers.get("Retry-After");
// without Retry-After: the quota is used up, retrying will not help
throw new Error(retryAfter ? "hejstack: rate limit, retry after " + retryAfter + " s" : "hejstack quota: " + (await res.json()).detail);
}
if (!res.ok) {
throw new Error("hejstack API " + res.status + ": " + (await res.text()));
}
const data = await res.json();
return { answer: data.answer, sources: data.sources, model: data.model };
}Onboarding: your first hour as an app developer
When hejstack onboards your app, an automated flow sets up everything below and sends you an invitation mail with the links. This is what you find, and what to do first.
What is already set up for you
| Item | What it is |
|---|---|
| Windmill development workspace | Your own workspace. The folder f/your-app is yours (you own it); f/hejstack holds the resources below (read-only); f/ops belongs to hejstack operations. |
| Resource f/hejstack/api | Access to the hejstack API: base_url and the token of the service account windmill-your-app of your test tenant, scopes knowledge:read, wiki:read, wiki:write. It sees only what you release to it (see step 4). |
| Resource f/hejstack/litellm | Access to the EU language models (OpenAI-compatible endpoint) with your own key and a daily budget. The key lives in a secret variable; the resource references it. |
| Test tenant in hejstack | A company of your own in hejstack where you are administrator: upload documents, create knowledge groups and wikis, release them to the service account under Zugriff für Apps. |
| Test users test1 and test2 | Two regular users of the test tenant without a Windmill account – use them to test your app as a guest. hejstack operations hands you their credentials. |
| App tile | A tile in the test tenant's Apps area, assigned to you and the test users. It opens f/your-app/app with the custom path your-app as soon as that app exists and is published for guests. |
| Git repository | Created from the hejstack template. Windmill Git-Sync mirrors your workspace folder into the branch dev; main is protected and released by pull request. |
Checklist
- Sign in to Windmill with your hejstack account and open your workspace.
- Read the script
f/your-app/README– it names the folders, resources and the repository. - Create a first script that calls
GET /methrough the resource (below). The response lists the scopes and, at first, empty knowledge groups and wikis. - In the test tenant, create a knowledge group, upload a few documents and release the group to the service account under Zugriff für Apps. Run the script again: the group appears.
- Call
knowledge/searchandknowledge/askagainst that group. - Build your app at
f/your-app/app, set the custom pathyour-appand publish it for guests. Open the tile in the test tenant – first as yourself, then as test1. - Done? Open a pull request from
devtomain. The merge is the release.
// First call from your development workspace: the onboarding set up the resource
// f/hejstack/api (base_url + token of your test tenant's service account) for you.
import * as wmill from "windmill-client";
type HejstackApi = { base_url: string; token: string };
export async function main() {
const api = (await wmill.getResource("f/hejstack/api")) as HejstackApi;
const res = await fetch(api.base_url + "/me", {
headers: {
Authorization: "Bearer " + api.token,
"X-hejstack-App": "f/your-app/first_call",
},
});
if (!res.ok) {
throw new Error("hejstack API " + res.status + ": " + (await res.text()));
}
return await res.json(); // scopes, knowledge_groups, wikis of the test tenant
}Keep tokens where they are: the resource and the secret variable stay in the workspace and are never copied into scripts, logs or mails. Questions during onboarding: get in touch.
Versioning and changes
- The version is part of the path (
/api/v1). Within v1, changes are additive: new optional fields, new endpoints, new values. Clients must ignore fields they do not know. - Breaking changes only arrive under a new version path. When a version is superseded, we announce it here and in the changelog, and the old version stays available for at least six months after the announcement.
- The specification at
/api/v1/openapi.jsonis the source of truth and always reflects the deployed version.
Changelog
| When | Change |
|---|---|
| November 2026 | Documented specification, interactive reference at /api/v1/docs, this guide with the onboarding checklist. |
| September 2026 | Wiki endpoints: list, read, create, replace, trash; ETag / If-Match; page history. |
| September 2026 | Initial release of API v1: /me, /knowledge/search, /knowledge/ask. |
Data protection
For every call hejstack records time, service account, endpoint, knowledge group and the X-hejstack-App origin in the company's audit log – never questions, answers or document contents. Knowledge, wiki pages and answers are stored on servers in Germany, and AI processing happens in the EU. A service account can only reach what the company released to it, and the company can revoke that release at any time. Details: Datenschutz (German).
Questions
Something missing or unclear? Get in touch – we extend this guide with what developers actually need.