SonicOS API provides an alternative to the SonicOS Command Line Interface (CLI) for configuring selected functions.
SonicOS API is disabled by default in SonicOS. Any attempt to access SonicOS API while it is disabled results in an HTTP 403 Forbidden error. To use the SonicOS API, you must enable it, either through the SonicOS Management Interface or from the CLI.
This article only explains how to add an Address group and add address objects to it. Please follow these articles for additional assistance:
You are free to choose Swagger, Postman, Git bash, or any application that allows API calls, if you are using a Linux-based operating system you can execute cURL from the terminal.
Please refer to https://sonicos-api.sonicwall.com for the entire list.
Only the first part of this article would change, depending on the SonicWall model you use. Commands are the same for both Gen6 and Gen7 SonicWall devices.
For this article, I'm using Postman App and will be showing the commands to run on cURL for each step.
This release includes significant user interface changes and many new features that are different from the SonicOS 6.5 and earlier firmware. The below resolution is for customers using SonicOS 7.X firmware.


NOTE: https://IP-address:port/-- Replace this with your SonicWall's Public or private IP address with the right management port number (If the management port is 443, you can directly use https:// followed by the IP address without the port number too).



curl --location --request POST 'https://192.168.168.168/api/sonicos/auth' \--header 'Accept: application/Json' \--header 'Content-Type: application/Json' \--header 'Authorization: Basic YWRtaW46cGFzc3dvcmQ=
--data-raw '{"override" : true}'
curl --location --request POST 'https://192.168.168.168/api/sonicos/address-groups/ipv4' \--header 'Content-Type: application/Json' \--header 'Accept: application/Json' \--header 'Authorization: Basic YWRtaW46cGFzc3dvcmQ=' \--data-raw '{ "address_group": { "ipv4": { "name": "AddressGroupName", "address_object": { "ipv4": { "name": "ExistingAddressObject1" }, "mac": { "name": "ExistingAddressObject2" }, "fqdn": { "name": "ExistingAddressObject3" } } } }}'
CAUTION: This is an important step. If you miss this step, all the configuration changes made in the current session will be lost. 
curl --location --request POST 'https://192.168.168.168/api/sonicos/config/pending' \--header 'Content-Type: application/Json' \--header 'Accept: application/Json' \--header 'Authorization: Basic YWRtaW46cGFzc3dvcmQ=' \--data-raw ''Testing: Log in to the GUI of the SonicWall firewall to check the changes made. Navigate to OBJECT | Match Objects | Addresses to check for the changes.
This release includes significant user interface changes and many new features that are different from the SonicOS 6.2 and earlier firmware. The below resolution is for customers using SonicOS 6.5 firmware.


NOTE: https://IP-address:port/-- Replace this with your SonicWall's Public or private IP address with the right management port number (If the management port is 443, you can directly use https:// followed by the IP address without the port number too).


curl --location --request POST 'https://192.168.168.168/api/sonicos/auth' \--header 'Accept: application/Json' \--header 'Content-Type: application/Json' \--header 'Authorization: Basic YWRtaW46cGFzc3dvcmQ='
curl --location --request POST 'https://192.168.168.168/api/sonicos/address-groups/ipv4' \--header 'Content-Type: application/Json' \--header 'Accept: application/Json' \--header 'Authorization: Basic YWRtaW46cGFzc3dvcmQ=' \--data-raw '{ "address_group": { "ipv4": { "name": "AddressGroupName", "address_object": { "ipv4": { "name": "ExistingAddressObject1" }, "mac": { "name": "ExistingAddressObject2" }, "fqdn": { "name": "ExistingAddressObject3" } } } }}'
CAUTION: This is an important step. If you miss this step, all the configuration changes made in the current session will be lost.
curl --location --request POST 'https://192.168.168.168/api/sonicos/config/pending' \--header 'Content-Type: application/Json' \--header 'Accept: application/Json' \--header 'Authorization: Basic YWRtaW46cGFzc3dvcmQ=' \--data-raw ''Testing: Log in to the GUI of the SonicWall firewall to check the changes made. Navigate to OBJECT | Match Objects | Addresses to check for the changes.
