Skip to main content

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
warning
  • 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 --ver flag (not --version, which is reserved by Commander.js)

Deployment Strategyโ€‹

  1. Blue-Green: Upload new version, test with specific clients, then switch for all
  2. Canary: Upload, gradually route traffic, then full switch
  3. Immediate: Upload with --switch for 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:

  1. Upload the new version
  2. Test it in a staging environment
  3. Review logs and metrics
  4. Switch the active version
  5. 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"