Global Options
These options are available for all commands:| Option | Alias | Description |
|---|---|---|
--version | -v | Display the version number |
--help | -h | Display help for a command |
Authentication Commands
dub login
Log into the Dub platform using OAuth authentication.
- Generates a secure code verifier for OAuth PKCE flow
- Opens your browser to Dub’s authentication page
- Starts a local server on
http://localhost:4587/callback - Waits for authentication callback
- Exchanges authorization code for access token
- Stores credentials securely
links.read- Read links from your workspacelinks.write- Create and update linksdomains.read- Read domain information
dub config
View your configured credentials and workspace settings.
- Access token
- Refresh token
- Configured domain
- Token expiration
Domain Management
dub domains
Configure your workspace domain for creating short links.
- Fetches all available domains from your workspace
- Includes both custom and default Dub domains
- Presents an interactive selection prompt
- Saves the selected domain to configuration
Link Management
dub shorten
Create a new short link.
| Argument | Required | Description |
|---|---|---|
url | Optional | Destination URL for the short link |
key | Optional | Custom short link key (slug) |
- Validates destination URL
- Generates random keys using nanoid
- Checks for key conflicts
- Returns the complete short link URL
dub links
Search for links in your Dub workspace.
| Option | Alias | Type | Description |
|---|---|---|---|
--search [search] | -s | string | Search term to filter links |
--limit [limit] | -l | number | Number of links to fetch (default: 10) |
- Short Link - The shortened URL
- Destination URL - Where the link redirects
- Clicks - Total number of clicks
- Created At - When the link was created (formatted)
Help Command
dub help
Display help information for the CLI or a specific command.
Command Aliases
Commands can be called using their short forms:Error Handling
The CLI provides helpful error messages: Authentication required:Environment Variables
The CLI respects these environment variables: | Variable | Description | Default | |----------|-------------|---------|| |DUB_API_URL | Base API URL | https://api.dub.co |
| DUB_OAUTH_URL | OAuth URL | https://app.dub.co |
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error occurred |
Next Steps
CLI Installation
Install and configure the CLI
CLI Overview
Back to CLI overview
API Reference
Explore the API
Server SDKs
Use programmatic SDKs