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.
Concepts
Section titled “Concepts”| Term | Description |
|---|---|
| Template | A Jinja2 template body (base64-encoded) with an associated device driver filter and execution type (cli, etc.) |
| Custom variables | JSON key-value pairs stored on the template, merged into the render context |
| Profile | A binding that ties a template to a specific network device, fabric, or set of devices |
| Render | Server-side execution of the Jinja2 template against a variables payload, returning the rendered string |
Managing templates
Section titled “Managing templates”Listing templates
Section titled “Listing templates”curl "https://<your-server>/api/v2/device-configuration-templates/config" \ -H "Authorization: Bearer <API_KEY>"Creating a template
Section titled “Creating a template”The templateContent field must be a base64-encoded Jinja2 string.
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”# Get by IDcurl "https://<your-server>/api/v2/device-configuration-templates/config/{id}" \ -H "Authorization: Bearer <API_KEY>"
# Updatecurl -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"} }'
# Deletecurl -X DELETE "https://<your-server>/api/v2/device-configuration-templates/config/{id}" \ -H "Authorization: Bearer <API_KEY>"Rendering templates
Section titled “Rendering templates”Render a saved template
Section titled “Render a saved template”Renders a saved template by ID, merging the stored customVariablesJson with any additional variables in the request body:
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" } }'Render an unsaved template (stateless)
Section titled “Render an unsaved template (stateless)”Renders a template body without saving it first — useful for testing:
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" } }'Managing profiles
Section titled “Managing profiles”A profile binds a template to a target (device, fabric, or device list). Profiles are how templates get applied to actual switches.
Creating a profile
Section titled “Creating a profile”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" }'Bulk-assigning a template across a fabric
Section titled “Bulk-assigning a template across a fabric”Assigns a template to all devices in a fabric (or an explicit device list) in one request:
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 }'Finding applicable profiles
Section titled “Finding applicable profiles”Returns the profiles that match a specific device or fabric:
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 }'Rendering all applicable profiles
Section titled “Rendering all applicable profiles”Renders every profile that applies to a target device or fabric and returns the combined output:
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 }'Rendering a specific profile
Section titled “Rendering a specific profile”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”# List all profilescurl "https://<your-server>/api/v2/device-configuration-templates/profile" \ -H "Authorization: Bearer <API_KEY>"
# Get by IDcurl "https://<your-server>/api/v2/device-configuration-templates/profile/{id}" \ -H "Authorization: Bearer <API_KEY>"
# Updatecurl -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"}'
# Deletecurl -X DELETE "https://<your-server>/api/v2/device-configuration-templates/profile/{id}" \ -H "Authorization: Bearer <API_KEY>"Related topics
Section titled “Related topics”- Managing Network Devices — for device IDs and custom variables used in render context
- Fabrics — for fabric custom variables available to templates