Integration
The Integration service provides CRUD capabilities for integration templates and integration instances (UserKey). It wraps the cloud API (
tcb2018-06-08), and every request carriesBusiness='integration'.Access it via
manager.integration, for example:const { integration } = new CloudBase({secretId: 'Your SecretId',secretKey: 'Your SecretKey',envId: 'Your envId' // Cloud Development environment ID, available in the Tencent Cloud Base console})NoteThe SDK supports two modes:
- Pass-through mode: Pass the
extJSON string directly (encrypt sensitive fields yourself), and the SDK forwards it as-is to the cloud API.- Auto-encryption mode: Pass
envVariablesas plaintext key-value pairs, and the SDK automatically identifies thepasswordfields in the template, retrieves the encryption key from QiCaiShi, performs AES-256-CBC encryption, and assembles theextstring.
listTemplates
1. Description
Function: Get the list of integration templates (UserKey templates)
Declaration: listTemplates(params?: IListTemplatesParams): Promise<IGetUserKeyTemplateListResult>
2. Input Parameters
IListTemplatesParams
| Field | Required | Type | Description |
|---|---|---|---|
| offset | No | Number | Offset, default 0 |
| limit | No | Number | Limit, default 100 |
| authTypeCode | No | String | Filter by auth type code |
| authTypeName | No | String | Filter by auth type name |
| business | No | String | Business type; pass integration for the integration center |
3. Response
IGetUserKeyTemplateListResult
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | No | String | Unique request ID |
| TotalCount | Yes | Number | Total templates |
| KeyTemplateList | Yes | Array<IUserKeyTemplate> | Template list |
IUserKeyTemplate
| Field | Required | Type | Description |
|---|---|---|---|
| AuthTypeCode | Yes | String | Auth type code (template key) |
| AuthTypeName | Yes | String | Auth type name (template display name) |
| Ext | Yes | String | Template dynamic info as JSON string, includes fields definitions |
| AuthURL | No | String | Auth URL (for OAuth-type templates) |
| Icon | No | String | Template icon |
| State | No | String | Status |
| RedirectURI | No | String | Redirect URI |
4. Example
const res = await integration.listTemplates({
limit: 20,
business: 'integration'
})
console.log(res.KeyTemplateList)
listUserKeys
1. Description
Function: Get the list of integration instances (UserKey)
Declaration: listUserKeys(params?: IListUserKeysParams): Promise<IGetUserKeyListResult>
2. Input Parameters
IListUserKeysParams
| Field | Required | Type | Description |
|---|---|---|---|
| name | No | String | Filter by name (fuzzy match) |
| authTypeCode | No | String | Filter by auth type code |
| offset | No | Number | Offset, default 0 |
| limit | No | Number | Limit, default 100 |
| business | No | String | Business type; pass integration for the integration center |
3. Response
IGetUserKeyListResult
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | No | String | Unique request ID |
| TotalCount | Yes | Number | Total instances |
| UserKeyList | Yes | Array<IUserKeyInfo> | Instance list |
IUserKeyInfo
| Field | Required | Type | Description |
|---|---|---|---|
| Name | Yes | String | Integration instance name |
| KeyID | Yes | String | Integration instance ID (unique) |
| AuthTypeCode | Yes | String | Auth type code |
| AuthTypeName | Yes | String | Auth type name |
| Ext | Yes | String | Config JSON string (contains encrypted sensitive values) |
| Description | No | String | Description |
| Status | No | String | Status |
| TicketID | No | String | OAuth-type auth ticket id |
| DemoCodeFunctionName | No | String | Bound sample code cloud function name |
| BindServiceList | No | Object | Bound service list (grouped by Mcp / Apis / Other) |
| CreateAt | No | String | Creation time (ISO 8601) |
| UpdateAt | No | String | Update time (ISO 8601) |
4. Example
const res = await integration.listUserKeys({
name: 'my-key',
business: 'integration'
})
console.log(res.UserKeyList)
getUserKey
1. Description
Function: Get a single integration instance
Declaration: getUserKey(params: IGetUserKeyParams): Promise<IGetOneUserKeyResult>
2. Input Parameters
IGetUserKeyParams
| Field | Required | Type | Description |
|---|---|---|---|
| keyId | Yes | String | Integration instance ID |
| needPwd | No | Boolean | When true, returns the encrypted value of sensitive fields; default false |
| decryptPwd | No | Boolean | When true, the SDK automatically decrypts the password field and returns plaintext (requires needPwd=true) |
| business | No | String | Business type; pass integration for the integration center |
3. Response
IGetOneUserKeyResult
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | No | String | Unique request ID |
| UserKeyInfo | Yes | IUserKeyInfo | Integration instance detail |
See listUserKeys for the
UserKeyInfofield definitions.
4. Example
// Get instance details (without sensitive field values)
const res = await integration.getUserKey({
keyId: 'my-key-id',
business: 'integration'
})
console.log(res.UserKeyInfo)
// Get instance details and auto-decrypt sensitive fields
const resWithPwd = await integration.getUserKey({
keyId: 'my-key-id',
needPwd: true,
decryptPwd: true,
business: 'integration'
})
console.log(resWithPwd.UserKeyInfo)
createUserKey
1. Description
Function: Create an integration instance
Declaration: createUserKey(params: ICreateUserKeyParams): Promise<ICreateUserKeyResult>
Supports two parameter modes:
- Pass-through mode: Pass
ext(an encrypted JSON string), and the SDK forwards it to the cloud API as-is (backward compatible).- Auto-encryption mode: Pass
envVariables(plaintext key-value pairs), and the SDK automatically identifies thepasswordfields in the template, retrieves the encryption key from QiCaiShi, performs AES-256-CBC encryption, and assembles theextstring.- When both are provided,
exttakes precedence.
2. Input Parameters
ICreateUserKeyParams
| Field | Required | Type | Description |
|---|---|---|---|
| name | Yes | String | Integration instance name |
| authTypeCode | Yes | String | Auth type code |
| description | No | String | Description |
| ext | No | String | Config JSON string (pass-through mode; contains encrypted sensitive values) |
| envVariables | No | Record<string, string> | Plaintext environment variables as key-value pairs (auto-encryption mode; SDK automatically encrypts password fields) |
| keyId | No | String | Specify the instance ID (generated by backend if omitted) |
| ticketId | No | String | OAuth-type auth ticket id |
| demoCodeFunctionName | No | String | Bound sample code cloud function name |
| runtimeConfig | No | Record<string, any> | Agent cloud function config |
| business | No | String | Business type; pass integration for the integration center |
3. Response
ICreateUserKeyResult
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | No | String | Unique request ID |
| CreateResult | Yes | Number | Create result (0 means success) |
| DemoCodeFunctionName | No | String | Sample code cloud function name |
4. Example
// Auto-encryption mode: pass plaintext envVariables, SDK automatically encrypts password fields
const res = await integration.createUserKey({
name: 'my-wechat',
authTypeCode: 'weixinoffiaccount',
envVariables: {
appId: 'wx1234567890',
appsecret: 'your-plaintext-secret' // Pass in plaintext, SDK auto-encrypts
},
business: 'integration'
})
console.log(res)
// Pass-through mode: pass pre-encrypted ext JSON string (backward compatible)
const res2 = await integration.createUserKey({
name: 'my-payment',
authTypeCode: 'weixinpaydc',
ext: JSON.stringify({ appId: 'xxx', secret: 'encrypted-value' }),
business: 'integration'
})
console.log(res2)
updateUserKey
1. Description
Function: Update an integration instance
Declaration: updateUserKey(params: IUpdateUserKeyParams): Promise<IUpdateUserKeyResult>
Supports two parameter modes:
- Pass-through mode: Pass
ext(the pre-merged JSON string), and the SDK forwards it to the cloud API as-is.- Auto-encryption mode: Pass
envVariables(plaintext key-value pairs), and the SDK automatically merges them with the existingExtand encrypts thepasswordfields.- When both are provided,
exttakes precedence. When neither is provided, the backend keeps the existingExtunchanged.
2. Input Parameters
IUpdateUserKeyParams
| Field | Required | Type | Description |
|---|---|---|---|
| keyId | Yes | String | Integration instance ID |
| name | No | String | Integration instance name |
| authTypeCode | No | String | Auth type code |
| description | No | String | Description |
| ext | No | String | Config JSON string (pass-through mode; contains encrypted sensitive values) |
| envVariables | No | Record<string, string> | Plaintext environment variables as key-value pairs (auto-encryption mode; SDK automatically merges with existing Ext and encrypts password fields) |
| demoCodeFunctionName | No | String | Bound sample code cloud function name (used by bind-resource) |
| runtimeConfig | No | Record<string, any> | Agent cloud function config |
| business | No | String | Business type; pass integration for the integration center |
3. Response
IUpdateUserKeyResult
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | No | String | Unique request ID |
| UpdateResult | Yes | Number | Update result (0 means success) |
4. Example
// Auto-encryption mode: pass plaintext envVariables, SDK automatically merges with existing Ext and encrypts
const res = await integration.updateUserKey({
keyId: 'my-key-id',
description: 'updated description',
envVariables: {
appId: 'wx1234567890',
appsecret: 'new-plaintext-secret' // Pass in plaintext, SDK auto-merges and encrypts
},
business: 'integration'
})
console.log(res)
// Pass-through mode: pass pre-merged ext JSON string (backward compatible)
const res2 = await integration.updateUserKey({
keyId: 'my-key-id',
description: 'updated description',
ext: JSON.stringify({ appId: 'xxx', secret: 'encrypted-value' }),
business: 'integration'
})
console.log(res2)
deleteUserKey
1. Description
Function: Delete an integration instance
Declaration: deleteUserKey(params: IDeleteUserKeyParams): Promise<IDeleteUserKeyResult>
2. Input Parameters
IDeleteUserKeyParams
| Field | Required | Type | Description |
|---|---|---|---|
| keyId | Yes | String | Integration instance ID |
3. Response
IDeleteUserKeyResult
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | No | String | Unique request ID |
| DeleteResult | Yes | Number | Delete result (0 means success) |
4. Example
const res = await integration.deleteUserKey({
keyId: 'my-key-id'
})
console.log(res)