dub.studioDOCS
Developers

Authentication and organizations

Authenticate versioned API requests with API keys, sessions, or bearer tokens.

Every versioned API request lives under /v1. It can authenticate with an organization API key, a Better Auth cookie session, or a bearer token. Each request is scoped to one organization.

API keys for servers

Create the key in the dashboard while the intended workspace is selected. The key is already scoped to that organization, so server requests only need x-api-key.

import { client, getBilling } from "@ai-dubbing/sdk";

client.setConfig({
  baseUrl: "https://api.example.com",
  headers: { "x-api-key": process.env.AI_DUBBING_API_KEY! },
});

const { data: wallet } = await getBilling({ throwOnError: true });
console.log(wallet.creditBalance);

Keep API keys on your server. Do not put them in a Vite/Next public environment variable, a mobile bundle, or browser storage.

Sessions for Studio and first-party apps

Studio uses the same /v1 contract with its Better Auth cookie session. If the user can belong to multiple organizations, send x-organization-id to select the active workspace.

For third-party server integrations, use an API key rather than forwarding a user cookie or bearer token.

On this page