Your app needs two values:
.env.local
CMS0_API_BASE_URL="https://environment-key.example.com/api"
CMS0_API_KEY="cms0_..."The base URL points at one environment. The key controls what the caller can do.
Endpoint formats
Hosted environments can expose one or both runtime URL formats:
Endpoint formats
https://environment-key.your-domain.com/api
https://app.example.com/api/content/environment-keyUse the endpoint shown on the environment page. Do not build the URL by hand unless you control the workspace domain settings.
Treat API keys as credentials. Create separate keys for local development, CI, and production deploys.
Create an API key
- Open the environment or organization settings where API keys are managed.
- Create a key for local development or CI.
- Copy the secret immediately.
- Store it in your app environment manager.
For a first integration, give the key schema publish and content read/write access. Reduce permissions once your deployment path is stable.
Use the key from @cms0/cms0
src/cms0.ts
import { cms0 } from "@cms0/cms0";
export const cms = cms0<RootSchema>({
apiConfig: {
baseUrl: process.env.CMS0_API_BASE_URL,
key: process.env.CMS0_API_KEY,
},
});Use the key from the CLI
cms0.config.ts
import "dotenv/config";
import { defineConfig } from "@cms0/cms0/config";
export default defineConfig({
entry: "./src/cms0.ts",
api: {
baseUrl: process.env.CMS0_API_BASE_URL,
key: process.env.CMS0_API_KEY,
},
});Success check
Run:
Terminal
pnpm exec cms0 buildThe schema should appear in the selected hosted environment.