ck_sandbox_ or ck_live_; new restricted keys start with rk_sandbox_ or rk_live_. Existing ck_ keys remain valid. The organization that created the key determines which data it can reach. Both environments use https://commet.co/api/v1.
Create a key
Choose the path that fits where you are working. You only need one to get started.- Dashboard
- CLI
- MCP
- Select your sandbox organization in the dashboard.
- Go to Settings → API Keys and click Create API Key.
- Choose Full Access for a backend or AI Agents to select resource permissions.
- Enter a descriptive name of up to 32 characters, such as
Local development, and choose Expires In (Days). The dashboard accepts 1–365 days and defaults to 365. - Create the key and copy it before closing the dialog. The full secret is shown only once.
POST /api/v1/api-keys. That request creates another key for the same organization. See Create API key for the request and response.
Limit key permissions
Leavepermissions out to create a full-access key. Provide resource grants to create a restricted key. For example, a key with customer: ["read"] can read customers but cannot change them. Write access requires both "read" and "write". An empty object ({}) grants no resource access.
A restricted key with api_key: ["read", "write"] can create restricted keys with the same or fewer permissions. These keys expire no later than the key that creates them. Restricted keys cannot edit or delete API keys.
Store the key on your server
For local development, save the key in a git-ignored environment file:.env.local
Use the key in your SDK
For Node.js, install the SDK:x-api-key header.
Rotate and promote to live
Use a separate key for each application or deployment that needs independent rotation. To replace a key before it expires:- Create a replacement in the same organization.
- Update the secret in every process using the old key and deploy or restart those processes.
- Verify a successful read with the replacement and confirm the application is using it.
- Delete the old key from Settings → API Keys or through Delete API key.
lastUsedAt in List API keys, can lag up to 5 minutes.
For production, create a key in your live organization and store it separately from sandbox credentials. Do not copy sandbox customer, plan, or subscription IDs into live configuration. Before switching, verify checkout, webhooks, and a renewal in sandbox with the Test Clock.
Next, follow the quickstart to complete your first subscription payment in sandbox.