FortiMail REST API Reference
FortiMail REST API Reference
Version 5.3
1
FORTINET DOCUMENT LIBRARY
http://docs.fortinet.com
FORTINET BLOG
https://blog.fortinet.com
FORTINET COOKBOOK
http://cookbook.fortinet.com
FORTIGUARD CENTER
http://www.fortiguard.com
FEEDBACK
Email: techdocs@fortinet.com
Introduction ........................................................................................................................................................................ 4
Enabling REST API support ............................................................................................................................................ 4
Authentication .................................................................................................................................................................... 4
Setting up an authenticated session .............................................................................................................................. 4
FortiMail REST API HTTP response codes .................................................................................................................. 5
REST API for system level resources ............................................................................................................................ 5
REST API for domain level resources ........................................................................................................................... 6
REST API for administrative actions .............................................................................................................................. 7
System resource list and URLs....................................................................................................................................... 7
Example commands ....................................................................................................................................................... 15
Admin login .................................................................................................................................................................. 15
Get domain information .............................................................................................................................................. 15
Access control rule management ............................................................................................................................. 15
List Access Control Rules ...................................................................................................................................... 16
Create a new Access Control Rule ...................................................................................................................... 16
Modify an existing Access Control Rule .............................................................................................................. 16
Delete an existing Access Control Rule .............................................................................................................. 17
Move existing Access Control Rules .................................................................................................................... 17
3
Introduction
This document provides the REST API information supported in FortiMail version 5.3.4 release. This document
covers the FortiMail GUI supported REST API reference only. These APIs can be used to retrieve, create,
update and delete configuration settings, to retrieve dynamic system statistics, and to perform basic
administrative actions such as reboot and shut down.
Http POST --- To create a new resource or perform certain administrative actions
By default, this feature is disabled on FortiMail. To enable it, use the following CLI command:
Authentication
When making requests to FortiMail appliance using the REST API, you will need
1. A valid admin username and password (so that an authenticated session can be established)
2. Appropriate access permissions for the requested resource (controlled by admin profile)
URL: http(s)://host_or_ip/api/v1/AdminLogin/
4
Method: POST
If login is successful, the response will contain the authentication token in the APSCOOKIE cookie value. This
cookie value must be included in any further requests.
Note: The permissions for the administrative account you use will affect which objects and operations you'll
have access to, so ensure the user has the permissions required for the actions you wish to perform.
403 - Forbidden Request is missing authentication token or administrator is missing access profile
permissions.
405- Method Not Allowed Specified HTTP method is not allowed for this resource
http(s)://host_ip/api/v1/resource_name/resource_id/sub_resource_name/sub_resource_id/
where:
resource_name --- Specifies the type of resource to query (such as SysInterface), required.
resource_id --- Unique ID of the resource as specified by resource_name (such as port1), optional.
If not present, returns entire list of resources.
sub_resource_name --- Some resources may have sub / child resources, use this to query sub resources,
5
optional
sub_resource_id --- Unique ID of the sub resource as specified by sub_resource_name, optional. If not
present, returns entire list of sub resources.
Examples:
…/api/v1/ProfSession/inbound/ ProfSessionSenderWhitelist/
For a full list of system level resources, refer to the Supported Resources List.
http(s)://host_ip/api/v1/domain/domain_name/resource_name/resource_id/sub_r
esource_name/sub_resource_id/
It is very similar to the URL for system level resources, only two new tokens are added:
Examples:
…/api/v1/domain/abc.com/ProfAntispam/
…/api/v1/domain/abc.com/PolicyRecipient/
…/api/v1/domain/abc.com/PolicyRecipient/1/
--- returns details of recipient based policy ‘1’ for domain ‘abc.com’
For a full list of domain level resources, refer to the Supported Resources List.
6
REST API for administrative actions
Apart from resources, FortiMail REST API supports basic administrative actions such as restarting / shutting
down a device. Use the following URL to send action request:
URL: http(s)://host_ip/api/v1/SysStatusCommand/
Method: POST
1 --- Restart
3 --- Reload
7
/AsDeepheader/ GET, PUT Deep header analysis
settings
9
* DELETE
10
/ProfDictionary/ GET, POST, PUT, Dictionary profiles
DELETE
11
DELETE safelist
12
/SysDateSetting/ GET, PUT System date
13
/SysSched_backup/ GET, PUT System configuration
scheduled backup settings
14
/UserMap/ GET, POST, PUT, Address maps
* DELETE
Example commands
Admin login
If login is successful, the cookies will be save to cookie.txt, which will be used in the below commands.
Supported values for 'action' attribute of ACL. If not set, the default action is reject.
1 --- safe-relay
2 --- relay
3 --- reject
4 --- discard
5 --- safe
0 --- any
1 --- authenticated
2 --- not-authenticated
15
Supported values for 'sender-ip-type' attribute of ACL:
0 --- ip mask
1 --- ip group
Supported values for 'sortingDirection' attribute of applicable JSON requests (i.e. ACL rule):
1 --- enabled/sorting
2 --- disabled/no sorting
1 --- GET
2 --- CREATE
3 --- DELETE
5 --- UPDATET
14 --- MOVE
Note: If reqAction is present in JSON, it takes precedence over HTTP method header (i.e. HTTP
GET/POST/PUT/DELETE).
16
--Set access rule "1" action to “Reject”
refMkey: 2 – required, reference ID of the ACL rule when moving before/after this ID
17
Copyright© 2016 Fortinet, Inc. All rights reserved. Fortinet®, FortiGate®, FortiCare® and FortiGuard®, and certain other marks are registered trademarks of Fortinet, Inc., in the
U.S. and other jurisdictions, and other Fortinet names herein may also be registered and/or common law trademarks of Fortinet. All other product or company names may be
trademarks of their respective owners. Performance and other metrics contained herein were attained in internal lab tests under ideal conditions, and actual performance and
other results may vary. Network variables, different network environments and other conditions may affect performance results. Nothing herein represents any binding
commitment by Fortinet, and Fortinet disclaims all warranties, whether express or implied, except to the extent Fortinet enters a binding written contract, signed by Fortinet’s
General Counsel, with a purchaser that expressly warrants that the identified product will perform according to certain expressly-identified performance metrics and, in such
event, only the specific performance metrics expressly identified in such binding written contract shall be binding on Fortinet. For absolute clarity, any such warranty will be
limited to performance in the same ideal conditions as in Fortinet’s internal lab tests. In no event does Fortinet make any commitment related to future deliverables, features, or
development, and circumstances may change such that any forward-looking statements herein are not accurate. Fortinet disclaims in full any covenants, representations, and
guarantees pursuant hereto, whether express or implied. Fortinet reserves the right to change, modify, transfer, or otherwise revise this publication without notice, and the most
current version of the publication shall be applicable.