FortiFlex API
Instead of making changes to your FortiFlex objects in the FortiCloud portal, you can automate tasks, such as creating VMs and entitlements, with an API when integrating with cloud orchestration platforms.
FortiFlex API information can also be found on the Fortinet Developer Network along with sample Python script. |
When implementing the FortiFlex API, you can follow this general process:
-
Create an API user.
-
Acquire the API token.
-
Run API calls against the FortiFlex portal to view, create, or modify objects.
Before you begin, ensure that you have a FortiCloud account and have FortiFlex activated. |
To create an API user:
-
Go to https://support.fortinet.com.
-
Go to Services > IAM.
-
Create an active permission profile that includes the FortiFlex portal. See Creating a permission profile in the Identity & Access Management (IAM) guide.
Actions that involve changing or creating data, such as creating a new configuration or updating a VM, will require read and write permissions or above.
-
Create an API user with the permission profile from the previous step applied. See Adding an API user in the Identity & Access Management (IAM) guide.
-
Click Download Credentials and set a password. A CSV file with the API user's credentials is downloaded that can only be opened with the password. See Adding an API user in the Identity & Access Management (IAM) guide.
Downloading API user credentials will reset the user's security credentials each time you perform this action. Any previous password will become invalid.
To acquire the API token:
-
Open the Postman app.
The Postman API Toolkit can be found at https://www.postman.com. FortiFlex Postman collections can also be found on GitHub.
-
Click Create a request.
-
Enter the following information:
Method POST URL https://customerapiauth.fortinet.com/api/v1/oauth/token/ -
Click Body.
-
Select raw and JSON.
-
Enter the following content:
{ "username":"<username of your API user>", "password":"<password of your API user>", "client_id":"flexvm", "grant_type":"password" }
-
Click Send. If authentication is successful, you should receive a 200 response code with the following information:
-
access_token
: The API token that will be used to run API calls against the FortiFlex portal. -
expires_in
: The token expiration time in seconds. The default value is 1440 seconds.
-
-
Copy the
access_token
value.
To run API calls:
-
Click on the + to open a new tab in the Postman app.
-
Click Authorization.
-
Set Type to Bearer Token.
-
Paste the
access_token
value in the Token field.
The URL for the API calls is https://support.fortinet.com. |