CloudBase for Platform
What is CloudBase for Platform
A solution for AI Coding, Vibe Coding, and similar platforms (e.g. Lovable, Bolt.new, Vercel v0, Figma Make) that lets any platform configure and manage the backend on behalf of its users. Platforms can offer a seamless, out-of-the-box backend experience without exposing the complexity of databases, cloud functions, or object storage—users get a working app from a single prompt or a few clicks.
What you get: An isolated environment per tenant, each containing a database, cloud functions, static hosting, and a unified HTTP access endpoint. Resources are isolated between tenants; creation, billing, deployment, database, and monitoring are all managed programmatically via Tencent Cloud APIs.
Use cases: SaaS, internal platforms, multi-tenant systems, or AI Coding / Vibe Coding platforms that want isolated backend capabilities per customer/tenant and management via API rather than console only.
Unit of management: The environment. One environment = one tenant's full set of resources (database, cloud functions, HTTP access service, static hosting, etc.). Typically one tenant, one environment. All operations are done programmatically via the Tencent CloudBase API.
Account and environment relationship: Uses a single-account model—one Tencent Cloud account (root or sub-user with CloudBase permissions) can create multiple environments. Each tenant maps to one environment; all resources and billing belong to that account for unified management. Environment count is subject to account quotas; you can query the environment quota before creating. To increase the limit, contact us.
Account, environment, and resource hierarchy:
Creating environments and billing
Create an environment for each new tenant and manage billing and quotas.
Steps
Step 1: Confirm prerequisites
Before creating, verify account status and available resources:
- Check service activation: CheckTcbService
- Query environment quota: DescribeEnvLimit
- Get available regions: DescribeTcbRegions
- Get available packages: DescribeBaasPackageList
Step 2: Call CreateEnv to create the environment
Call CreateEnv. The API places and pays the order automatically. Key parameters:
| Parameter | Description |
|---|---|
PackageId | Package ID, e.g. baas_personal; retrieve options with DescribeBaasPackageList |
Alias | Environment alias |
Resources | Resource types to provision at creation; see table below |
Period | Duration in months (default 1) |
Tags | Environment tags for access isolation and resource grouping; recommended to tag by tenant ID or product line |
Resources values:
| Value | Description |
|---|---|
flexdb | Document database (NoSQL), MongoDB-style API |
storage | Object storage (CloudBase storage) |
function | Cloud Functions (including HTTP functions) |
Choose the resource types your use case needs. Other resources (e.g. MySQL) can be enabled after environment creation.
Step 3: Wait for provisioning and confirm status
Environment provisioning is asynchronous. Poll DescribeEnvs until the environment status is available, then check usage and billing:
- Query environment billing info: DescribeEnvBilling
- Query environment quota usage: DescribeEnvLimit
Quota notes: COS resources and Cloud Functions (non-Shanghai regions) both have account-level or regional quotas. If you plan to create a large number of environments, discuss quotas with the CloudBase team first.
Environment lifecycle API reference
- Create environment: CreateEnv
- List environments: DescribeEnvs
- Destroy environment: DestroyEnv
- Reinstate environment: ReinstateEnv
- Renew environment: RenewEnv
- Change plan: ModifyEnvPlan
Deploying backend for tenants
Requests enter through the HTTP access service and are routed to the corresponding cloud function. Supports REST APIs, WebSocket, and container image deployment.
Complete call sequence from getting environment info to publicly reachable:
Steps
Step 1: Get environment and log config
Call DescribeEnvs; extract LogsetId / TopicId from EnvInfo.LogServices[0] and pass as ClsLogsetId / ClsTopicId to CreateFunction for log delivery.
Step 2: Package the code
Zip the function directory and Base64-encode it, 50 MB limit. For larger packages, upload to COS first and reference via CosBucketName / CosObjectName / CosBucketRegion (bucket name without -appid suffix, path starts with /).
Step 3: Create or update the function
Call CreateFunction or UpdateFunctionCode. Required: Type: 'HTTP', Namespace (environment ID), Handler. For WebSocket, additional parameters are required—see WebSocket functions.
Step 4: Wait for function ready
Poll ListFunctions until Status = Active.
Step 5: Configure HTTP access route
Call CreateCloudBaseGWAPI. Key parameters: EnableUnion: true, Path, ServiceId (environment ID), Type: 6, Name (function name), AuthSwitch: 2 (auth off), PathTransmission: 2 (path pass-through), EnableRegion: true, Domain.
Step 6: Wait for service ready
Poll DescribeCloudBaseGWAPI until APISet[0].UnionStatus = 1 to get the public access URL.
(Optional) Bind custom domain
Call BindCloudBaseAccessDomain with ServiceId (environment ID), Domain, BindFlag: 2. For HTTPS, pass CertId—request the certificate in the SSL console first. For domains on Tencent Cloud DNSPod, use DescribeRecordFilterList to check whether a CNAME record exists; if not, call CreateRecord to create it.
These APIs can be called via the Manager SDK commonService. You can also use the Tencent Cloud SDK 3.0 to call Cloud Functions APIs directly. Multi-language support: Python, Java, PHP, Go, Node.js, .NET, C++, Ruby.
Cloud Functions API reference
Pass the CloudBase environment ID as Namespace to operate on functions within that environment. See SCF API overview for full parameters.
- List functions: ListFunctions
- Create function: CreateFunction
- Update function code: UpdateFunctionCode
- Update function config: UpdateFunctionConfiguration
- Get function detail: GetFunction
- Delete function: DeleteFunction
- Invoke function: Invoke
- Get function code download URL: GetFunctionAddress
WebSocket functions
WebSocket functions extend the standard HTTP function. Pass these additional fields to CreateFunction:
ProtocolType: 'WS',
ProtocolParams: {
WSParams: {
IdleTimeOut: 7200 // idle connection timeout, 10–7200 s
}
},
Timeout: 7200 // function timeout, must be >= IdleTimeOut, 15–7200 s
Note:
Timeoutmust be ≥IdleTimeOut, otherwise function creation will fail.
Single-instance concurrency (Session-Based for WebSocket, Request-Based for HTTP):
InstanceConcurrencyConfig: {
DynamicEnabled: 'FALSE',
MaxConcurrency: 10,
Type: 'Session-Based', // WebSocket: Session-Based; HTTP: Request-Based
SessionConfig: {
SessionExpireTime: 7200,
IdleSessionExpireTime: 3600,
SessionDestroyStrategy: 'IdleDestroy',
SessionKeyType: 'Header',
SessionKey: 'x-ws-session'
},
InstanceIsolationEnabled: 'FALSE'
}
Container image deployment
Suited for complex dependencies, large packages, or custom runtime environments.
Prerequisites:
- Authorize image pull: Grant the cloud function role the
QcloudAccessForSCFRoleInPullImagepolicy—one-time operation: Click to authorize - Prepare image repository: Create a repository in Tencent Container Registry (TCR); see Get access credentials and Push image.
- Image requirements: Linux-based
amd64image; container must listen on port 9000.
On Apple Silicon Macs or other ARM hosts, you must add --platform linux/amd64—otherwise the deployed function will fail to start:
docker build --platform linux/amd64 -t your-image-name .
When deploying, replace Code.ZipFile with Code.ImageConfig in CreateFunction:
Code: {
ImageConfig: {
ImageType: 'personal', // personal edition repository
ImageUri: 'ccr.ccs.tencentyun.com/your-ns/your-image:tag',
// RegistryId: '' // required for enterprise edition repository
}
}
Reference: ImageConfig parameter description
HTTP access service API reference
- Create route: CreateCloudBaseGWAPI
- Modify route: ModifyCloudBaseGWAPI
- List routes: DescribeCloudBaseGWAPI
- Describe service: DescribeCloudBaseGWService
Domains and secure domains
Bind custom domains and certificates for tenant environments' static hosting or HTTP access service; maintain a secure domain allowlist for origins that may call CloudBase.
Steps
Step 1: Request an SSL certificate
Before binding an HTTPS domain, request or upload a certificate in the SSL console to obtain a CertId.
Step 2: Bind custom domain
Choose the appropriate API based on the target:
- HTTP access service domain: call BindCloudBaseAccessDomain with
ServiceId(environment ID),Domain,BindFlag: 2; for HTTPS also passCertId. - Static hosting domain: call CreateHostingDomain; the task is asynchronous—poll DescribeHostingDomainTask until complete.
Step 3: Configure DNS CNAME
After binding, add a CNAME record at your DNS provider pointing to the CloudBase hostname (e.g. xxx.tcbaccess.tencentcloudbase.com). For domains on Tencent Cloud DNSPod:
- Check whether the CNAME record exists: DescribeRecordFilterList
- If not, create it: CreateRecord, set
Valueto the CloudBase hostname
Access works only after both binding and DNS propagation are complete.
Step 4: Add secure domains (optional)
Secure domains control which front-end origins can call CloudBase. Add your tenant front-end domains to the allowlist:
- Add secure domain: CreateAuthDomain
- List secure domains: DescribeAuthDomains
Domain API reference
- Bind HTTP access service domain: BindCloudBaseAccessDomain
- Bind static hosting domain: CreateHostingDomain
- Query static hosting domain task status: DescribeHostingDomainTask
- Add secure domain: CreateAuthDomain
- List secure domains: DescribeAuthDomains
Database
Each environment includes two database options; tenants are isolated per environment.
- Document database (FlexDB / NoSQL): Collection/document storage, MongoDB-style API; collection CRUD, index management. Enable by including
flexdbinResourcesat environment creation. - Relational database (MySQL): Standard SQL and DDL, table management; front-end can access via Web SDK with a Supabase-style API.
- Permissions and security: Database-level ACL and table-level security rules for read/write and row-level access control.
Document database
Steps
Step 1: Enable
Include flexdb in Resources when calling CreateEnv; no additional steps required.
Step 2: Create collections
Call CreateTable with EnvId and the collection name.
Step 3: Manage indexes and permissions
- Query or update collection indexes: UpdateTable
- Configure read/write ACL and security rules to control tenant data access
Document database API reference
- Create collection: CreateTable
- Describe collection: DescribeTable
- List collections: ListTables
- Update collection indexes: UpdateTable
- Delete collection: DeleteTable
- Modify database ACL: ModifyDatabaseACL
- Get database ACL: DescribeDatabaseACL
- Query security rules: DescribeSecurityRule
MySQL
Steps
Step 1: Enable MySQL
Call CreateMySQL to enable. The operation is asynchronous—poll for completion:
- Query enable result: DescribeCreateMySQLResult
- Query task status: DescribeMySQLTaskStatus
Step 2: Initialize schema
Once enabled, call RunSql to execute DDL statements such as CREATE TABLE and CREATE INDEX.
Step 3: Configure accounts and access
- List existing accounts: DescribeAccounts
- Reset account password: ResetAccountPassword
- Modify account privileges (isolate read/write per tenant): ModifyAccountPrivileges
MySQL API reference
Lifecycle management (tcb.tencentcloudapi.com):
- Enable MySQL: CreateMySQL
- Query enable result: DescribeCreateMySQLResult
- Query task status: DescribeMySQLTaskStatus
- Describe cluster: DescribeMySQLClusterDetail
- Execute SQL: RunSql
- Destroy MySQL: DestroyMySQL
Account management (cynosdb.tencentcloudapi.com):
- List accounts: DescribeAccounts
- Reset password: ResetAccountPassword
- Modify privileges: ModifyAccountPrivileges
- Modify account config: ModifyAccountParams
Connection and cluster (cynosdb.tencentcloudapi.com):
- Enable public access: OpenWan
- Disable public access: CloseWan
- Describe cluster params: DescribeClusterParams
- Modify cluster params: ModifyClusterParam
Backup (cynosdb.tencentcloudapi.com):
- Create manual backup: CreateBackup
- Delete manual backup: DeleteBackup
- Get backup download URL: DescribeBackupDownloadUrl
Monitoring and logging
View per-environment metrics and HTTP access service status, and search CLS logs for troubleshooting and usage analysis.
Steps
Step 1: Query monitoring data
Choose the appropriate granularity:
- Environment-level monitoring curves (calls, traffic, etc.): DescribeCurveData
- Environment-level monitoring metrics: DescribeGraphData
- HTTP access service (gateway) monitoring: DescribeGatewayData
Step 2: Search logs
Call SearchClsLog with:
EnvId: environment ID- Time range
QueryString: CLS syntax, e.g.module:database,src:app
Returns up to 100 results per call with cursor pagination up to 10,000 total.
Monitoring and logging API reference
- Query monitoring curves: DescribeCurveData
- Query monitoring data: DescribeGraphData
- Query gateway monitoring: DescribeGatewayData
- Search user call logs: SearchClsLog
Development and integration options
Depending on your stack and scenario, you can manage environments and resources with:
| Option | Use case | Docs |
|---|---|---|
| Manager SDK (Node.js) | Integrate in your system or scripts; recommended | Manager SDK |
| Manager API | Call REST API directly or from your backend | CloudBase API intro |
| MCP tools | AI Coding platforms (Cursor, Claude Code, etc.); AI agent calls CloudBase | CloudBase MCP, Skills |
MCP supports two connection modes—see Connection modes:
Local mode (recommended): MCP Server runs locally via npx; full functionality including file upload and template download. Requires Node.js.
{
"mcpServers": {
"cloudbase": {
"command": "npx",
"args": ["@cloudbase/cloudbase-mcp@latest"],
"env": {
"CLOUDBASE_ENV_ID": "<env_id>",
"TENCENTCLOUD_SECRETID": "<SecretId>",
"TENCENTCLOUD_SECRETKEY": "<SecretKey>"
}
}
}
}
Hosted mode: MCP Server runs on Tencent Cloud; IDE connects via HTTP. No local Node.js required, but local file operations (e.g. template download) are not supported.
{
"mcpServers": {
"cloudbase": {
"type": "http",
"url": "https://tcb-api.cloud.tencent.com/mcp/v1?env_id=<env_id>",
"headers": {
"X-TencentCloud-SecretId": "<SecretId>",
"X-TencentCloud-SecretKey": "<SecretKey>"
}
}
}
}
Hosted mode supports disabling specific plugins via the disable_plugins URL parameter (e.g. &disable_plugins=rag&disable_plugins=env). Available plugins: env, database, functions, hosting, storage, setup, rag, cloudrun, gateway, security-rule, capi, etc. See MCP tools for the full list.
Suggested implementation order
- Environment creation and billing: Create a single-tenant environment, enable billing, and support usage queries.
- Deploy backend: Deploy HTTP cloud functions to expose APIs or WebSocket.
- HTTP access service and domain: Configure routes and custom domain for exposure and access control.
- Database and permissions: Enable database for tenants, create tables, configure permissions and security rules.
- Monitoring and logging: Use metrics and CLS logs for troubleshooting and usage analysis.
Terminology
| Term | Description |
|---|---|
| Environment | One tenant's full set of resources (database, cloud functions, HTTP access service, static hosting, etc.); typically one tenant per environment. |
| HTTP cloud function | On-demand cloud function exposed via HTTP access service; suited for REST APIs and light logic. |
| HTTP access service | Unified HTTP entry that routes requests to HTTP cloud functions (term used in Tencent Cloud docs). |
References
Official docs
AI Coding / MCP
- CloudBase MCP
- MCP tools list
- MCP connection modes (local / hosted)
- Rules / Skills (GitHub)
- Project templates
Platform integrations