Skip to main content
farhanahmed
Staff
Staff
Mar 14, 2025 6:58 AM UTC

Technical Tip: How to create a CLI Template and Pre-Run CLI Template using JSON API

Description This article describes how to create a CLI Template and Pre-Run CLI Template using JSON API.
Scope FortiManager, JSON-API.
Solution

A CLI Template can be created using API request below:

{
 "method": "add",
 "params": [
        {
            "data": [

                {
                   "description": "{{DESCRIPTION}}",
                   "name": "{{TEMPLATE_NAME}}",
                   "provision": "disable",
                   "script": "config system global\nset hostname FGT40F\nend",
                   "type": "cli"
                },

           ]
            "url": "pm/config/adom/{{ADOM}}/obj/wireless-controller/vap/"
        }
    ],
    "session": "{{session}}",
    "id": "1"

}

 

Sample output:

 

1.png

 

To create a Pre-Run CLI template, use the same API request and set 'provision': 'enable' on line #9. To create a JINJA template, set 'type': 'jinja' on line #11.
 

Related articles:
Technical Tip: Using FortiManager API.
Fortinet Development Network (FNDN) - FortiManager.
Technical Tip: How to create IPSec Template and assign to a device using JSON API.

 

Thought Leadership. Security Summit. Thursday, November 12th, PGA National Resort, Palm Beach Gardens, FL.
Security Operations Summit: Modernize SecOps. Operate AI-Native.AMER: November 4 | 9:00 AM PST. India and SAARC: November 5 | 10:00 AM IST. EMEA: November 5 | 10:30 AM CET. APAC: November 5 | 11:00 AM SGT