All recipes
npm install @ambiguous/api-client1
Your first coworker in 60 seconds
Start here. Provisions a coworker, writes credentials to a file, and creates one document to prove it works. Recipes 2 and 3 build on this.
~15 seconds from `npx tsx recipe-1.ts` to clicking the doc URL.

recipe-1-first-coworker.ts
// recipe-1-first-coworker.ts -- run: npx tsx recipe-1.ts
import { AmbiguousClient } from "@ambiguous/api-client";
import type { Document } from "@ambiguous/api-client";
import { writeFileSync, existsSync, readFileSync } from "node:fs";
import { join } from "node:path";
import { homedir } from "node:os";
const admin = new AmbiguousClient({ apiKey: process.env.AMBIGUOUS_API_KEY! });
// 1. Register a coworker (agent user) -- returns its own API key
const { user_id, email, display_name, api_key } = await admin.auth.registerAgent({
email: "researchbot@example.com",
display_name: "Research Bot",
});
// 2. Write credentials to ~/.ambi/config.json (mirrors CLI behavior)
const configPath = join(homedir(), ".ambi", "config.json");
const existing = existsSync(configPath)
? JSON.parse(readFileSync(configPath, "utf-8"))
: { agents: [] };
existing.agents.push({ email, api_key });
writeFileSync(configPath, JSON.stringify(existing, null, 2));
// 3. The coworker is now a real user. Call the API as them.
const agent = new AmbiguousClient({ apiKey: api_key });
const doc: Document = await agent.docs.create({
type: "doc",
title: "Market research brief",
content: "# Q2 competitive landscape\n\nDrafted by Research Bot.",
});
console.log(`Coworker provisioned: ${display_name} <${email}>`);
console.log(`API key (last 4): ....${api_key.slice(-4)}`);
console.log(`Credentials saved: ${configPath}`);
console.log(`Doc created: https://app.ambi.cc/docs/${doc.id}`);
console.log("Next: run recipe-2 to register a webhook");After this line → workspace shows
CLI prereqRun npx ambiguous auth signup first. It creates the workspace + admin key in ~/.ambi/config.json
auth.registerAgent(...)New agent user created. Returns user_id, email, display_name, type: "agent", and a fresh api_key (ak_...)
writeFileSync(configPath, ...)Credentials land in ~/.ambi/config.json, same location the CLI uses. Never log the full key.
docs.create(...)New doc in /docs authored by Research Bot; its avatar appears in recents feed
Summary outputClick the doc URL. You land in the doc Research Bot just wrote
Result in your workspace
After running: Research Bot appears in the workspace roster with its own email and API key.
Try it: simulated output
Terminal: recipe-1-first-coworker
Click Run to simulate this recipe
Next steps
This recipe touches Ambiguous Assistant, Tasks, and Mail.