> ## 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 SDK

> REST-first JavaScript integration patterns for the live ThreeTone API

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

```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`

## Recommended structure

* 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](/api-reference/introduction)
* Add webhook verification for any event-driven integrations

## Next steps

* [JavaScript examples](/sdks/examples/javascript-examples)
* [API reference](/api-reference/introduction)
