Overview
Refresh your current workspace token with a new token that has updated expiration. This command automatically revokes the old token and stores the new one locally, ensuring seamless token rotation.Syntax
Options
Token expiration time in secondsDefault:
Example:
31536000
(1 year)Example:
86400
(24 hours)Output format for the refresh resultDefault:
Options:
text
Options:
text
, json
Token Refresh Behavior
Automatic Token Revocation
When you refresh a token, the old token is automatically revoked and cannot be used again. This improves security by ensuring only one active token per refresh cycle.Default Expiration
Tokens have a 1-year default expiration. This follows security best practices while providing reasonable token lifetime for most use cases.Examples
Standard Refresh
Custom Expiration
Short-Lived Token
Non-Expiring Token
JSON Output
Token Lifecycle
What Happens During Refresh
- Generate New Token: Creates a new token with specified expiration
- Store Locally: Updates local configuration with the new token
- Revoke Old Token: Automatically revokes the previous token
- Confirm Success: Displays new token information
Impact on Running Systems
CI/CD Systems: If you’ve shared your workspace token with CI/CD systems, they will lose access when you refresh. Use
ntcli token create
for dedicated CI/CD tokens instead.Local Development: Your local ntcli commands will continue working seamlessly with the new token.
Best Practices
Regular Token Rotation
Separate Tokens for Different Purposes
Monitor Token Expiration
Security Considerations
Automatic Revocation Benefits
- Reduced Attack Surface: Old tokens cannot be used if compromised
- Single Active Token: Prevents confusion about which token is current
- Audit Trail: Clear record of token rotation events
Token Sharing Guidelines
- Never Share Refreshable Tokens: Use
ntcli token create
for shared tokens - Use Dedicated CI/CD Tokens: Create separate tokens for automated systems
- Regular Rotation: Refresh tokens regularly, especially after security incidents
Error Handling
Authentication Required
Authentication Required
Error:
Authentication required. Try running ntcli token refresh
Solution: This indicates you need a valid Clerk authentication session:Workspace Not Selected
Workspace Not Selected
Error:
No workspace selected
Solution: Select a workspace first:No Existing Token
No Existing Token
Error:
No current token to refresh
Solution: Create a new token first:Invalid Expiration Time
Invalid Expiration Time
Error:
Invalid expiration time
Solution: Use a valid expiration in seconds: