Skip to main content

Get Environment API Key

After creating your first environment, you need to allocate an independently isolated CloudBase environment to each user (employee, customer, tenant), and issue environment access credentials for them.

CloudBase provides API Key as environment access credentials: the API Key is bound by the CloudBase platform to a specified environment ID and strictly validated on the server side. Even if leaked, it can only access the user's own environment and cannot access other users' data laterally. API Key is the only recommended environment access method in platform integration scenarios.

Integration Overview

The entire platform integration consists of three steps:

  1. Create environments: create an exclusive environment for each user through APIs, see Enable and create your first environment
  2. Get environment API Key: issue an API Key for each environment and deliver it to users (this document)
  3. Connect environments with API Key: users configure the API Key into their Agent tools to operate their own environments, see Connect environments with API Key

Create API Key

Create Through APIs

Call the Tencent Cloud CreateApiKey API to create an api_key type key for the user environment:

// Example: create an API Key for a user environment
const result = await tcbClient.CreateApiKey({
EnvId: userEnvId, // the user's CloudBase environment ID
KeyType: "api_key", // server-side administrator-level key
KeyName: `user-${userId}`,
// ExpireIn: 7776000 // Optional: validity period (seconds); not set means no expiration
});
// result.ApiKey is the plaintext key, returned only once; keep it safe

Create Manually in the Console

You can also create it manually in the console: CloudBase Console → Environment → API Key Management.

Distribute to Users

The platform distributes CLOUDBASE_ENV_ID and CLOUDBASE_API_KEY to the corresponding users through its own channels (in-site messages, email, etc.). Users fill in the environment ID + API Key in the MCP configuration of their Agent tool to directly operate their own CloudBase environment, without any additional login flow.

Security Notes

Security warning

api_key has full administrator permissions on the environment. It can be provided to users through secure channels for configuring local MCP, or stored only on the platform server side; do not write it into business frontends, browser-executable code, application code repositories, or public channels. It is recommended to rotate it regularly, with a maximum of 5 keys per environment.

Next Steps

After obtaining the API Key, you can connect the environment to your Agent platform:

Connect environments with API Key