Authentication Commands
The `compozy auth` command group provides comprehensive authentication and API key management capabilities. These commands support both interactive TUI and automation-friendly JSON output modes.
Overview
compozy auth [command] [flags]
API Key Management
User Administration
Interactive TUI
Automation Ready
API Key Management
Generate API Key
Create a new API key for authenticating with the Compozy API:
# Interactive mode (TUI)
compozy auth generate
# With parameters
compozy auth generate --name "CI/CD Pipeline" --description "For automated deployments"
# With expiration date
compozy auth generate --name "Temporary Key" --expires "2024-12-31"
# JSON output for automation
compozy auth generate --name "API Integration" --output json
Flags
Flag | Description | Format |
---|---|---|
--name | Name/description for the API key | String |
--description | Detailed description of the API key usage | String |
--expires | Expiration date | YYYY-MM-DD |
--output | Output format | json | table |
List API Keys
View all API keys with their status and metadata:
# List all keys (TUI)
compozy auth list
# Sort by creation date
compozy auth list --sort created
# Filter by status
compozy auth list --status active
# JSON output
compozy auth list --output json
Flags
Flag | Description | Options |
---|---|---|
--sort | Sort by field | created | name | expires |
--status | Filter by status | active | expired | revoked |
--output | Output format | json | table |
Revoke API Key
Revoke an existing API key:
# Interactive selection (TUI)
compozy auth revoke
# Revoke specific key
compozy auth revoke --key "amp_1234567890"
# JSON output
compozy auth revoke --key "amp_1234567890" --output json
Flags
Flag | Description | Format |
---|---|---|
--key | API key to revoke | String |
--output | Output format | json | table |
User Management
Create User
Create a new user account:
# Interactive mode (TUI)
compozy auth create-user
# With parameters
compozy auth create-user --email "user@example.com" --name "John Doe"
# With role assignment
compozy auth create-user --email "admin@example.com" --name "Admin User" --role admin
# JSON output
compozy auth create-user --email "user@example.com" --name "John Doe" --output json
Flags
Flag | Description | Format/Options | Required |
---|---|---|---|
--email | User's email address | Yes | |
--name | User's full name | String | No |
--role | User role | admin | user | viewer | No |
--output | Output format | json | table | No |
List Users
View all users in the system:
# List all users (TUI)
compozy auth list-users
# Filter by role
compozy auth list-users --role admin
# Sort by creation date
compozy auth list-users --sort created
# JSON output
compozy auth list-users --output json
Flags
Flag | Description | Options |
---|---|---|
--role | Filter by role | admin | user | viewer |
--sort | Sort by field | created | email | name |
--output | Output format | json | table |
Update User
Update user information:
# Interactive mode (TUI)
compozy auth update-user
# Update specific user
compozy auth update-user --email "user@example.com" --name "Jane Doe"
# Change user role
compozy auth update-user --email "user@example.com" --role admin
# JSON output
compozy auth update-user --email "user@example.com" --role admin --output json
Flags
Flag | Description | Format/Options | Required |
---|---|---|---|
--email | User's email address (to identify user) | Yes | |
--name | New name for the user | String | No |
--role | New role for the user | admin | user | viewer | No |
--output | Output format | json | table | No |
Delete User
Remove a user from the system:
# Interactive selection (TUI)
compozy auth delete-user
# Delete specific user
compozy auth delete-user --email "user@example.com"
# Force deletion without confirmation
compozy auth delete-user --email "user@example.com" --force
# JSON output
compozy auth delete-user --email "user@example.com" --output json
Flags
Flag | Description | Format/Options |
---|---|---|
--email | Email of user to delete | |
--force | Skip confirmation prompt | Boolean |
--output | Output format | json | table |
Authentication Flow
Initial Setup
When setting up Compozy for the first time:
Create the first admin user
compozy auth create-user --email "admin@company.com" --name "Admin" --role admin
Generate an API key
compozy auth generate --name "Admin API Key"
Set the API key in your environment
export COMPOZY_API_KEY="amp_your_key_here"
Using API Keys
API keys can be provided in multiple ways:
export COMPOZY_API_KEY="amp_1234567890"
compozy workflow list
Best Practices
- Key Rotation
Regularly rotate API keys for security. Set expiration dates and create new keys before old ones expire.
- Descriptive Names
Use clear, descriptive names for API keys to identify their purpose and usage.
- Role-Based Access
Assign appropriate roles to users based on their responsibilities. Use viewer role for read-only access.
- Audit Trail
The auth system maintains an audit trail of all key usage. Use
compozy auth list
to review key activity. - Secure Storage
Never commit API keys to version control. Use environment variables or secure secret management systems.
Next Steps
Development Commands
Development server commands for Compozy with hot reload and debugging
Configuration Commands
The `compozy config` command group provides comprehensive tools for managing, validating, and diagnosing your Compozy configuration. These commands ensure your setup is correct, optimized, and ready for production deployment.