Skip to main content

Create Integration

Use the tcb integration create [keyId] command to create integration instances through configuration files. When a keyId positional argument is provided, only the matching integration is created; otherwise all integrations in the configuration file are created in batch.

Quick Start

1. Initialize Integration Configuration

Different integrations have different environment variable requirements. It is recommended to use the tcb config init integration command to generate a configuration template:

# Interactive initialization (will automatically fetch available integration types for selection)
tcb config init integration <keyId>

# Directly specify integration type
tcb config init integration <keyId> --type weixinpaydc

After execution, the CLI interactively guides you through environment selection, integration type selection, and field template generation, then writes the result to cloudbaserc.json. For the detailed workflow, see Initialize Configuration.

Example output:

? Select integration type WeChat Pay (weixinpaydc)
? Enter integration name my-pay

Configuration saved to /path/to/cloudbaserc.json

📝 Next steps:
1. Edit the cloudbaserc.json file to complete integration configuration parameters
2. Run tcb integration create to create integration instances

📋 Field descriptions:
- mch_id (required) - Merchant ID
- api_key (required) - Sensitive field

2. Complete Configuration

Edit the generated cloudbaserc.json file and replace placeholders with actual values:

{
"envId": "env-abc123",
"integrations": [
{
"keyId": "key-abc123",
"name": "key-abc123",
"authTypeCode": "weixinpaydc",
"description": "WeChat Pay integration",
"envVariables": {
"mch_id": "your-mch-id",
"api_key": "your-api-key"
}
}
]
}

3. Create Integration

tcb integration create

Configuration File Mode

tcb integration create reads the integrations field from the cloudbaserc.json configuration file to create integration instances. You need to configure the integrations field in the configuration file first, then execute the command to create.

Configuration File Format

Add the integrations field in cloudbaserc.json:

{
"integrations": [
{
"keyId": "key-abc123",
"name": "my-integration",
"authTypeCode": "custom",
"description": "My integration",
"envVariables": {
"AppId": "your-app-id",
"AppSecret": "your-app-secret"
},
"demoCodeFunctionName": "my-function"
}
]
}

Configuration Fields

For field types, required status, and descriptions, see Configuration File - Integration. Optional values for authTypeCode can be queried using the tcb integration types command.

Multi-line sensitive fields (such as privateKey, apiV3Key) support the @ file reference syntax; see Configuration File - Integration - Read Field Values from a File for details.

Command Parameters

ParameterDescriptionRequired
<keyId>Integration instance identifier to create (positional, matches the keyId in cloudbaserc.json); if not specified, all integrations are created in batchNo
--yesSkip all confirmations (batch creation)No

Tips:

  • When <keyId> is not specified, you will be prompted whether to batch create all integrations in the configuration file
  • When <keyId> is specified, only the matching integration will be created

Usage Examples

Batch Create Integrations

If multiple integrations are configured in the configuration file, you will be prompted whether to batch create:

# Interactive confirmation for batch creation
tcb integration create

# Skip confirmation, batch create all integrations directly
tcb integration create --yes

Create Single Integration

If you only want to create one integration from the configuration file, you can pass the keyId positional argument:

# Create only the integration with keyId key-abc123
tcb integration create key-abc123

# Skip confirmation, create the specified integration directly
tcb integration create key-abc123 --yes

Output Example

✓ Integration instance created successfully: my-integration

Next steps:
View details tcb integration get <key-id>
Bind cloud function tcb integration bind-resource <key-id> --function <function-name>

Batch creation completed: 1 succeeded, 0 failed

Batch Creation

You can configure multiple integration instances in the integrations array to create in batch:

{
"integrations": [
{
"keyId": "key-abc123",
"name": "integration-1",
"authTypeCode": "custom"
},
{
"keyId": "key-def456",
"name": "integration-2",
"authTypeCode": "wechat"
}
]
}

After executing tcb integration create, the CLI will concurrently create these integration instances (up to 5 per batch) and output the creation results.

Error Handling

If the configuration file format is incorrect, the CLI will report an error and list all error messages:

Configuration file format error:
1. integrations[0].keyId cannot be empty
2. integrations[0].authTypeCode cannot be empty

Please fix the configuration file and re-execute.

Notes

  • keyId is the unique identifier of the integration instance and is required
  • name is only a display name and may be duplicated; it defaults to keyId when not set
  • Auth type cannot be modified after creation
  • Key ID will be automatically generated after successful creation (format: key-[32-bit hexadecimal])
  • If demoCodeFunctionName is configured, it will be automatically bound to the specified cloud function after successful creation