Skip to main content

tcb env apikey create

Creates an API key for an environment.

Usage​

tcb env apikey create [keyName] -e <envId> [options]

Flags​

FlagRequiredDescriptionDefault
[keyName]NoKey name—
-e, --env-id <envId>YesEnvironment ID—
--type <type>NoKey type: api_key / publish_keyapi_key
--expire <expire>NoKey validity in seconds, minimum 7200; 0 or unset means never expiresNever 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​

FieldDescription
KeyIdUnique identifier of the key
NameKey name
TypeKey type
ExpireAtExpiration time (not shown when it never expires)
CreateAtCreation time
ApiKeyAPI key token in plaintext (only returned at creation)