Skip to main content

Secret Templating

Axion supports inline secret interpolation using {{KEY}} templates.

Basic Syntax

# Set base secrets
axn set PG_USER "myuser"
axn set PG_PASS "secret123"
axn set PG_HOST "localhost"

# Use templating
axn set DATABASE_URL "postgres://{{PG_USER}}:{{PG_PASS}}@{{PG_HOST}}:5432/mydb"
At runtime, DATABASE_URL resolves to:
postgres://myuser:secret123@localhost:5432/mydb

Nested Templates

Templates can reference other templated values:
axn set PROTOCOL "https"
axn set HOST "api.example.com"
axn set BASE_URL "{{PROTOCOL}}://{{HOST}}"
axn set API_URL "{{BASE_URL}}/v1"
# → https://api.example.com/v1

Legacy Syntax

The @ref:KEY syntax is still supported for full-value references:
axn set BACKUP_URL "@ref:DATABASE_URL"

JSON Configs

Store structured configuration with JSON validation:
axn set FEATURE_FLAGS '{"beta":true,"v2":false}' --json
axn set CONFIG '{"timeout":5000,"retries":3}' --json
The --json flag validates JSON before storing.

Error Handling

Missing References

axn set URL "{{MISSING_KEY}}"
axn run -- npm start
# Error: Referenced key "MISSING_KEY" not found

Circular References

axn set A "{{B}}"
axn set B "{{A}}"
axn run -- npm start
# Error: Circular reference detected: A → B → A

Escape Syntax

To use literal {{ in a value, escape with backslash:
axn set TEMPLATE "Use \{{NAME}} for templates"
# → Use {{NAME}} for templates