Version Management
Manage multiple versions of your functions with the Invoke CLI.
Understanding Versionsโ
Every time you upload new code, a new version is created. Each version:
- Has a sequential version number (1, 2, 3, ...)
- Can be independently activated
- Contains the complete function code
- Has its own upload timestamp and size info
Listing Versionsโ
List All Versionsโ
invoke function:versions:list my-api
Example output:
๐ฆ Function Versions:
โโโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโ
โ Version โ Status โ Size โ Uploaded โ Active โ
โโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโค
โ 3 โ ready โ 45.2 KB โ 23/2/2026, 2:15:30 pm โ โ
โ
โ 2 โ ready โ 39.8 KB โ 23/2/2026, 1:44:11 pm โ โ
โ 1 โ ready โ 12.5 KB โ 23/2/2026, 10:22:45 amโ โ
โโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโ
JSON output:
invoke function:versions:list my-api --output json
Uploading Versionsโ
Upload New Versionโ
Upload a new version from a directory or zip file:
# From directory (auto-zips)
invoke function:versions:upload my-api ./my-function
# From zip file
invoke function:versions:upload my-api ./my-function.zip
Example output:
Preparing upload...
โ
Version 4 uploaded successfully
Upload and Switchโ
Upload and immediately activate the new version:
invoke function:versions:upload my-api ./my-function --switch
Example output:
Preparing upload...
โ
Version 4 uploaded successfully
Switching to new version...
โ
Switched to version 4
This is equivalent to:
invoke function:versions:upload my-api ./my-function
invoke function:versions:switch my-api --ver 4
Switching Versionsโ
Activate a Different Versionโ
Switch the active version:
invoke function:versions:switch my-api --ver 2
Example output:
โ
Switched to version 2
The active version is the one that gets executed when you invoke the function.
Downloading Versionsโ
Download Version Codeโ
Download a version for backup or inspection:
# Extract to directory
invoke function:versions:download my-api --ver 3 --output ./backup
# Save as zip
invoke function:versions:download my-api --ver 3 --output ./backup.zip
Example output:
Downloading version...
โ
Downloaded to: ./backup
Default behavior:
- If output path ends with
.zipโ saves as zip file - Otherwise โ extracts to directory
Deleting Versionsโ
Delete a Versionโ
Remove an old or unwanted version:
invoke function:versions:delete my-api --ver 1
You'll be prompted for confirmation:
? Are you sure you want to delete version 1? This cannot be undone. (y/N)
Skip confirmation:
invoke function:versions:delete my-api --ver 1 --force
- You cannot delete the active version
- Deleted versions cannot be recovered
- Version numbers are not reused
Version Workflow Examplesโ
Continuous Deploymentโ
Automated deployment script:
#!/bin/bash
# Build your function
npm run build
# Upload and activate new version
invoke function:versions:upload my-api ./dist --switch --output json
# Check if successful
if [ $? -eq 0 ]; then
echo "Deployment successful!"
else
echo "Deployment failed!"
exit 1
fi
Safe Rolloutโ
Upload first, test, then switch:
# 1. Upload new version (don't switch yet)
invoke function:versions:upload my-api ./new-code
# 2. Note the new version number (e.g., 5)
invoke function:versions:list my-api
# 3. Test the specific version manually
# (You'd need to temporarily switch or test in staging)
# 4. If tests pass, switch to new version
invoke function:versions:switch my-api --ver 5
Quick Rollbackโ
If something goes wrong, roll back immediately:
# List versions to see previous active version
invoke function:versions:list my-api
# Switch back to previous version
invoke function:versions:switch my-api --ver 4
Version Cleanupโ
Remove old versions to save space:
# Delete old versions (keep last 3)
invoke function:versions:delete my-api --ver 1 --force
invoke function:versions:delete my-api --ver 2 --force
invoke function:versions:delete my-api --ver 3 --force
Best Practicesโ
Version Numberingโ
- Versions are sequential integers (1, 2, 3...)
- Numbers are never reused, even after deletion
- Use
--verflag (not--version, which is reserved by Commander.js)
Deployment Strategyโ
- Blue-Green: Upload new version, test with specific clients, then switch for all
- Canary: Upload, gradually route traffic, then full switch
- Immediate: Upload with
--switchfor instant deployment
Version Retentionโ
Keep a few recent versions for quick rollback:
- Production: Keep last 5-10 versions
- Development: Keep only last 2-3 versions
- Archive old versions locally if needed
Testing Versionsโ
Before switching an active version:
- Upload the new version
- Test it in a staging environment
- Review logs and metrics
- Switch the active version
- Monitor for any issues
Tipsโ
Check Active Versionโ
invoke function:get my-api | grep "Active Version"
Compare Versionsโ
Download two versions and use diff:
invoke function:versions:download my-api --ver 2 --output ./v2
invoke function:versions:download my-api --ver 3 --output ./v3
diff -r ./v2 ./v3
Automate with JSONโ
# Get version info programmatically
versions=$(invoke function:versions:list my-api --output json)
latest=$(echo $versions | jq '.[0].version')
echo "Latest version: $latest"