Skip to main content

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:

TypeDescriptionUse CaseLimit
api_keyServer-side admin credentialServer-side API calls (not yet available)Up to 5 per environment
publish_keyFrontend anonymous access credentialFrontend anonymous access to Cloud Development resources1 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:

ParameterDescriptionDefault
[keyName]Key name (optional)
-e, --env-id <envId>Environment ID
--type <type>Key type: api_key / publish_keyapi_key
--expire <expire>Key validity period (seconds), minimum 7200; 0 or unset means never expiresNever 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:

FieldDescription
KeyIdUnique identifier of the Key
NameKey name
TypeKey type
ExpireAtExpiration time (not shown if never expires)
CreateAtCreation time
ApiKeyAPI 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:

ParameterDescriptionDefault
-e, --env-id <envId>Environment ID
--type <type>Filter by key type: api_key / publish_keyapi_key
--limit <limit>Number of items per page10
--offset <offset>Offset, starting from 00

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:

FieldDescription
KeyIdUnique identifier of the Key
NameKey name
ApiKeyAPI Key (partially masked)
ExpireAtExpiration time
CreateAtCreation time

Delete API Key

Delete a specified API Key:

tcb env apikey delete <keyId> -e <envId>

Parameters:

ParameterDescription
<keyId>The API Key ID to delete (required)
-e, --env-id <envId>Environment ID
--yesSkip 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

CommandDescriptionVersion
tcb env apikey create [keyName]Create API Keyv3.1.0+
tcb env apikey listQuery API Key listv3.1.0+
tcb env apikey delete <keyId>Delete API Keyv3.1.0+