For AI Agents
Typebar is built to be used by AI agents, not just people. An agent can create an account and get a working API key in a single request, then use the REST API or the MCP server right away. No web sign-up form, no waiting on a human.If you are an agent acting on behalf of a user, confirm with them before you accept the terms and create an account.
0. Check for existing credentials first
If~/.superdocs/agent_credentials.json exists on this machine, a previous agent already created an account. Call GET https://api.superdocs.app/v1/agents/whoami with that api_key and reuse the account — its documents and remaining quota carry over. Sign up fresh only when the project deliberately needs its own separate account. A legacy ~/.typebar/agent_credentials.json counts too; if both files exist, use the more recently written one.
1. Sign up
curl
-f never writes an error reply, umask 077 makes the file readable only by you, a file that already holds a key is never touched (the command prints “credentials already saved” and changes nothing), and a missing or empty file is replaced by the new reply. A leftover agent_credentials.json.new appears only when another process saved credentials first: reuse the saved file, then delete the .new file. On Windows (cmd.exe or PowerShell), save only a successful reply, to a new file under %USERPROFILE%\.superdocs that only your user can read, and never over an agent_credentials.json that already holds a key.
The saved response looks like this (abridged: long values are cut short with …):
mcp_setup block gives you copy-paste commands to connect right away. They carry a placeholder (${SUPERDOCS_API_KEY}, <api_key> or <your key>), never your key, so the key appears only once in the reply, in api_key.
Optional body fields: agent_name (a label), operated_by_email (your operator’s email, used only if you hand off later), and model_metadata (free-form details about your model).
2. Use your key
Put the key in an environment variable without printing it (this reads the saved file and needsjq):
REST
https://api.superdocs.app/mcp (streamable HTTP) with the same Bearer key. In Claude Code, one command connects it:
Claude Code
${SUPERDOCS_API_KEY}, never the key. Claude Code expands it each time it connects, so SUPERDOCS_API_KEY must be exported in the shell that launches claude, in every new terminal, not only the one where you ran the command. To keep it set, add the export line above to your shell profile (~/.zshrc or ~/.bashrc): it reads the file and never holds the key itself. If the variable is not set when claude starts, Claude Code sends the reference as written, the server answers 401 naming SUPERDOCS_API_KEY, and the server does not connect. MCP servers load when a session starts, so start a new Claude Code session after adding it. User scope (-s user) makes the server available from every folder; use -s local for the current folder only, or -s project to share it with your repository through .mcp.json (only the reference is committed). On Windows PowerShell, set the variable with $env:SUPERDOCS_API_KEY = (Get-Content -Raw ~/.superdocs/agent_credentials.json | ConvertFrom-Json).api_key; in cmd.exe, put double quotes around the header instead of single quotes.
No variable at all. Claude Code’s headersHelper runs a command each time it connects and sends the headers that command prints, so nothing has to be exported and the connection survives restarts:
Claude Code (no variable)
.mcp.json) connects only after you approve it in Claude Code once.
Other clients (Cursor, Claude Desktop, Windsurf, VS Code, Cline, Continue) take the same URL and header; where a client’s MCP config supports an environment-variable reference (for example ${env:SUPERDOCS_API_KEY} in Cursor), use it instead of pasting the key. See MCP Setup. Call the get_account_status tool anytime to check your remaining operations.
Edit a file in one call
Upload a document and give every instruction for the job in one request. Typebar finds the targets, does the work and returns the result with a download link for the edited file, in the same format. Your agent never reads the document. The Agent recipe has the whole job as copy-paste commands, including the wait and the held-changes steps.REST
response (what was done, per instruction), session_id, turn_index (pass it to /v1/sessions/{session_id}/revert to undo the turn), document_changes (counts only, so the reply stays small on any document size) and download (a 15-minute link; send -F export_format=pdf for another format). Follow-ups on the same document go to POST /v1/chat with the same session_id.
To create a document instead, drop file and attach each source with -F "sources=@./source.pdf" (repeat it); the message is the brief. The call waits up to wait_seconds (85 here, at most 110), so it fits a shell command limit. A longer job answers 202 and keeps running: GET /v1/sessions/{session_id}/result?wait_seconds=85&export_format=docx waits for it in one call (run it again on another 202). Never re-send the POST: that starts a second job. If document_changes.requires_approval is true, Typebar held changes for review and nothing from this turn is in the document yet (a download now is the document as it was before this turn: save it before you stop or ask your user anything). Rows marked requires_review need your user’s own go: without it, never approve them. If any row is requires_review and you can ask your user, ask before the approve call (it declines every row it does not name), and include the ones they approve in that same call. To apply the others, POST /v1/chat/{session_id}/approve with job_id, "approved": true, "wait_for_result": false and changes naming exactly those rows (one {change_id, approved: true} each), then wait with the result call. That call closes every row it does not name as declined: not applied, and never approvable later, so tell your user which changes were not applied and that they can ask for them again. Until held changes are decided, a new chat answers 409.
Over MCP the same job is about four calls: request_upload_url, its curl_example, one chat with upload_id, upload_filename, response_mode: "summary" and export_format: "docx", then the reply’s download.curl_example.
Long generations
For document-scale generations (a whole handbook or long report in one turn), usePOST /v1/chat/async — it returns a job_id immediately and reports progress via GET /v1/jobs/{job_id}. A very long plain sync /v1/chat call can be cut off by a client or gateway timeout before its reply reaches you, so send long turns async (you can also stream their progress). Editing patterns, placement, verification, and billing are covered in the Agent editing playbook.
3. Quota and handing off to a human
Your account is a normal free account: 500 operations per month, the same as a human free account. When you near the cap and want to keep going, hand the account to your human so they can take it over and pay:curl
working_context (a short note on where you are running) so the email is recognizable and does not look like spam. The response includes a short takeover_code (like ABCD-1234).
Show that takeover code to your human, and tell them where to find it if they ask (you can also save it to a file such as ~/.superdocs/takeover-code.txt). We email a one-time link to the address you gave. Your human opens it, signs in, and enters the takeover code, then takes the account over in place, so you keep all your work and your API key keeps working the whole time. They can then upgrade or pay from the app.
The takeover code is a security check: it proves the person adopting the account is really the one running you, so a link that reaches the wrong inbox cannot be used to take the account. Never email the code or post it anywhere public. (If your human already has a Typebar account, they sign into that instead.)
Adopt-link errors: a wrong takeover code returns
403 with the number of attempts remaining in detail. After too many wrong codes the link is permanently disabled and returns 410 Gone; that old link can never work again, so send a new POST /v1/agents/handoff to get a fresh one. An expired or unknown link returns 404 (links expire after about 24 hours).Fully autonomous with no human who can upgrade for you?
POST https://api.superdocs.app/v1/agents/request-upgrade with your key (optionally a short note). We don’t offer agent-native card payment yet, but we’re gauging demand and will follow up. A human handoff upgrades you immediately; this path is for when there truly is no human.Rules and limits
- Use one account per agent or user. Do not create multiple accounts to get around the free limit.
- Check your status anytime with
GET /v1/agents/whoamior theget_account_statusMCP tool. It tells you how many operations remain so you can hand off before you hit the cap.