Command Line and API
Besides the graphical interface, HeyS can be operated with the heys command line, or called by other systems over HTTP. This page is for administrators and developers doing system integration.
First: where the command line and the API are
If a task on the desktop asks the agent to run a heys … command, it only gets a message saying that HeyS is a desktop app without a heys command line; it won't start a second HeyS. On the desktop, do things directly in the interface; when you need scripting or batch work, use a server deployment or the command-line package.
The command line shares the same data directory and the same spaces with the server it lives in: a task started from the command line on the server is visible when you sign in to the web app, and vice versa.
The heys command line
Getting the command line
- Docker deployment: it is inside the container; run
docker compose exec heys heys <command>; - Server package: the unpacked directory contains
heys, for example/opt/heys-server/heys; - Command-line package: a zip that unpacks to a single-file executable (with its own runtime, no need to install Node.js) plus resource directories such as
skills/andcase-templates/next to it; these directories must stay with the executable.
If you are told it has no execute permission, run chmod +x heys. If macOS blocks it the first time it runs, click "Open Anyway" in System Settings → Privacy & Security.
General conventions
heys --versionshows the core version, which matches Core version in Settings → About; add--helpafter any command to see all options.- Most query commands support
--jsonfor machine-readable JSON output. - Session, task, project and scheduled task IDs are all 26-character strings; project arguments accept either the ID or the project name.
- Which space a command acts on:
--profile <name>> the environment variableHEYS_PROFILE> the current space set withheys profile use>default. - Bad arguments or a missing object → exit code 1.
heys task runreturns 0 when it finishes, whether the task succeeded or not; to check the result, look at the last event or atheys task get <id> --json.
Where environment variables come from
At startup, commands load .env files automatically without overriding variables that already exist. Priority from high to low:
Each line of .env is KEY=VALUE, with support for an export prefix, # comments and quotes. Values such as model provider keys and the extension market address, written into desktop.yml through the Settings pages or with heys provider add and heys hub config, are also read from there when they aren't found in the shell.
Common global variables:
Starting a task
While it runs, the explanation, tool calls and results of each step are printed live, and the answer is printed word by word at the end. Ctrl+C only stops showing the output; the task keeps running in the background. Reattach later with heys task attach <taskId>.
- Without a current session, every
heys task runis a new session, and the model can't see what was said last time. For a multi-turn conversation, runheys session createfirst, or pass--sessionevery time. - If the session still has an unfinished task, running
heys task run "your follow-up"again attaches the message to that task and continues it; to end it for good, useheys task close <taskId>. - Start the goal with
/skill-nameto choose a skill:heys task run "/docx Convert the README to Word". - When the agent stops to ask a question, the command line lists the options with numbers; just answer:
heys task run --session <sid> "1". - The terminal can't draw charts, so charts in answers are replaced with tables automatically.
Common commands
See Shortcuts and Commands for all options, or add --help after any command. Some examples:
For automation such as pipelines, create sessions with --no-memory so that instructions from the pipeline aren't remembered as things "about you".
What the command line doesn't have: question card buttons, charts in answers, Tab completion, the file panel, Computer Use, the Sprite, skins and font size.
Starting a service from the command line: heys server
For team deployments, use the Docker image or server package from CoWork, Collaboration Node, Web App and Deployment (which include the web app and Apps). If you only want to serve an API to your own systems, you can also start a service directly from the command line:
The arguments are the same as for heys-server in CoWork, Collaboration Node, Web App and Deployment. A service started with heys server has no web app and no Apps, and no APIs for the built-in Office editor, Computer Use or Import sessions.
- Static tokens must be at least 32 characters; with a shorter one the service won't start (
HEYS_ALLOW_WEAK_KEYS=1allows it temporarily); - A static token with the
tokenmethod is not an administrator, so administrator APIs such as space settings, skill installation and environment variables are refused; when you need them, use an administrator account with theaccountsmethod; - Behind a reverse proxy, set
HEYS_TRUSTED_PROXIES; - Run only one service on the same data directory at any one time; the first Ctrl+C shuts down gracefully, the second exits immediately.
HTTP API (REST)
The web app uses this API, and your business systems can call it directly too. The service address is the one your administrator gave you (for example https://heys.example.com), or a colleague's collaboration node at http://<IP>:3777.
Signing in and authentication
After that, send Authorization: Bearer <token> with every request. A few rules:
- With accounts, the token decides which space you can access; a request that names another space is changed back; sessions in other spaces always come back as "not found".
- For addresses the browser loads directly and that can't carry request headers, such as images, download links and event streams, first exchange the token for a temporary ticket with
POST /api/auth/ticket, and put it on the URL as?_ticket=<ticket>. Tickets are valid for 5 minutes and are read-only. The old way of putting the token directly in the URL (?_token=) is still accepted but no longer recommended. POST /api/auth/logoutimmediately invalidates this account's tokens and tickets on all devices; changing the password or the mapped space, or deleting the account, also voids old tokens.- Protection against credential stuffing: after several failed sign-ins in a row for the same account, each sign-in waits a while first (up to 30 seconds); the account is not locked. Too many failures from the same source in a short time get a 429.
Administrator-level APIs (space settings, model providers, environment variables, extension installation, account management, and so on): the none method counts as administrator, the token method does not, and the accounts method follows the account's role.
Running a task
goal is required; the rest are optional: sessionId (a new session is created if omitted), workspace / projectId, pinnedSkills (choose skills), expertName, sessionRefs (reference other sessions), uploadIds (attachments uploaded beforehand), model (which model to use this time), memory: "off" (the new session doesn't use global memory).
Integration notes:
- A task can have several segments (follow-ups, continuations), so terminal events can occur more than once. The event stream ends at an explicit
event: end; don't disconnect on your own as soon as you receivetask.completed. - When the session already has an unfinished task,
/api/tasks/runreturns 409SESSION_HAS_OPEN_TASK(withtaskId); call/continueinstead, or/closeit first. - When the task has already ended,
/continuereturns 409TASK_CLOSED; start a new task with the samesessionId. - In code, check only the
codeand the HTTP status; don't match error messages, since the text changes with theAccept-Languagerequest header. - A chart in an answer is a
```chartcode block (a JSON spec); the API passes it through as-is, and clients that can't draw charts can replace it with a table.
Do the versions match?
The server and the client are released separately. In GET /api/about: version is the product version, coreVersion the core version, apiVersion the API version the server provides, and minApiVersion the oldest client version it still supports.
The client records the version N it was built against: N < minApiVersion → the client is too old and needs upgrading; apiVersion < N → the server is older and new features are unavailable; otherwise they are compatible.
For the full list of API and event fields, ask your administrator or technical support.
OpenAI-compatible API
For systems that just want to "send a sentence and get an answer", you can treat HeyS as a model that does work, and connect with an off-the-shelf OpenAI SDK or LangChain, changing only base_url and api_key.
How things map
You don't need to resend history: HeyS keeps the session history itself, and only the last user message in messages is taken as the goal. extra_body can also carry task_id, profile, project_id, pinned_skills and max_iterations.
Multi-turn conversations: session_id and task_id
To continue from the previous turn, send the same session_id. Ways to pass it, by priority:
If you don't send one, the server generates it and returns it in the response headers x-heys-session / x-heys-task; send it with the next turn. If the session still has an unfinished task, this message continues that task as a follow-up.
Two request headers
With accounts, a model pointing at someone else's space returns 403, and /v1/models lists only your own.
For multi-turn orchestration, follow-ups, file handling and tracking Cases, use the REST API in HTTP API (REST); /v1 is for plugging HeyS into existing systems that only understand the OpenAI format.
