tcb env apikey create
Creates an API key for an environment.
Usage
tcb env apikey create [keyName] -e <envId> [options]
Flags
| Flag | Required | Description | Default |
|---|---|---|---|
[keyName] | No | Key name | — |
-e, --env-id <envId> | Yes | Environment ID | — |
--type <type> | No | Key type: api_key / publish_key | api_key |
--expire <expire> | No | Key validity in seconds, minimum 7200; 0 or unset means never expires | Never expires |
Example
# 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 creation, the API key token (plaintext) is returned only once at creation time. Store it securely. Later queries cannot retrieve the full plaintext.
Output fields
| Field | Description |
|---|---|
KeyId | Unique identifier of the key |
Name | Key name |
Type | Key type |
ExpireAt | Expiration time (not shown when it never expires) |
CreateAt | Creation time |
ApiKey | API key token in plaintext (only returned at creation) |