Skip to main content
Practical, copy-pasteable examples.
Each demo assumes you have an API key (hero_ak_*) — see Working with the API if you don’t.

1. Fetch your default workspace

The simplest possible call — verifies your key is wired up correctly and returns the workspace your account lands on by default.
If you get a 401, the key is wrong or expired.
If you get a 403 with WorkspaceScopeViolation, the key is workspace-scoped and the default workspace isn’t in its scope — pass an explicit workspaceId to a scoped endpoint instead.

2. Create a document programmatically

Two calls: list your projects, then create a document inside one.
1

List your projects

Pick the _id of the project you want to write into.
2

Create the document

Returns { "data": { "_id": "...", "name": "My new doc", ... } }. Open it in the HERO app at app.myhero.so/<projectId>/<documentId>/editor.

3. Stream an AI agent (and watch it use tools)

POST /api/ai-agent/stream runs HERO’s general agent and emits Server-Sent Events as it thinks, calls tools, and edits your workspace. You see the model’s reply stream in token-by-token, get notified every time it invokes a tool (create-document, add-row, search-web, and 50+ others), and at the end receive a change summary of every entity it touched — undoable in one shot if the user changes their mind. The five event types over text/event-stream:

Quick peek with cURL

-N disables curl’s buffering so you see the chunks land in real time.
You’ll see a flurry of data: {"type":"delta",...} lines as the agent narrates what it’s about to do, then data: {"type":"tool_call",...} as it invokes create-document and write-document-markdown, then a final data: {"type":"done",...} with the change summary.

Full Node.js client — parse, react, capture

Undo a run

If the agent did something unwanted, ship the sessionId from the done event back:
Every entity the agent touched (documents, tables, projects) is rolled back to the snapshot it took before the run.

Lighter alternatives

  • For a single-prompt rewrite (no tool use, no streaming), use POST /ai-agent/transform-text with one of the built-in operations (rephrase, fixGrammar, simplify, translate, shorten, summarize, etc.).
  • For an agentic run where you don’t need incremental output, use POST /ai-agent — same body shape, returns the full chatMessages array in one response.
  • For an interactive widget — a calculator, dashboard, slide deck, prototype or game — use POST /ai-agent/generate-html. It streams the HTML as it is written and ends with one done event holding the finished document, styled with HERO’s design system; pass mentions (documents, folders, tables…) and attachments to build from your own content:

4. Drive HERO from your AI client

The MCP path. After installing for your client, try prompts like these in Cursor, Claude Desktop, or Claude Code — the AI will route them to the right HERO tools automatically.
The MCP server exposes 100+ tools across documents, tables, projects, signing, comments, versions and automations — browse the full Tool catalog.

5. Receive a webhook

Subscribe to events (Webhooks) and accept POSTs at your endpoint.
Node.js / Express
Verify the signature header before trusting the payload — see Webhooks for the signing scheme.