API Key Management
Manage API Keys for Cloud Development environments, used for server-side or client-side access to Cloud Development resources via key-based authentication.
v3.1.0+
Overview
Cloud Development API Keys are divided into two types:
| Type | Description | Use Case | Limit |
|---|---|---|---|
api_key | Server-side admin credential | Server-side API calls (not yet available) | Up to 5 per environment |
publish_key | Frontend anonymous access credential | Frontend anonymous access to Cloud Development resources | 1 per environment |
Notice
The api_key type is not yet available. Currently only publish_key type is supported.
Create API Key
Create a new API Key:
tcb env apikey create [keyName] -e <envId> [options]
Parameters:
| Parameter | Description | Default |
|---|---|---|
[keyName] | Key name (optional) | — |
-e, --env-id <envId> | Environment ID | — |
--type <type> | Key type: api_key / publish_key | api_key |
--expire <expire> | Key validity period (seconds), minimum 7200; 0 or unset means never expires | Never expires |
Examples:
# Create an API Key named my-key
tcb env apikey create my-key -e env-xxx
# Create a publish_key type key
tcb env apikey create frontend-key -e env-xxx --type publish_key
# Create a key with 24-hour validity
tcb env apikey create server-prod -e env-xxx --expire 86400
# Output in JSON format
tcb env apikey create my-key -e env-xxx --json
Important
After successful creation, the API Key token (plaintext) is returned only once at creation time. Please store it securely. The full key plaintext cannot be retrieved in subsequent queries.
Output Description:
| Field | Description |
|---|---|
KeyId | Unique identifier of the Key |
Name | Key name |
Type | Key type |
ExpireAt | Expiration time (not shown if never expires) |
CreateAt | Creation time |
ApiKey | API Key token in plaintext (only returned at creation) |
Query API Key List
Query the API Key list for the current environment:
tcb env apikey list -e <envId> [options]
Parameters:
| Parameter | Description | Default |
|---|---|---|
-e, --env-id <envId> | Environment ID | — |
--type <type> | Filter by key type: api_key / publish_key | api_key |
--limit <limit> | Number of items per page | 10 |
--offset <offset> | Offset, starting from 0 | 0 |
Examples:
# Query API Key list
tcb env apikey list -e env-xxx
# Filter by publish_key type
tcb env apikey list -e env-xxx --type publish_key
# Paginated query
tcb env apikey list -e env-xxx --limit 5 --offset 5
# Output in JSON format
tcb env apikey list -e env-xxx --json
Output Description:
| Field | Description |
|---|---|
KeyId | Unique identifier of the Key |
Name | Key name |
ApiKey | API Key (partially masked) |
ExpireAt | Expiration time |
CreateAt | Creation time |
Delete API Key
Delete a specified API Key:
tcb env apikey delete <keyId> -e <envId>
Parameters:
| Parameter | Description |
|---|---|
<keyId> | The API Key ID to delete (required) |
-e, --env-id <envId> | Environment ID |
--yes | Skip confirmation prompt |
Examples:
# Delete a specified API Key (with interactive confirmation)
tcb env apikey delete key-xxxxxxxx -e env-xxx
# Skip confirmation and delete directly
tcb env apikey delete key-xxxxxxxx -e env-xxx --yes
# Output in JSON format
tcb env apikey delete key-xxxxxxxx -e env-xxx --yes --json
Tips
Use tcb env apikey list to view available KeyIds.
Command Reference
| Command | Description | Version |
|---|---|---|
tcb env apikey create [keyName] | Create API Key | v3.1.0+ |
tcb env apikey list | Query API Key list | v3.1.0+ |
tcb env apikey delete <keyId> | Delete API Key | v3.1.0+ |