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 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
_id of the project you want to write into.2
Create the document
{ "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.
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 thesessionId from the done event back:
Lighter alternatives
- For a single-prompt rewrite (no tool use, no streaming), use
POST /ai-agent/transform-textwith 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 fullchatMessagesarray 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 onedoneevent holding the finished document, styled with HERO’s design system; passmentions(documents, folders, tables…) andattachmentsto 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.5. Receive a webhook
Subscribe to events (Webhooks) and accept POSTs at your endpoint.Node.js / Express