Skip to main content
Use JavaScript against the live ThreeTone API today with fetch. This keeps your integration production-ready while the public SDK package is finalized.

Runtime requirements

Node.js 18+ includes fetch by default, so you can call ThreeTone directly without extra dependencies.

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
  • Keep your ThreeTone API key in server-side environment variables
  • Wrap repetitive API calls in small helper functions
  • Link mutating operations back to the API reference
  • Add webhook verification for any event-driven integrations

Next steps