Loading...
Loading...
Use CloudBase HTTP API to access CloudBase platform features (database, authentication, cloud functions, cloud hosting, cloud storage, AI) via HTTP protocol from backends or scripts that are not using SDKs.
npx skill4agent add tencentcloudbase/skills http-api-cloudbase@cloudbase/js-sdk@cloudbase/node-sdkenvAuthorization: Bearer <token>searchKnowledgeBasemode=openapiapiNamemysqldbfunctionsauthcloudrunstoragesearchKnowledgeBase({ mode: "openapi", apiName: "mysqldb" })searchKnowledgeBasesearchKnowledgeBasesearchKnowledgeBase({ mode: "openapi", apiName: "<api-name>" })mysqldbfunctionsauthcloudrunstoragesearchKnowledgeBase({ mode: "openapi", apiName: "auth" })⚠️ Warning: Tokens are critical credentials for identity authentication. Keep them secure. API Key must NOT be used in client-side code.
💡 Note: Can be exposed in browsers, used for requesting publicly accessible resources, effectively reducing MAU.
ap-shanghaihttps://{your-env}.api.tcloudbasegateway.com{your-env}cloud1-abchttps://cloud1-abc.api.tcloudbasegateway.comap-singaporehttps://{your-env}.api.intl.tcloudbasegateway.com{your-env}cloud1-abchttps://cloud1-abc.api.intl.tcloudbasegateway.comAuthorization: Bearer <access_token/apikey/publishable_key>< >eymykeyAuthorization: Bearer eymykeycurl -X POST "https://your-env-id.api.tcloudbasegateway.com/v1/functions/YOUR_FUNCTION_NAME" \
-H "Authorization: Bearer <access_token/apikey/publishable_key>" \
-H "Content-Type: application/json" \
-d '{"name": "张三", "age": 25}'https://{envId}.api.tcloudbasegateway.com/v1/rdb/rest/{table}https://{envId}.api.tcloudbasegateway.com/v1/rdb/rest/{schema}/{table}https://{envId}.api.tcloudbasegateway.com/v1/rdb/rest/{instance}/{schema}/{table}envIdinstanceschematable| Header | Parameter | Description | Example |
|---|---|---|---|
| Accept | | Control data return format | |
| Content-Type | | Request content type | |
| Prefer | Operation-dependent feature values | - | |
| Authorization | | Authentication token | |
/v1/rdb/rest/{table}select*class_id(grade,class_number)limitoffsetorderfield.ascfield.desc# Before URL encoding
curl -X GET 'https://your-env.api.tcloudbasegateway.com/v1/rdb/rest/course?select=name,position&name=like.%张三%&title=eq.文章标题' \
-H "Authorization: Bearer <access_token>"
# After URL encoding
curl -X GET 'https://your-env.api.tcloudbasegateway.com/v1/rdb/rest/course?select=name,position&name=like.%%E5%BC%A0%E4%B8%89%&title=eq.%E6%96%87%E7%AB%A0%E6%A0%87%E9%A2%98' \
-H "Authorization: Bearer <access_token>"Content-Range0-9/100/v1/rdb/rest/{table}💡 Note about: When a user is logged in (using AccessToken authentication), the_openidfield is automatically populated by the server with the current user's identity. You do NOT need to manually set this field in INSERT operations - the server will fill it automatically based on the authenticated user's session._openid
curl -X POST 'https://your-env.api.tcloudbasegateway.com/v1/rdb/rest/course' \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "Prefer: return=representation" \
-d '{
"name": "数学",
"position": 1
}'/v1/rdb/rest/{table}curl -X PATCH 'https://your-env.api.tcloudbasegateway.com/v1/rdb/rest/course?id=eq.1' \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "Prefer: return=representation" \
-d '{
"name": "高等数学",
"position": 2
}'⚠️ Important: UPDATE requires a WHERE clause. Use query parameters liketo specify conditions.?id=eq.1
/v1/rdb/rest/{table}curl -X DELETE 'https://your-env.api.tcloudbasegateway.com/v1/rdb/rest/course?id=eq.1' \
-H "Authorization: Bearer <access_token>"⚠️ Important: DELETE requires a WHERE clause. Use query parameters to specify conditions.
| Error Code | HTTP Status | Description |
|---|---|---|
| INVALID_PARAM | 400 | Invalid request parameters |
| INVALID_REQUEST | 400 | Invalid request content: missing permission fields, SQL execution errors, etc. |
| INVALID_REQUEST | 406 | Does not meet single record return constraint |
| PERMISSION_DENIED | 401, 403 | Authentication failed: 401 for identity authentication failure, 403 for authorization failure |
| RESOURCE_NOT_FOUND | 404 | Database instance or table not found |
| SYS_ERR | 500 | Internal system error |
| OPERATION_FAILED | 503 | Failed to establish database connection |
| RESOURCE_UNAVAILABLE | 503 | Database unavailable due to certain reasons |
Prefer: return=representation[]Accept: application/vnd.pgrst.object+json{}Accept: application/vnd.pgrst.object+jsoncurl -i -X GET 'https://{{host}}/v1/rdb/rest/course?select=name,position&name=like.%张三%&title=eq.文章标题'curl -i -X GET 'https://{{host}}/v1/rdb/rest/course?select=name,position&name=like.%%E5%BC%A0%E4%B8%89%&title=eq.%E6%96%87%E7%AB%A0%E6%A0%87%E9%A2%98'searchKnowledgeBasesearchKnowledgeBase({ mode: "openapi", apiName: "<api-name>" })authmysqldbfunctionscloudrunstoragesearchKnowledgeBaseapiName/v1/rdb/rest/{table}env="your-env-id"
token="your-access-token-or-api-key"
base="https://${env}.api.tcloudbasegateway.com"curl -X GET "${base}/v1/rdb/rest/table_name" \
-H "Authorization: Bearer ${token}" \
-H "Content-Type: application/json"{
"code": "ERROR_CODE",
"message": "Error message details",
"requestId": "request-unique-id"
}🌟 IMPORTANT: Default Authentication MethodWhen no specific signup/signin method is specified by the user, ALWAYS use Phone SMS Verification as the default and recommended method. It is:
- ✅ The most user-friendly for Chinese users
- ✅ No password to remember
- ✅ Works for both new users (registration) and existing users (login)
- ✅ Most secure with OTP verification
- ✅ Supported by default in CloudBase
┌─────────────────────────────────────────────────────────────────────────┐
│ Step 1: Send Verification Code │
│ POST /auth/v1/verification │
│ Body: { "phone_number": "+86 13800138000", "target": "ANY" } │
│ ⚠️ IMPORTANT: phone_number MUST include "+86 " prefix WITH SPACE │
│ Response: { "verification_id": "xxx", "expires_in": 600 } │
│ 📝 SAVE verification_id for next step! │
└─────────────────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────────────────┐
│ Step 2: Verify Code │
│ POST /auth/v1/verification/verify │
│ Body: { "verification_id": "<saved_id>", "verification_code": "123456" }│
│ Response: { "verification_token": "xxx" } │
│ 📝 SAVE verification_token for login! │
└─────────────────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────────────────┐
│ Step 3: Sign In with Token │
│ POST /auth/v1/signin │
│ Body: { "verification_token": "<saved_token>" } │
│ Response: { "access_token": "xxx", "refresh_token": "xxx" } │
└─────────────────────────────────────────────────────────────────────────┘"+86 13800138000"verification_idverification_token"+86 13800138000"verification_id