> ## Documentation Index
> Fetch the complete documentation index at: https://docs.threetone.in/llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript Examples

> Runnable JavaScript examples for authenticating and creating agents

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

## Create an agent

```javascript theme={null}
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
