Skip to content

Device Configuration Templates

Device configuration templates let you define reusable Jinja2 templates that render switch configuration. Templates are bound to devices or fabrics via profiles, and can be rendered on demand to preview or apply configuration changes.

TermDescription
TemplateA Jinja2 template body (base64-encoded) with an associated device driver filter and execution type (cli, etc.)
Custom variablesJSON key-value pairs stored on the template, merged into the render context
ProfileA binding that ties a template to a specific network device, fabric, or set of devices
RenderServer-side execution of the Jinja2 template against a variables payload, returning the rendered string
Terminal window
curl "https://<your-server>/api/v2/device-configuration-templates/config" \
-H "Authorization: Bearer <API_KEY>"

The templateContent field must be a base64-encoded Jinja2 string.

Terminal window
curl -X POST "https://<your-server>/api/v2/device-configuration-templates/config" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <API_KEY>" \
-d '{
"label": "ntp-config",
"name": "NTP Configuration",
"description": "Configures NTP servers on a device",
"deviceDriver": "sonic_enterprise",
"executionType": "cli",
"templateContent": "<base64-encoded Jinja2 template>",
"customVariablesJson": {
"ntp_server": "192.0.2.1"
}
}'

Getting, updating, and deleting a template

Section titled “Getting, updating, and deleting a template”
Terminal window
# Get by ID
curl "https://<your-server>/api/v2/device-configuration-templates/config/{id}" \
-H "Authorization: Bearer <API_KEY>"
# Update
curl -X PATCH "https://<your-server>/api/v2/device-configuration-templates/config/{id}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <API_KEY>" \
-d '{
"customVariablesJson": {"ntp_server": "198.51.100.1"}
}'
# Delete
curl -X DELETE "https://<your-server>/api/v2/device-configuration-templates/config/{id}" \
-H "Authorization: Bearer <API_KEY>"

Renders a saved template by ID, merging the stored customVariablesJson with any additional variables in the request body:

Terminal window
curl -X POST "https://<your-server>/api/v2/device-configuration-templates/config/{id}/actions/render" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <API_KEY>" \
-d '{
"variables": {
"ntp_server": "192.0.2.2"
}
}'

Renders a template body without saving it first — useful for testing:

Terminal window
curl -X POST "https://<your-server>/api/v2/device-configuration-templates/config/actions/render" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <API_KEY>" \
-d '{
"templateContent": "<base64-encoded Jinja2 template>",
"variables": {
"ntp_server": "192.0.2.3"
}
}'

A profile binds a template to a target (device, fabric, or device list). Profiles are how templates get applied to actual switches.

Terminal window
curl -X POST "https://<your-server>/api/v2/device-configuration-templates/profile" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <API_KEY>" \
-d '{
"templateId": 5,
"networkDeviceId": 229,
"label": "ntp-leaf01"
}'

Assigns a template to all devices in a fabric (or an explicit device list) in one request:

Terminal window
curl -X POST "https://<your-server>/api/v2/device-configuration-templates/profile/bulk" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <API_KEY>" \
-d '{
"templateId": 5,
"networkFabricId": 1
}'

Returns the profiles that match a specific device or fabric:

Terminal window
curl -X POST "https://<your-server>/api/v2/device-configuration-templates/profile/actions/find-applicable" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <API_KEY>" \
-d '{
"networkDeviceId": 229
}'

Renders every profile that applies to a target device or fabric and returns the combined output:

Terminal window
curl -X POST "https://<your-server>/api/v2/device-configuration-templates/profile/actions/render-applicable" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <API_KEY>" \
-d '{
"networkDeviceId": 229
}'
Terminal window
curl -X POST "https://<your-server>/api/v2/device-configuration-templates/profile/{id}/actions/render" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <API_KEY>" \
-d '{
"networkDeviceId": 229
}'

Listing, getting, updating, and deleting profiles

Section titled “Listing, getting, updating, and deleting profiles”
Terminal window
# List all profiles
curl "https://<your-server>/api/v2/device-configuration-templates/profile" \
-H "Authorization: Bearer <API_KEY>"
# Get by ID
curl "https://<your-server>/api/v2/device-configuration-templates/profile/{id}" \
-H "Authorization: Bearer <API_KEY>"
# Update
curl -X PATCH "https://<your-server>/api/v2/device-configuration-templates/profile/{id}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <API_KEY>" \
-d '{"label": "updated-label"}'
# Delete
curl -X DELETE "https://<your-server>/api/v2/device-configuration-templates/profile/{id}" \
-H "Authorization: Bearer <API_KEY>"