Skip to main content
These examples are backed by source files in the repo and syntax-checked in CI.

Create an agent

const response = await fetch("https://api.threetone.in/v1/convai/agents/create", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "x-api-key": "YOUR_API_KEY",
  },
  body: JSON.stringify({
    name: "Customer Support Agent",
    system_prompt: "You are a helpful customer support representative.",
  }),
});

if (!response.ok) {
  throw new Error(`Create agent failed: ${response.status}`);
}

const agent = await response.json();
console.log(agent.agent_id);
Canonical source file: /examples/javascript/create-agent.mjs

Suggested integrations

  • Next.js or Express route handlers for server-side mutations
  • Background jobs for polling or analytics collection
  • Local MCP usage when you want AI tools to call ThreeTone with guardrails