Complete command reference for the Cosmic CLI. For a quick overview, see the README.
- Interactive Shell
- Global Options
- Authentication
- Context & Navigation
- Objects
- Types
- Media
- Media Folders
- Billing
- Repositories
- Deployments
- Webhooks
- Team
- Domains
- Workflows
- Agents
- AI Generation
- Interactive Chat
- Shortcut Commands
- Configuration
- Command Aliases
Start an interactive shell session where you can run commands without the cosmic prefix.
cosmic shellAlias: cosmic sh
$ cosmic shell
Cosmic Shell v1.0.0
Logged in as: you@example.com
Context: my-workspace / my-project / production
Type commands without "cosmic" prefix. Use "!" for system shell.
Type "help" for commands, "exit" to quit.
cosmic my-workspace/production> ls
cosmic my-workspace/production> objects list
cosmic my-workspace/production> cd posts
cosmic my-workspace/production> !git status
cosmic my-workspace/production> exit
Goodbye!
$
| Feature | Description |
|---|---|
| No prefix needed | Type ls instead of cosmic ls |
| System commands | Use ! prefix for shell commands (!ls, !git status, etc.) |
| Dynamic prompt | Shows current workspace/bucket context |
| Command history | Use arrow keys to navigate command history |
| Context updates | Prompt updates when context changes (after cd, use, etc.) |
| Command | Description |
|---|---|
help |
Show available commands |
exit, quit |
Exit the shell |
!<command> |
Run system shell command |
ls # List contents at current level
cd <path> # Navigate to project/bucket/type
pwd # Show current location
use [workspace] # Set workspace (or "-" for default)
context # Show current contextobjects list # List objects
objects get <id> # Get object details
objects types # List object types
media list # List media fileschat # Start AI chat
content # Content mode chat
build # Build mode chat
update [repo] # Update repo mode chat
automate # Automate mode chat (agents & workflows)
ai generate <prompt> # Generate text
ai image <prompt> # Generate image
ai audio <text> # Generate audio (TTS)types list # List object types
media folders list # List media folders
billing usage # Show project usage
billing plans list # List available plans
agents list # List agents
workflows list # List workflows
repos list # List repositories
webhooks list # List webhooks
team list # List team members
domains list # List domainsThese options work with all commands:
| Option | Description |
|---|---|
--json |
Output as JSON for scripting/automation |
-v, --verbose |
Enable verbose output |
--no-color |
Disable colored output |
--help |
Show help for command |
--version |
Show CLI version |
| Variable | Description |
|---|---|
COSMIC_DEBUG=1 |
Enable debug output with detailed error information |
Login to your Cosmic account with email/password or a Personal Access Token.
# Interactive email/password login
cosmic login
# Login with a Personal Access Token
cosmic login --token cos_YOUR_TOKENOptions:
| Flag | Description |
|---|---|
-e, --email <email> |
Email address |
-p, --password <password> |
Password |
-t, --token <token> |
Personal Access Token (cos_...) |
Environment variable: Set COSMIC_TOKEN to authenticate without running cosmic login. This takes priority over stored credentials.
export COSMIC_TOKEN=cos_YOUR_TOKENCreate tokens at Account Settings > API Tokens.
Clear stored credentials.
cosmic logoutShow current authenticated user.
cosmic whoamiSet the working context (workspace, project, bucket). Runs interactively to let you select from available options.
# Interactive selection
cosmic use
# Switch to a specific workspace
cosmic use <workspace-slug>
# Switch to default projects (no workspace)
cosmic use -
cosmic use --default
# With bucket keys (no login required)
cosmic use --bucket=<slug> --read-key=<key> --write-key=<key>Options:
| Option | Description |
|---|---|
-d, --default |
Switch to default projects (no workspace) |
--bucket <slug> |
Bucket slug |
--read-key <key> |
Bucket read key |
--write-key <key> |
Bucket write key |
Show current working context.
cosmic contextList available workspaces.
cosmic workspaces
cosmic workspaces --jsonList projects in current workspace.
cosmic projects
cosmic projects --jsonList available AI models.
cosmic models
cosmic models --jsonList contents at current navigation level.
cosmic ls # List at current level
cosmic ls / # List all projects
cosmic ls /project-id # List buckets in project
cosmic ls /project/bucket # List object types in bucketNavigate the content hierarchy.
cosmic cd project-id # Navigate into project
cosmic cd bucket-slug # Navigate into bucket
cosmic cd posts # Navigate into object type
cosmic cd .. # Go up one level
cosmic cd / # Go to rootShow current navigation location.
cosmic pwdList objects in current bucket.
cosmic objects list
cosmic objects ls # Alias
cosmic objects list --props "id,title,type" # Select specific fieldsOptions:
| Option | Description |
|---|---|
-t, --type <slug> |
Filter by object type |
-s, --status <status> |
Filter by status (published, draft, any) |
-l, --limit <n> |
Limit results (default: 10) |
-p, --props <props> |
Properties to return (comma-separated, e.g. "id,title,slug,metadata") |
-d, --depth <n> |
Depth for nested object references |
--skip <n> |
Skip results (for pagination) |
--json |
Output as JSON |
Get object details.
cosmic objects get <id>
cosmic objects get <id> --json
cosmic objects get <id> --props "id,title,metadata" --depth 2Options:
| Option | Description |
|---|---|
-p, --props <props> |
Properties to return (comma-separated) |
-d, --depth <n> |
Depth for nested object references |
--json |
Output as JSON |
Create a new object (interactive).
cosmic objects create
cosmic objects create --type=posts
cosmic objects create --type=posts --title="My Post"Options:
| Option | Description |
|---|---|
--type <slug> |
Object type slug |
--title <title> |
Object title |
--slug <slug> |
Object slug |
--status <status> |
Status (published, draft) |
--content <content> |
Content/body text |
--metadata <json> |
Metadata as JSON string |
--json |
Output as JSON |
Update an existing object.
cosmic objects update <id> --title="New Title"
cosmic objects update <id> --metadata='{"key":"value"}'Options:
| Option | Description |
|---|---|
--title <title> |
New title |
--slug <slug> |
New slug |
--status <status> |
New status |
--content <content> |
New content |
--metadata <json> |
New metadata (JSON) |
--json |
Output as JSON |
Delete an object.
cosmic objects delete <id>
cosmic objects rm <id> # Alias
cosmic objects delete <id> --force # Skip confirmationPublish a draft object.
cosmic objects publish <id>List object types in current bucket.
cosmic objects types
cosmic objects types --jsonList object types in current bucket.
cosmic types list
cosmic types ls # Alias
cosmic types list --jsonOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Get object type details including metafields.
cosmic types get <slug>
cosmic types get posts --jsonOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Create a new object type.
cosmic types create
cosmic types create --title "Blog Posts"
cosmic types create --title "Posts" --slug posts --emoji "📝"
cosmic types add # AliasOptions:
| Option | Description |
|---|---|
--title <title> |
Object type title |
--slug <slug> |
Object type slug (auto-generated from title) |
--singular <name> |
Singular display name |
--emoji <emoji> |
Emoji icon |
--singleton |
Create as singleton type |
--json |
Output as JSON |
Update an object type.
cosmic types update <slug> --title "New Title"
cosmic types update posts --emoji "✍️"
cosmic types edit posts --singular "Post" # AliasOptions:
| Option | Description |
|---|---|
--title <title> |
New title |
--slug <slug> |
New slug |
--singular <name> |
New singular name |
--emoji <emoji> |
New emoji |
--singleton |
Set as singleton |
--no-singleton |
Unset singleton |
--json |
Output as JSON |
Delete an object type and all its objects.
cosmic types delete <slug>
cosmic types rm <slug> # Alias
cosmic types delete <slug> --force # Skip confirmationOptions:
| Option | Description |
|---|---|
-f, --force |
Skip confirmation |
Duplicate an object type (copies structure, not objects).
cosmic types duplicate <slug>
cosmic types dup <slug> # Alias
cosmic types duplicate posts --jsonOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
List media files.
cosmic media list
cosmic media ls # AliasOptions:
| Option | Description |
|---|---|
--folder <folder> |
Filter by folder |
--limit <n> |
Limit results |
--json |
Output as JSON |
Get media file details.
cosmic media get <id>
cosmic media get <id> --jsonUpload a file to the media library.
cosmic media upload ./image.png
cosmic media upload ./photo.jpg --folder=photos
cosmic media upload ./hero.png --alt-text="Hero image"Options:
| Option | Description |
|---|---|
-f, --folder <folder> |
Target folder |
-a, --alt-text <text> |
Alt text for accessibility |
--json |
Output as JSON |
Delete a media file.
cosmic media delete <id>
cosmic media rm <id> # Alias
cosmic media delete <id> --force # Skip confirmationMove media files into a folder.
cosmic media move <ids...> --folder <folderSlug>Options:
| Option | Description |
|---|---|
-f, --folder <folder> |
Required. Target folder slug |
Examples:
cosmic media move abc123 --folder photos
cosmic media move abc123 def456 --folder documentsRemove media files from their folder (unfile them).
cosmic media unfolder <ids...>Examples:
cosmic media unfolder abc123
cosmic media unfolder abc123 def456Manage media folders within a bucket. Folders are nested under the media command.
List all media folders in the current bucket.
cosmic media folders list
cosmic media folders ls # Alias
cosmic media folders list --jsonOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Create a new media folder.
cosmic media folders create
cosmic media folders add # Alias
cosmic media folders create --title "Photos"
cosmic media folders create --title "Photos" --slug photos --emoji "📸"Options:
| Option | Description |
|---|---|
--title <title> |
Folder title (prompted if not provided) |
--slug <slug> |
Folder slug (auto-generated from title) |
--emoji <emoji> |
Folder emoji icon |
--json |
Output as JSON |
Update a media folder.
cosmic media folders update <slug> --title "New Name"
cosmic media folders edit <slug> --emoji "🖼️" # Alias
cosmic media folders update photos --slug imagesOptions:
| Option | Description |
|---|---|
--title <title> |
New title |
--slug <slug> |
New slug |
--emoji <emoji> |
New emoji |
--json |
Output as JSON |
Delete a media folder. Media files in the folder will be unfiled but not deleted.
cosmic media folders delete <slug>
cosmic media folders rm <slug> # Alias
cosmic media folders delete <slug> --force # Skip confirmationOptions:
| Option | Description |
|---|---|
-f, --force |
Skip confirmation |
Manage project billing, plans, addons, and usage. Requires a project to be selected (use cosmic cd to navigate to a project).
Show project usage statistics (API requests, storage, AI tokens, users, buckets).
cosmic billing usage
cosmic billing usage --jsonOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Open the Stripe billing portal in your browser to manage payment methods, view invoices, and more.
cosmic billing portalList available plans with pricing.
cosmic billing plans list
cosmic billing plans ls # Alias
cosmic billing plans list --jsonOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Subscribe to a plan. Shows an interactive plan picker if no price ID is provided. Requires confirmation before proceeding.
cosmic billing plans subscribe
cosmic billing plans upgrade # Alias
cosmic billing plans subscribe --price-id price_123abcOptions:
| Option | Description |
|---|---|
--price-id <priceId> |
Stripe price ID (skips interactive selection) |
--json |
Output as JSON |
Cancel the current plan subscription.
cosmic billing plans cancel
cosmic billing plans cancel --force # Skip confirmationOptions:
| Option | Description |
|---|---|
-f, --force |
Skip confirmation |
List available addons with pricing and subscription status. Shows actual quantities for per-unit addons (users, buckets, AI tokens).
cosmic billing addons list
cosmic billing addons ls # Alias
cosmic billing addons list --jsonOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Subscribe to an addon. Shows an interactive picker with current subscription status if no IDs are provided. Quantity-based addons (additional users, buckets, AI tokens) prompt for quantity and default to the current value. AI input and output tokens are managed together in a single form. All purchases require confirmation before proceeding.
cosmic billing addons subscribe
cosmic billing addons add # Alias
cosmic billing addons subscribe --addon-id prod_123 --price-id price_456
cosmic billing addons subscribe -q 5 # Set quantity for per-unit addonsOptions:
| Option | Description |
|---|---|
--addon-id <addonId> |
Stripe addon/product ID |
--price-id <priceId> |
Stripe price ID |
-q, --quantity <number> |
Quantity for per-unit addons (prompted if not provided) |
--json |
Output as JSON |
Cancel an addon subscription.
cosmic billing addons cancel <addonId>
cosmic billing addons rm <addonId> # Alias
cosmic billing addons cancel <addonId> --forceOptions:
| Option | Description |
|---|---|
-f, --force |
Skip confirmation |
Open the billing management page in your browser.
cosmic billing openNote: Quantity-based addons (additional users, buckets, AI tokens) are managed through
cosmic billing addons subscribe, which will prompt for quantities when applicable.
List connected GitHub repositories.
cosmic repos list
cosmic repos ls # Alias
cosmic repos # Default action
cosmic repositories list # Full aliasOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Get repository details.
cosmic repos get <id>
cosmic repos get <id> --jsonConnect a GitHub repository.
cosmic repos connect
cosmic repos connect --url https://github.com/user/repo
cosmic repos add --url https://github.com/user/repo # AliasOptions:
| Option | Description |
|---|---|
-n, --name <name> |
Repository name |
-u, --url <url> |
GitHub repository URL |
-f, --framework <fw> |
Framework (nextjs, react, vue, nuxt, astro, svelte, other) |
--json |
Output as JSON |
Disconnect a repository (does not delete the GitHub repo).
cosmic repos delete <id>
cosmic repos rm <id> # Alias
cosmic repos delete <id> --force # Skip confirmationClone a repository locally and auto-create a .env file with Cosmic bucket API keys.
cosmic repos clone # Interactive selection
cosmic repos clone <repositoryId> # Clone by repository ID
cosmic repos clone <github-url> # Clone by GitHub URL
cosmic repos clone <id> -d my-project # Custom directory name
cosmic repos clone <id> -b develop # Clone specific branch
cosmic repos clone <id> --no-env # Skip .env creationOptions:
| Option | Description |
|---|---|
-d, --directory <dir> |
Target directory name (default: repo name) |
-b, --branch <branch> |
Branch to clone (default: repo's default branch) |
--no-env |
Skip creating the .env file |
--json |
Output as JSON |
What it does:
- Clones the repository using
git clone - Creates a
.envfile with:COSMIC_BUCKET_SLUG- Your bucket slugCOSMIC_READ_KEY- API read keyCOSMIC_WRITE_KEY- API write keyNEXT_PUBLIC_COSMIC_BUCKET_SLUG- For Next.js client-sideNEXT_PUBLIC_COSMIC_READ_KEY- For Next.js client-side
Examples:
# Interactive - shows list of connected repos to choose from
cosmic repos clone
# Clone by repository ID
cosmic repos clone 507f1f77bcf86cd799439011
# Clone a GitHub URL
cosmic repos clone https://github.com/cosmicjs/nextjs-blog
# Clone to a specific directory
cosmic repos clone 507f1f77bcf86cd799439011 -d my-blog
# Clone a specific branch
cosmic repos clone 507f1f77bcf86cd799439011 -b develop
# Clone without creating .env (if you have your own setup)
cosmic repos clone 507f1f77bcf86cd799439011 --no-envOutput example:
Cloning my-blog into my-blog...
Cloning into 'my-blog'...
remote: Enumerating objects: 150, done.
...
✓ Repository cloned to my-blog
Fetching bucket API keys...
✓ API keys configured
✓ Created .env with Cosmic bucket keys
Environment Variables
COSMIC_BUCKET_SLUG my-bucket
COSMIC_READ_KEY abc123...
COSMIC_WRITE_KEY xyz789...
Next steps
1. cd my-blog
2. npm install # or bun install
3. npm run dev # Start development server
Manage environment variables for repository deployments. These are synced to Vercel when you deploy.
List environment variables for a repository.
cosmic repos env list <repoId>
cosmic repos env ls <repoId> # Alias
cosmic repos env list <repoId> --jsonAdd an environment variable.
cosmic repos env create <repoId>
cosmic repos env add <repoId> # Alias
cosmic repos env create <repoId> -k API_KEY -v secret123
cosmic repos env create <repoId> -k API_KEY -v secret123 -t production,preview
cosmic repos env create <repoId> -k NEXT_PUBLIC_SITE_URL -v https://example.com --type plainOptions:
| Option | Description |
|---|---|
-k, --key <key> |
Environment variable key |
-v, --value <value> |
Value |
-t, --target <targets> |
Target environments: production, preview, development (comma-separated, default: all) |
--type <type> |
encrypted (default) or plain (for client-side vars like NEXT_PUBLIC_*) |
--json |
Output as JSON |
Edit an existing environment variable.
cosmic repos env edit <repoId> API_KEY -v new-value
cosmic repos env edit <repoId> API_KEY -t production
cosmic repos env edit <repoId> API_KEY --type plainOptions:
| Option | Description |
|---|---|
-v, --value <value> |
New value |
-t, --target <targets> |
Target environments (comma-separated) |
--type <type> |
encrypted or plain |
--json |
Output as JSON |
Delete an environment variable.
cosmic repos env delete <repoId> API_KEY
cosmic repos env rm <repoId> API_KEY # Alias
cosmic repos env delete <repoId> API_KEY -f # Skip confirmationManage custom domains for repository deployments. Domains are added to the Vercel project linked to the repository.
List domains for a repository.
cosmic repos domains list <repoId>
cosmic repos domains ls <repoId> # AliasOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Add a domain to a repository.
cosmic repos domains create <repoId> www.example.com
cosmic repos domains add <repoId> www.example.com # Alias
cosmic repos domains create <repoId> www.example.com -r example.com
cosmic repos domains create <repoId> blog.example.com --redirect-status 302Options:
| Option | Description |
|---|---|
-r, --redirect <url> |
Redirect URL or domain |
--redirect-status <code> |
Redirect status code: 301, 302, 307, 308 (default: 301) |
--json |
Output as JSON |
Update domain settings (redirect configuration).
cosmic repos domains edit <repoId> www.example.com -r https://example.com
cosmic repos domains edit <repoId> www.example.com -r "" # Remove redirect
cosmic repos domains edit <repoId> www.example.com --redirect-status 302Options:
| Option | Description |
|---|---|
-r, --redirect <url> |
Redirect URL or domain (empty to remove redirect) |
--redirect-status <code> |
Redirect status code: 301, 302, 307, 308 |
--json |
Output as JSON |
Remove a domain from a repository.
cosmic repos domains delete <repoId> www.example.com
cosmic repos domains rm <repoId> www.example.com # Alias
cosmic repos domains delete <repoId> www.example.com -f # Skip confirmationOptions:
| Option | Description |
|---|---|
-f, --force |
Skip confirmation |
--json |
Output as JSON |
List branches for a repository.
cosmic repos branches <repoId> list
cosmic repos branches <repoId> ls # Alias
cosmic repos branches <repoId> # Default actionCreate a new branch.
cosmic repos branches <repoId> create
cosmic repos branches <repoId> create --name feature-x
cosmic repos branches <repoId> create --name feature-x --from mainOptions:
| Option | Description |
|---|---|
-n, --name <name> |
Branch name |
--from <branch> |
Source branch (default: main) |
--json |
Output as JSON |
Delete a branch.
cosmic repos branches <repoId> delete <branchName>
cosmic repos branches <repoId> rm <branchName> # Alias
cosmic repos branches <repoId> delete <name> --force # Skip confirmationList pull requests for a repository.
cosmic repos pr list <repoId>
cosmic repos pr ls <repoId> # Alias
cosmic repos pull-requests list <repoId> # Full aliasOptions:
| Option | Description |
|---|---|
-s, --state <state> |
Filter by state: open, closed, all (default: open) |
--base <branch> |
Filter by base branch |
--head <branch> |
Filter by head branch |
--json |
Output as JSON |
Examples:
cosmic repos pr list repo-123 # List open PRs
cosmic repos pr list repo-123 --state all # List all PRs
cosmic repos pr list repo-123 --base main # PRs targeting mainGet pull request details.
cosmic repos pr get <repoId> <pull_number>
cosmic repos pr get repo-123 42 --jsonOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Create a new pull request.
cosmic repos pr create <repoId>
cosmic repos pr add <repoId> # Alias
cosmic repos pr create <repoId> --head feature --base mainOptions:
| Option | Description |
|---|---|
-t, --title <title> |
Pull request title |
-b, --body <body> |
Pull request description |
--head <branch> |
Head branch (source, where changes are) |
--base <branch> |
Base branch (target, where changes go) |
--draft |
Create as draft PR |
--json |
Output as JSON |
Examples:
# Interactive mode
cosmic repos pr create repo-123
# With all options
cosmic repos pr create repo-123 \
--title "Add new feature" \
--body "This PR adds..." \
--head feature-branch \
--base main
# Create draft PR
cosmic repos pr create repo-123 --draftMerge a pull request.
cosmic repos pr merge <repoId> <pull_number>
cosmic repos pr merge repo-123 42
cosmic repos pr merge repo-123 42 --method squashOptions:
| Option | Description |
|---|---|
-m, --method <method> |
Merge method: merge, squash, rebase (default: merge) |
--title <title> |
Commit title for merge |
--message <message> |
Commit message for merge |
-f, --force |
Skip confirmation |
Examples:
# Standard merge
cosmic repos pr merge repo-123 42
# Squash merge
cosmic repos pr merge repo-123 42 --method squash
# With custom commit message
cosmic repos pr merge repo-123 42 \
--title "Feature: Add dark mode" \
--message "Adds dark mode support with theme toggle"Close a pull request without merging.
cosmic repos pr close <repoId> <pull_number>
cosmic repos pr close repo-123 42
cosmic repos pr close repo-123 42 --force # Skip confirmationOptions:
| Option | Description |
|---|---|
-f, --force |
Skip confirmation |
Deploy a repository to Vercel.
cosmic deploy start <repositoryId>
cosmic deploy trigger <repositoryId> # Alias
cosmic deploy start <repositoryId> --branch main # Deploy from specific branch (repos with existing Vercel project)Options:
| Option | Description |
|---|---|
-w, --watch |
Watch deployment progress until complete |
-b, --branch <branch> |
Branch to deploy (for repos with existing Vercel project; uses redeploy API) |
--json |
Output as JSON |
Redeploy a repository with optional branch selection. Use when the repository already has a Vercel project and you want to trigger a new deployment from a specific branch.
cosmic deploy redeploy <repositoryId> # Interactive branch selection
cosmic deploy redeploy <repositoryId> -b main # Redeploy from main branch
cosmic deploy redeploy <repositoryId> --branch develop --watchOptions:
| Option | Description |
|---|---|
-b, --branch <branch> |
Branch to deploy from (skips interactive selection) |
-w, --watch |
Watch deployment progress until complete |
--json |
Output as JSON |
List deployments for a repository.
cosmic deploy list <repositoryId>
cosmic deploy ls <repositoryId> # AliasOptions:
| Option | Description |
|---|---|
-n, --limit <n> |
Number of deployments to show (default: 10) |
--json |
Output as JSON |
Get deployment logs.
cosmic deploy logs <deploymentId>
cosmic deploy logs <deploymentId> --follow # Stream logs in real-timeOptions:
| Option | Description |
|---|---|
-f, --follow |
Follow/stream logs |
--json |
Output as JSON |
Cancel an in-progress deployment.
cosmic deploy cancel <repositoryId> <deploymentId>
cosmic deploy cancel <repoId> <deploymentId> --force # Skip confirmationList webhooks in current bucket.
cosmic webhooks list
cosmic webhooks ls # Alias
cosmic wh list # Short alias
cosmic webhooks list --jsonOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Get webhook details.
cosmic webhooks get <id>
cosmic webhooks get <id> --jsonOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Create a new webhook.
cosmic webhooks create # Interactive mode
cosmic webhooks add # Alias
cosmic webhooks create \
--title "Notify on publish" \
--endpoint https://example.com/webhook \
--resource objects \
--events created,edited,deletedOptions:
| Option | Description |
|---|---|
--title <title> |
Webhook title |
--endpoint <url> |
Endpoint URL to receive events |
--resource <type> |
Resource type: objects, media, merge_request |
--events <events> |
Events to listen for (comma-separated: created, edited, deleted, completed) |
--object-types <types> |
Object type filters (comma-separated) |
--payload |
Include full payload in webhook |
--props <props> |
Properties to include in payload |
--json |
Output as JSON |
Update a webhook.
cosmic webhooks update <id> --endpoint https://new-url.com/hook
cosmic webhooks edit <id> --events created,edited # Alias
cosmic webhooks update <id> --title "New Name" --no-payloadOptions:
| Option | Description |
|---|---|
--title <title> |
New title |
--endpoint <url> |
New endpoint URL |
--resource <type> |
New resource type |
--events <events> |
New events (comma-separated) |
--object-types <types> |
New object type filters (comma-separated) |
--payload |
Enable payload |
--no-payload |
Disable payload |
--props <props> |
Properties to include in payload |
--json |
Output as JSON |
Delete a webhook.
cosmic webhooks delete <id>
cosmic webhooks rm <id> # Alias
cosmic webhooks delete <id> --force # Skip confirmationOptions:
| Option | Description |
|---|---|
-f, --force |
Skip confirmation |
Manage project team members. Requires a project to be selected (use cosmic cd to navigate to a project).
List team members in the current project.
cosmic team list
cosmic team ls # Alias
cosmic team list --jsonOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Add a team member to the project.
cosmic team add user@example.com # Interactive role selection
cosmic team add user@example.com --role admin
cosmic team add user@example.com -r managerOptions:
| Option | Description |
|---|---|
-r, --role <role> |
Project role: admin, manager, user |
--json |
Output as JSON |
Roles:
| Role | Description |
|---|---|
admin |
Full access to the project |
manager |
Manage content and settings |
user |
Content access based on bucket roles |
Update a team member's role.
cosmic team update <userId> --role admin
cosmic team edit <userId> -r user # AliasOptions:
| Option | Description |
|---|---|
-r, --role <role> |
New project role: admin, manager, user |
--json |
Output as JSON |
Remove a team member from the project.
cosmic team remove <userId>
cosmic team rm <userId> # Alias
cosmic team remove <userId> --force # Skip confirmationOptions:
| Option | Description |
|---|---|
-f, --force |
Skip confirmation |
Manage domains and DNS records.
List all domains.
cosmic domains list
cosmic domains ls # Alias
cosmic domains list --jsonOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Get domain details.
cosmic domains get <id>
cosmic domains get <id> --jsonOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Search for available domain names.
cosmic domains search example.com
cosmic domains search mysite --limit 20Options:
| Option | Description |
|---|---|
-l, --limit <n> |
Limit results |
--json |
Output as JSON |
Import an external domain (one you already own).
cosmic domains import example.com
cosmic domains import example.com --description "Main website"Options:
| Option | Description |
|---|---|
-d, --description <text> |
Domain description |
--json |
Output as JSON |
Connect a domain to a deployed repository.
cosmic domains connect <id> --repo <repoId>
cosmic domains connect <id> --repo <repoId> --redirect https://www.example.com
cosmic domains connect <id> -r <repoId> --redirect-code 302Options:
| Option | Description |
|---|---|
-r, --repo <repoId> |
Repository ID to connect |
--redirect <url> |
Redirect URL |
--redirect-code <code> |
Redirect status code: 301, 302, 307, 308 |
--json |
Output as JSON |
Disconnect a domain from a repository.
cosmic domains disconnect <id> --repo <repoId>
cosmic domains disconnect <id> -r <repoId>Options:
| Option | Description |
|---|---|
-r, --repo <repoId> |
Repository ID to disconnect |
Delete a domain.
cosmic domains delete <id>
cosmic domains rm <id> # Alias
cosmic domains delete <id> --force # Skip confirmationOptions:
| Option | Description |
|---|---|
-f, --force |
Skip confirmation |
Manage DNS records for a domain.
List DNS records for a domain.
cosmic domains dns list <domainId>
cosmic domains dns ls <domainId> # Alias
cosmic domains dns list <domainId> --jsonOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Add a DNS record.
cosmic domains dns add <domainId> # Interactive
cosmic domains dns add <domainId> -t A -n @ -v 76.76.21.21
cosmic domains dns add <domainId> -t CNAME -n www -v example.com
cosmic domains dns add <domainId> -t TXT -n @ -v "v=spf1 ..." --ttl 3600Options:
| Option | Description |
|---|---|
-t, --type <type> |
Record type: A, AAAA, CNAME, MX, TXT, SRV, NS |
-n, --name <name> |
Record name |
-v, --value <value> |
Record value |
--ttl <seconds> |
TTL in seconds (60-86400) |
--comment <text> |
Record comment |
--json |
Output as JSON |
Update a DNS record.
cosmic domains dns update <domainId> <recordId> --value 1.2.3.4
cosmic domains dns edit <domainId> <recordId> --ttl 3600 # AliasOptions:
| Option | Description |
|---|---|
-t, --type <type> |
New record type |
-n, --name <name> |
New record name |
-v, --value <value> |
New record value |
--ttl <seconds> |
New TTL |
--comment <text> |
New comment |
--json |
Output as JSON |
Delete a DNS record.
cosmic domains dns delete <domainId> <recordId>
cosmic domains dns rm <domainId> <recordId> # Alias
cosmic domains dns delete <domainId> <recordId> -f # Skip confirmationOptions:
| Option | Description |
|---|---|
-f, --force |
Skip confirmation |
List workflows.
cosmic workflows list
cosmic workflows ls # Alias
cosmic wf list # Short aliasOptions:
| Option | Description |
|---|---|
-s, --status <status> |
Filter by status (active, draft, paused) |
--schedule-type <type> |
Filter by schedule type (manual, cron, event_triggered) |
-l, --limit <n> |
Limit results |
--json |
Output as JSON |
Get workflow details.
cosmic workflows get <id>
cosmic workflows get <id> --jsonCreate a new workflow with an initial agent step.
cosmic workflows create
cosmic workflows create --name "My Workflow" --agent <agentId>
cosmic workflows add # AliasOptions:
| Option | Description |
|---|---|
-n, --name <name> |
Workflow name |
-d, --description <desc> |
Description |
-a, --agent <agentId> |
Initial agent ID for first step |
--schedule-type <type> |
Schedule type (manual, cron, event_triggered) |
--status <status> |
Initial status (draft, active, paused) |
--json |
Output as JSON |
Add an agent as a step to an existing workflow.
cosmic workflows add-step <workflowId>
cosmic workflows add-step <workflowId> --agent <agentId>Options:
| Option | Description |
|---|---|
-a, --agent <agentId> |
Agent ID to add |
--json |
Output as JSON |
Remove a step from a workflow.
cosmic workflows remove-step <workflowId>
cosmic workflows remove-step <workflowId> --step 2Options:
| Option | Description |
|---|---|
-s, --step <n> |
Step number to remove (1-based) |
-f, --force |
Skip confirmation |
--json |
Output as JSON |
Execute a workflow.
cosmic workflows run <id>
cosmic workflows execute <id> # AliasOptions:
| Option | Description |
|---|---|
-i, --inputs <json> |
User inputs as JSON string |
--json |
Output as JSON |
Delete a workflow.
cosmic workflows delete <id>
cosmic workflows rm <id> # Alias
cosmic workflows delete <id> --force # Skip confirmationList or get execution details.
cosmic workflows executions # List all executions
cosmic workflows executions <executionId> # Get specific execution
cosmic workflows exec <executionId> # Alias
cosmic workflows executions <execId> --watch # Watch until completeOptions (for listing):
| Option | Description |
|---|---|
-w, --workflow-id <id> |
Filter by workflow ID |
-s, --status <status> |
Filter by status |
-l, --limit <n> |
Limit results (default: 20) |
--watch |
Watch execution and poll until complete |
--json |
Output as JSON |
Cancel a running execution.
cosmic workflows cancel <executionId>List agents in current bucket.
cosmic agents list
cosmic agents ls # AliasOptions:
| Option | Description |
|---|---|
--json |
Output as JSON |
Get agent details.
cosmic agents get <id>
cosmic agents get <id> --jsonCreate a new agent.
cosmic agents create --type content
cosmic agents add --type repo # AliasOptions:
| Option | Description |
|---|---|
-t, --type <type> |
Required. Agent type: content, repository (or code/repo), computer_use |
-n, --name <name> |
Agent name |
-p, --prompt <prompt> |
Agent prompt/instructions |
-m, --model <model> |
AI model (default: opus-4.5 for content/repo, haiku-4.5 for computer_use) |
-e, --emoji <emoji> |
Agent emoji |
--repository-id <id> |
Repository ID (for repository type) |
--base-branch <branch> |
Base branch (for repository type) |
--start-url <url> |
Start URL (for computer_use type) |
--goal <goal> |
Goal description (for computer_use type) |
--auth-session <id> |
Pre-captured auth session ID (for computer_use type) |
--types <types> |
Object type slugs for context (comma-separated) |
-l, --links <urls> |
External URLs for context (comma-separated) |
--objects-limit <n> |
Max objects per type for context (default: 100) |
--objects-depth <n> |
Object depth for nested metafields (default: 1) |
--email-notifications |
Enable email notifications |
--require-approval |
Require approval before execution |
--schedule |
Enable scheduled runs |
--schedule-type <type> |
once or recurring (default: recurring) |
--schedule-frequency <freq> |
hourly, daily, weekly, monthly (default: daily) |
--timezone <tz> |
Timezone for schedule (default: UTC) |
--run |
Run immediately after creation |
--json |
Output as JSON |
Run an agent.
cosmic agents run <id>
cosmic agents run <id> --prompt "Override prompt"Options:
| Option | Description |
|---|---|
-p, --prompt <prompt> |
Override the agent's prompt |
--json |
Output as JSON |
Add a follow-up task to continue work on the same branch.
cosmic agents follow-up <agentId>
cosmic agents followup <agentId> # Alias
cosmic agents follow-up <agentId> --prompt "Continue with..."Options:
| Option | Description |
|---|---|
-p, --prompt <prompt> |
Follow-up instructions |
--json |
Output as JSON |
Create a pull request from agent's work.
cosmic agents pr <agentId>
cosmic agents pull-request <agentId> # AliasOptions:
| Option | Description |
|---|---|
-t, --title <title> |
PR title |
-b, --body <body> |
PR description |
--json |
Output as JSON |
Approve and execute pending operations for an execution.
cosmic agents approve <agentId> <executionId>
cosmic agents approve <agentId> <execId> --all # Approve without confirmation
cosmic agents approve <agentId> <execId> --skip # Skip and mark completeOptions:
| Option | Description |
|---|---|
-y, --all |
Approve all operations without confirmation |
--skip |
Skip operations and mark execution as complete |
--json |
Output as JSON |
Delete an agent.
cosmic agents delete <id>
cosmic agents rm <id> # Alias
cosmic agents delete <id> --force # Skip confirmationList or get agent execution details.
cosmic agents executions <agentId> # List executions
cosmic agents executions <agentId> <executionId> # Get specific
cosmic agents exec <agentId> <execId> # Alias
cosmic agents executions <agentId> <execId> --watch # Poll until completeOptions:
| Option | Description |
|---|---|
-w, --watch |
Watch execution and poll until complete |
--json |
Output as JSON |
Capture authentication from local browser for computer use agents.
cosmic agents capture-auth --url https://example.com/loginOpens a browser window. Log in to the site, then click "Done - Capture Auth" in the banner. Returns a session ID to use with --auth-session when creating agents.
Options:
| Option | Description |
|---|---|
-u, --url <url> |
Required. URL to authenticate on |
-l, --label <label> |
Label for this auth session |
--timeout <seconds> |
Timeout in seconds (default: 600) |
--json |
Output as JSON |
Generate text from a prompt with streaming output.
cosmic ai generate "Write a blog post about AI"
cosmic ai gen "Your prompt" # AliasOptions:
| Option | Description |
|---|---|
-m, --model <model> |
AI model to use |
--max-tokens <n> |
Maximum tokens to generate |
--temperature <n> |
Temperature (0-2) |
--json |
Output as JSON |
Generate an image from a prompt.
cosmic ai image "A sunset over mountains"
cosmic ai img "Your prompt" # AliasOptions:
| Option | Description |
|---|---|
-f, --folder <folder> |
Target folder in media library |
-a, --alt-text <text> |
Alt text for the image |
--json |
Output as JSON |
Generate audio from text using AI text-to-speech. The generated audio file is uploaded to your media library.
cosmic ai audio "Welcome to our podcast"
cosmic ai audio "Hello world" --voice=alloy # Specify voice
cosmic ai audio "text" --model=tts-1-hd # High-definition model
cosmic ai audio "text" --folder=audio # Save to folderOptions:
| Option | Description |
|---|---|
-v, --voice <voice> |
Voice to use: alloy, ash, coral, echo, fable, nova, onyx, sage, shimmer (default: nova) |
-m, --model <model> |
TTS model: tts-1, tts-1-hd (default: tts-1) |
-f, --folder <folder> |
Target folder in media library |
--json |
Output as JSON |
Send a single message to AI.
cosmic ai chat "Tell me about my content"
cosmic ai chat "Explain this" --system "You are a helpful assistant"Options:
| Option | Description |
|---|---|
-m, --model <model> |
AI model to use |
-s, --system <prompt> |
System prompt |
--json |
Output as JSON |
Start interactive AI chat session.
cosmic chat # Default ask mode (read-only)
cosmic chat --content # Content mode (can modify content)
cosmic chat --build # Build mode (generate apps)
cosmic chat --repo # Repository mode (code changes)
cosmic chat --repo my-repo # Repo mode with specific repo
cosmic chat --automate # Automation mode (create agents & workflows)Options:
| Option | Description |
|---|---|
-m, --model <model> |
AI model to use |
--ask |
Ask mode - read-only questions |
-c, --content |
Content mode - create/update content |
-b, --build |
Build mode - app development |
-a, --automate |
Automation mode - create agents & workflows |
-r, --repo [name] |
Repository mode - code changes |
--branch <branch> |
Branch to use in repo mode |
-p, --prompt <prompt> |
Start with initial prompt |
-t, --types <types> |
Object type slugs to include (comma-separated) |
-l, --links <urls> |
External URLs to include (comma-separated) |
--objects-limit <n> |
Max objects per type (default: 10 content, 100 build) |
--objects-depth <n> |
Object depth for nested metafields (default: 1) |
Inside chat mode:
| Command | Description |
|---|---|
exit, quit |
Exit chat mode |
clear |
Clear conversation history |
context |
Show current context |
help |
Show available commands |
Shortcut for content mode chat.
cosmic content # Start content chat
cosmic content -p "Create 5 blog posts" # With initial prompt
cosmic content --types posts,authors # Include object types
cosmic content --ask # Read-only modeOptions:
| Option | Description |
|---|---|
-m, --model <model> |
AI model to use |
-p, --prompt <prompt> |
Initial prompt |
-a, --ask |
Ask mode (read-only) |
-t, --types <types> |
Object types to include |
-l, --links <urls> |
External URLs to include |
--objects-limit <n> |
Max objects per type |
--objects-depth <n> |
Nested metafield depth |
Shortcut for build mode chat.
cosmic build # Start build chat
cosmic build -p "A blog with dark mode" # With description
cosmic build --types posts # Include content context
cosmic build --ask # Ask without generatingOptions:
| Option | Description |
|---|---|
-m, --model <model> |
AI model to use |
-p, --prompt <prompt> |
App description |
-a, --ask |
Ask mode (questions only) |
-t, --types <types> |
Object types to include |
-l, --links <urls> |
External URLs to include |
--objects-limit <n> |
Max objects per type |
--objects-depth <n> |
Nested metafield depth |
Shortcut for repository update mode.
cosmic update # Select repo interactively
cosmic update my-repo # Specify repo name
cosmic update my-repo -b feature-branch # Specify branch
cosmic update -p "Add dark mode support" # With instructions
cosmic update --ask # Explore code without changesOptions:
| Option | Description |
|---|---|
-m, --model <model> |
AI model to use |
-b, --branch <branch> |
Branch to update (default: main) |
-p, --prompt <prompt> |
Change description |
-a, --ask |
Ask mode (explore only) |
-t, --types <types> |
Object types to include |
-l, --links <urls> |
External URLs to include |
--objects-limit <n> |
Max objects per type |
--objects-depth <n> |
Nested metafield depth |
Shortcut for automation mode chat. Create AI agents and workflows with natural language.
cosmic automate # Start automate chat
cosmic automate -p "Create a weekly content agent" # With initial prompt
cosmic automate --ask # Ask about automation without creatingOptions:
| Option | Description |
|---|---|
-m, --model <model> |
AI model to use |
-p, --prompt <prompt> |
Describe what you want to automate |
-a, --ask |
Ask mode (questions without creating anything) |
Get configuration values.
cosmic config get # Show all config
cosmic config get defaultModel # Get specific valueSet configuration values.
cosmic config set defaultModel gpt-5
cosmic config set apiUrl https://custom-api.example.com
cosmic config set sdkUrl http://localhost:8080/v3| Option | Description |
|---|---|
defaultModel |
Default AI model for generation |
apiUrl |
Custom API URL |
sdkUrl |
Custom SDK URL (for local development) |
currentWorkspace |
Current workspace slug |
currentProject |
Current project slug |
currentBucket |
Current bucket slug |
Configuration is stored in ~/.cosmic/:
| File | Contents |
|---|---|
config.json |
Settings (context, default model, etc.) |
credentials.json |
Authentication tokens |
Many commands have short aliases for convenience:
| Command | Aliases |
|---|---|
shell |
sh |
list |
ls |
delete |
rm |
create |
add |
update |
edit |
objects |
obj |
webhooks |
wh |
workflows |
wf |
repositories |
repos |
duplicate |
dup |
executions |
exec |
generate |
gen |
image |
img |
follow-up |
followup |
pr |
pull-request |
| Type | Aliases |
|---|---|
repository |
code, repo |
# Clone a connected repository with auto-configured environment
cosmic repos clone # Interactive - select from connected repos
cosmic repos clone my-repo-id # By repository ID
cosmic repos clone https://github.com/user/my-app # By URL
# The clone command automatically:
# 1. Clones the repo to your local machine
# 2. Creates .env with your Cosmic API keys:
# - COSMIC_BUCKET_SLUG
# - COSMIC_READ_KEY
# - COSMIC_WRITE_KEY
# - NEXT_PUBLIC_COSMIC_BUCKET_SLUG (for Next.js)
# - NEXT_PUBLIC_COSMIC_READ_KEY (for Next.js)
# Start developing immediately
cd my-app
npm install
npm run dev# 1. Login to Cosmic
cosmic login
# 2. Create a new project with AI-generated content model
cosmic projects create
# Follow prompts:
# - Project title: "Recipe Blog"
# - How to start: "Use AI to generate content model"
# - Describe: "A recipe blog with recipes, categories, and authors"
# AI creates object types and sample content automatically
# 3. Verify your content
cosmic ls # See your project
cosmic cd <project-id> # Navigate into it
cosmic ls # See the bucket
cosmic cd <bucket-slug> # Navigate into bucket
cosmic objects list # See generated content
# 4. Generate more content with AI
cosmic content -p "Create 10 more recipes with hero images"
# 5. Build an app from your content
cosmic build -p "A modern recipe blog using Next.js with search,
category filtering, and a beautiful grid layout"
# AI generates complete app code and creates GitHub repo
# 6. List your repos and deploy
cosmic repos list # Find repo ID
cosmic deploy start <repoId> --watch # Deploy to Vercel
# ✓ Deployment ready: https://recipe-blog-xyz.vercel.app
# 7. Clone locally for development
cosmic repos clone <repoId> # Clone with .env auto-configured
cd recipe-blog
npm install
npm run dev # Start local development
# 8. Make updates to the app
cosmic update <repoName> -p "Add a favorites feature where users can
save recipes to localStorage, and add dark mode support"
# AI modifies the code in your repo
# 9. Watch the agent work
cosmic agents executions <agentId> --watch
# 10. Review and create a PR
cosmic agents pr <agentId>
# ✓ PR created: https://github.com/user/recipe-blog/pull/1
# 11. Merge and redeploy
# After reviewing/merging the PR:
cosmic deploy redeploy <repoId> --branch main --watch
# Or: cosmic deploy start <repoId> --branch main --watch# Create agents
cosmic agents create --type content --name "Writer" \
--prompt "Write engaging blog posts" --run
cosmic agents create --type content --name "Editor" \
--prompt "Edit and improve blog posts"
# Create workflow
cosmic workflows create --name "Content Pipeline" --agent <writerId>
cosmic workflows add-step <workflowId> --agent <editorId>
# Execute
cosmic workflows run <workflowId># Capture auth session
cosmic agents capture-auth --url https://dashboard.example.com/login
# Create agent with auth
cosmic agents create \
--type computer_use \
--name "Dashboard Bot" \
--start-url "https://dashboard.example.com" \
--prompt "Screenshot the weekly metrics and summarize them" \
--auth-session <sessionId> \
--schedule \
--schedule-frequency daily
# Check executions
cosmic agents executions <agentId> --watch