Overview
The keys command provides tools for managing API keys that enable programmatic
access to the Trix API. You can create keys with different permissions, set expiration times,
and manage their lifecycle.
Aliases: key, ak
Important: API key management requires user login (email/password authentication). If you're currently authenticated with an API key, you'll need to log in with your email and password first:
trix auth login --email [email protected]Create API Keys
Create new API keys for programmatic access to your Trix account. Keys can be configured with different permissions and expiration times.
# Create a basic API key
trix keys create --name "Production API"
# Create with description
trix keys create --name "Dev Key" --description "Development environment"
# Create an admin key
trix keys create --name "Admin Key" --admin
# Create with expiration
trix keys create --name "Temp Key" --expires 720h # 30 days
trix keys create --name "Short-lived" --expires 24h
# Interactive mode
trix keys createSave your key immediately! The full API key is only shown once during creation. You won't be able to see it again. Store it securely.
Create Options
| Option | Description |
|---|---|
--name | Name for the API key (required) |
--description | Description of the key's purpose |
--admin | Grant account admin privileges |
--expires | Set expiration duration (e.g., 720h, 30d) |
List API Keys
View all API keys for your account, including their status, last usage, and creation date.
# List all keys
trix keys list
# Output as JSON
trix keys list -o json
# Filter with jq
trix keys list --jq '.[].name'
trix keys list --jq '[.[] | select(.is_active)]'
trix keys list --jq '[.[] | select(.is_account_admin)]'Example output:
ID NAME PREFIX ADMIN ACTIVE LAST USED CREATED
key_abc123 Production API gdb_prod no yes 2 hours ago Jan 15, 2024
key_def456 Dev Key gdb_dev no yes 5 minutes ago Jan 20, 2024
key_ghi789 Admin Key gdb_admin yes yes 1 day ago Jan 10, 2024Update API Keys
Update properties of an existing API key, including description, active status, and admin privileges.
# Update description
trix keys update key_abc123 --description "Updated description"
# Enable/disable a key
trix keys update key_abc123 --enable
trix keys update key_abc123 --disable
# Grant admin privileges
trix keys update key_abc123 --admin
# Remove admin privileges
trix keys update key_abc123 --no-admin--description, --enable, --disable, --admin, or --no-admin).Update Options
| Option | Description |
|---|---|
--description | Update the key's description |
--enable | Enable the API key |
--disable | Disable the API key |
--admin | Grant account admin privileges |
--no-admin | Remove account admin privileges |
Delete API Keys
Revoke an API key. This action cannot be undone. The key will immediately stop working.
# Delete a key (with confirmation)
trix keys delete key_abc123
# Skip confirmation
trix keys delete key_abc123 --yesCommand Reference
keys Commands
| Command | Description |
|---|---|
create | Create a new API key |
list | List all API keys |
update <key-id> | Update an API key |
delete <key-id> | Delete (revoke) an API key |
Common Examples
Initial Setup
# Create your first API key
trix keys create --name "Production" --description "Main production API key"
# Save the key securely
# The full key (gdb_xxx...) will only be shown once
# Use the key for authentication
export TRIX_API_KEY=gdb_your_key_here
# Test the key
trix whoamiKey Rotation
# Create a new key
NEW_KEY=$(trix keys create --name "Production v2" -o json | jq -r '.key')
# Update your applications to use the new key
# ...
# After verifying the new key works, delete the old one
trix keys delete key_old123 --yesTemporary Access
# Create a short-lived key for temporary access
trix keys create --name "Contractor Access" --expires 168h --description "7-day access for external contractor"
# Create a key for testing
trix keys create --name "Test Key" --expires 24hAudit Keys
# List all keys
trix keys list
# Find inactive keys
trix keys list --jq '[.[] | select(.is_active == false)]'
# Find admin keys
trix keys list --jq '[.[] | select(.is_account_admin)]'
# Export for audit
trix keys list -o json > keys-audit-$(date +%Y%m%d).jsonManage Permissions
# Create a read-only key (standard key without admin)
trix keys create --name "Read Only"
# Create an admin key
trix keys create --name "Admin Access" --admin
# Upgrade a key to admin
trix keys update key_abc123 --admin
# Downgrade from admin
trix keys update key_abc123 --no-admin
# Disable a key temporarily (without deleting)
trix keys update key_abc123 --disable
# Re-enable later
trix keys update key_abc123 --enableBest Practices
Security
- Never commit API keys to version control
- Use environment variables or secure secret management tools
- Rotate keys regularly (every 90 days recommended)
- Use separate keys for different environments (dev, staging, prod)
- Set expiration dates on temporary keys
- Grant admin privileges sparingly
Organization
- Use descriptive names that indicate the key's purpose
- Add detailed descriptions to track key usage
- Regularly audit your keys and delete unused ones
- Document which applications use which keys
Monitoring
# Check when keys were last used
trix keys list
# Identify potentially compromised keys
trix keys list --jq '[.[] | select(.last_used_at == null)]'
# List keys created more than 90 days ago
trix keys list --jq '[.[] | select(.created_at < "'$(date -u -d '90 days ago' +%Y-%m-%dT%H:%M:%SZ)'")]'Next Steps
- Billing - View subscription and usage information
- Authentication - Learn about authentication methods
- REST API Authentication - Use API keys with the REST API
- Security - Security best practices and compliance