Skip to main content
Manage templates for HopX sandboxes using the template command (alias: tpl). List available templates, view template details, build custom templates, and delete templates.

Command Syntax

hopx template <subcommand> [options]

Subcommands

list

List all available templates. Syntax:
hopx template list [OPTIONS]
Options:
  • --output, -o FORMAT - Output format: table, json, plain (default: table)
Examples:
# List all templates
hopx template list

# List with JSON output
hopx template list --output json
Expected Output (Table):
┌──────────────┬──────────────────────┬─────────────┐
│ Name         │ Description          │ Category    │
├──────────────┼──────────────────────┼─────────────┤
│ python       │ Python 3.11          │ language    │
│ nodejs       │ Node.js 20           │ language    │
│ code-interpreter │ Data science stack │ development │
└──────────────┴──────────────────────┴─────────────┘
Exit Codes:
  • 0 - Success
  • 3 - Authentication error

info

Get detailed information about a template. Syntax:
hopx template info TEMPLATE_NAME [OPTIONS]
Arguments:
  • TEMPLATE_NAME - Template name or ID (required)
Options:
  • --output, -o FORMAT - Output format: table, json, plain (default: table)
Examples:
# Get template info
hopx template info python

# Get info with JSON output
hopx template info code-interpreter --output json
Expected Output (Table):
┌─────────────┬─────────────────────────────────────┐
│ Property    │ Value                               │
├─────────────┼─────────────────────────────────────┤
│ Name        │ python                              │
│ ID          │ 123                                 │
│ Description │ Python 3.11 with pip                │
│ Category    │ language                            │
│ Language    │ python                              │
└─────────────┴─────────────────────────────────────┘
Exit Codes:
  • 0 - Success
  • 3 - Authentication error
  • 4 - Template not found

build

Build a custom template from a Dockerfile. Syntax:
hopx template build [OPTIONS]
Options:
  • --name TEXT - Template name (required)
  • --dockerfile PATH - Path to Dockerfile
  • --image TEXT - Base image (e.g., python:3.11, node:20)
  • --context PATH - Build context directory
  • --output, -o FORMAT - Output format: table, json, plain (default: table)
Examples:
# Build template from Dockerfile
hopx template build --name my-app --dockerfile ./Dockerfile

# Build with context directory
hopx template build --name my-app --dockerfile ./Dockerfile --context ./build-context
Expected Output:
Building template: my-app
✓ Template built successfully
✓ Template ID: tpl_abc123
Exit Codes:
  • 0 - Success
  • 1 - Build failed
  • 3 - Authentication error

delete

Delete a custom template. Syntax:
hopx template delete TEMPLATE_ID [OPTIONS]
Arguments:
  • TEMPLATE_ID - Template ID to delete (required)
Options:
  • --force - Skip confirmation prompt
Examples:
# Delete template
hopx template delete tpl_abc123

# Delete without confirmation
hopx template delete tpl_abc123 --force
Expected Output:
✓ Template deleted: tpl_abc123
Exit Codes:
  • 0 - Success
  • 3 - Authentication error
  • 4 - Template not found

Shell Scripting Examples

List and Filter Templates

#!/bin/bash

# List templates and filter by category
hopx template list --output json | jq '.[] | select(.category == "language")'

Build and Use Custom Template

#!/bin/bash
set -e

# Build custom template
TEMPLATE_ID=$(hopx template build --name my-app --dockerfile ./Dockerfile --output json | jq -r '.id')

# Create sandbox from custom template
SANDBOX_ID=$(hopx sandbox create --template-id "$TEMPLATE_ID" --output json | jq -r '.id')

echo "Created sandbox $SANDBOX_ID from template $TEMPLATE_ID"

Next Steps