# Turso Platform API

> Programmatically manage databases, groups, organizations, and tokens with the Turso Platform API.
> Canonical HTML: https://tursodb.cn/docs/api-reference/introduction/
> Upstream Source (MIT): https://docs.turso.tech/api-reference/introduction
> Language: en

---
## Quickstart with the TypeScript SDK

The fastest way to use the Platform API from JavaScript or TypeScript is the official [`@tursodatabase/api`](https://www.npmjs.com/package/@tursodatabase/api) client:

```bash
npm install @tursodatabase/api
```

```ts
import { createClient } from "@tursodatabase/api";

const turso = createClient({
  org: process.env.TURSO_ORG!,
  token: process.env.TURSO_PLATFORM_TOKEN!,
});

// Create a database
const db = await turso.databases.create("user-abc123", { group: "default" });

// Generate a scoped auth token for that database
const { jwt } = await turso.databases.createToken("user-abc123");

// Delete it when no longer needed
await turso.databases.delete("user-abc123");
```

For the raw HTTP reference, see the resource endpoints below.

## Common use cases

### Database per user / database per agent (multi-tenant)

Provision a dedicated database per user or per AI agent. Each entity gets its own isolated SQLite database that you create, token-scope, and tear down via the API.

```ts
import { createClient } from "@tursodatabase/api";

const turso = createClient({
  org: process.env.TURSO_ORG!,
  token: process.env.TURSO_PLATFORM_TOKEN!,
});

// On user signup or agent creation — provision a database
const db = await turso.databases.create(`agent-${agentId}`, { group: "default" });

// Generate a scoped token for that database
const { jwt } = await turso.databases.createToken(`agent-${agentId}`);

// Store db.hostname and jwt for the session
```

Once the database is created, connect to it from your application:

* **Over the wire** — query the database remotely using [`@tursodatabase/serverless`](/docs/sdk/ts/quickstart/)
* **Local-first with sync** — sync the database to and from a local file using [`@tursodatabase/sync`](/docs/sync/usage/)

### Platform / reseller

Create and manage databases on behalf of your end users. Use the Platform API to build your own database-as-a-service on top of Turso.

```ts
// List all databases in your organization
const databases = await turso.databases.list();

// Get details for a specific database
const db = await turso.databases.get("customer-db");
```

<div class="doc-cards">
<a class="doc-card" href="/docs/api-reference/quickstart/"><div class="doc-card-title"><span>API Quickstart</span><span class="doc-card-arrow" aria-hidden="true">→</span></div><p class="doc-card-desc">Step-by-step guide to create your first database with the API.</p></a>
</div>


## API Resources

Start integrating the Turso API with your platform in a few simple steps.

<div class="doc-cards">
<a class="doc-card" href="/api-reference/groups"><div class="doc-card-title"><span>Groups API</span><span class="doc-card-arrow" aria-hidden="true">→</span></div><p class="doc-card-desc">Create and manage where your database is located.</p></a>
<a class="doc-card" href="/api-reference/databases"><div class="doc-card-title"><span>Database API</span><span class="doc-card-arrow" aria-hidden="true">→</span></div><p class="doc-card-desc">Create, manage and generate auth tokens for databases.</p></a>
<a class="doc-card" href="/api-reference/locations"><div class="doc-card-title"><span>Locations API</span><span class="doc-card-arrow" aria-hidden="true">→</span></div><p class="doc-card-desc">Fetch all available locations where your database group can be located.</p></a>
<a class="doc-card" href="/api-reference/organizations"><div class="doc-card-title"><span>Organizations API</span><span class="doc-card-arrow" aria-hidden="true">→</span></div><p class="doc-card-desc">Manage your organization, it's members and invites.</p></a>
<a class="doc-card" href="/api-reference/tokens"><div class="doc-card-title"><span>API Tokens API</span><span class="doc-card-arrow" aria-hidden="true">→</span></div><p class="doc-card-desc">Create, validate and revoke API keys that can be used to access the API.</p></a>
<a class="doc-card" href="/api-reference/audit-logs"><div class="doc-card-title"><span>Audit Logs API</span><span class="doc-card-arrow" aria-hidden="true">→</span></div><p class="doc-card-desc">Monitor logs of what's happening in your organization.</p></a>
</div>
