PAN-OS® and Panorama™API Usage Guide - V10.1
PAN-OS® and Panorama™API Usage Guide - V10.1
Guide
Version 10.1
docs.paloaltonetworks.com
Contact Informaon
Corporate Headquarters:
Palo Alto Networks
3000 Tannery Way
Santa Clara, CA 95054
www.paloaltonetworks.com/company/contact-support.html
Copyright
Palo Alto Networks, Inc.
www.paloaltonetworks.com
©2021–2022 Palo Alto Networks, Inc. Palo Alto Networks is a registered trademark of Palo
Alto Networks. A list of our trademarks can be found at www.paloaltonetworks.com/company/
trademarks.html. All other marks menoned herein may be trademarks of their respecve
companies.
Last Revised
March 15, 2022
PAN-OS® and Panorama™API Usage Guide Version Version 2 ©2022 Palo Alto Networks, Inc.
10.1
Table of Contents
About the PAN-OS API.................................................................................... 7
PAN-OS XML API Components............................................................................................... 8
Structure of a PAN-OS XML API Request.............................................................................9
API Authencaon and Security.................................................................................. 9
XML and XPath.............................................................................................................. 10
XPath Node Selecon...................................................................................................11
PAN-OS® and Panorama™API Usage Guide Version Version 3 ©2022 Palo Alto Networks, Inc.
10.1
Table of Contents
PAN-OS® and Panorama™API Usage Guide Version Version 4 ©2022 Palo Alto Networks, Inc.
10.1
Table of Contents
PAN-OS® and Panorama™API Usage Guide Version Version 5 ©2022 Palo Alto Networks, Inc.
10.1
Table of Contents
PAN-OS® and Panorama™API Usage Guide Version Version 6 ©2022 Palo Alto Networks, Inc.
10.1
About the PAN-OS API
The PAN-OS® and Panorama™ API allows you to manage firewalls and Panorama
through a third-party service, applicaon, or script. The firewalls and Panorama
support two types of API—XML API and REST API.
The XML API uses a tree of XML nodes to map firewall or Panorama funconality. To
make an API request, you must specify the XPath (XML Path Language) to the XML
node that corresponds to a specific seng or acon. XPath allows you to navigate
through the hierarchical XML tree structure for firewalls and Panorama. To get started,
see:
You can use the REST API to Create, Update, Read, Delete (CRUD) Objects and
Policies on the firewalls; you can access the REST API directly on the firewall or use
Panorama to perform these operaon on policies and objects from a central locaon
and push them to the managed firewalls. To get started, see Access the PAN-OS REST
API.
Because PAN-OS API funconality mirrors that of both the web interface and the
CLI, you should familiarize yourself with both. Reading relevant porons of the
PAN-OS Administrator’s Guide will help you get a beer understanding of firewall
funconalies that you can access using the API. You should also be knowledgeable
about web service APIs, HTTP, XML, and XPath.
7
About the PAN-OS API
Feature Descripon
Full access to PAN-OS The PAN-OS XML API allows you to access almost all of the
funconality funconality normally provided through the firewall web
interface and CLI.
Secure authencaon and Use your administrave username and password to generate
access using API key and admin an API key to authencate API calls. Granular roles allow you
roles to grant API access to specific funconality including reports,
logs, and operaonal mode commands.
Opons to view XML syntax To explore all various funcons of the API, you can use the
through API browser, CLI and API browser through the firewall web interface. You can
web interface debug mode also enable debug mode through the CLI to see the API
equivalent of CLI commands.
To learn about the PAN-OS REST API, see PAN-OS REST API.
To learn about changes to the latest version of CLI commands that affect corresponding PAN-OS
XML API requests, see the PAN-OS CLI Quick Start.
PAN-OS® and Panorama™API Usage Guide Version Version 8 ©2022 Palo Alto Networks, Inc.
10.1
About the PAN-OS API
• API key (key=): The API key allows you to authencate yourself to the API when making
requests. Learn about API Authencaon and Security and how to Get Your API Key.
• Request type (type=): Because the XML API allows you to perform a wide array of requests,
you must first specify the type of request you want, ranging from configuraon to operaon,
imporng to exporng, and from reports to user ID. Learn more about Request Types.
• Acon (action=): When the request type isconfig (configuraon) orop (operaonal mode
command), you must also specify an associated acon, such asedit,delete, ormove. Learn
more about Configuraon Acons.
• XML and XPath elements (xpath= orcmd=): When using configuraon or operaonal mode
commands on the firewall, you include only the XML or the XPath that specifies the XML node.
Learn more about XML and XPath and XPath Node Selecon.
To make requests to the PAN-OS XML API, you can use the GET and POST methods.
Use a GET request when the query size is less than 2K and you want to pass strings in the Request
URL. When using the GET method, append the query string to the request URL as a URL-encoded
parameter string:
GET /api/?type=keygen&user=<username>&password=<password>
Use a POST request when you are sending large amounts of form data (the request size is
between 2K to 5MB; limit the request size to 5MB) or when you are passing non-ASCII characters.
Some API requests, such as imporng files, require POST. When using the POST method, pass the
parameters in the request body. In this example, the request body includes the login credenals:
Content-Type: application/x-www-form-urlencoded
password=<password>&user=<username>&type=keygen
If you want to learn about the PAN-OS REST API structure, see PAN-OS REST API Request and
Response Structure.
PAN-OS® and Panorama™API Usage Guide Version Version 9 ©2022 Palo Alto Networks, Inc.
10.1
About the PAN-OS API
• Use the custom HTTP header,X-PAN-KEY: <key> to include the API key in the HTTP header.
• For the XML API, include the API key as a query parameter in the HTTP request URL.
• Use Basic Authencaon to pass the admin credenals asusername:password with Base64
encoding in an Authorizaon header field.
You cannot use basic authencaon when you Get Your API Key.
To enforce key rotaon set an API key lifeme; you can also revoke all API keys to protect from
accidental exposure.
Ensure you replace variables such as <hostname> and <APIkey> with the IP address or hostname
of your firewall or Panorama and API key, respecvely.
When making configuraon requests (type=config), you can use XPath, a syntax for selecng
nodes from within an XML document. Use the XPath to isolate and modify porons of your
configuraon. The XML configuraon within PAN-OS uses four different types of nodes as shown
here:
<users>
<entry name="admin">
<permissions>
<role-based>
<superuser>yes</superuser>
</role-based>
</permissions>
</entry>
<entry name="guest">
<permissions>
<role-based>
<custom>
<profile>NewUser</profile>
</custom>
</role-based>
</permissions>
</entry>
</users>
PAN-OS® and Panorama™API Usage Guide Version Version 10 ©2022 Palo Alto Networks, Inc.
10.1
About the PAN-OS API
• Root nodes are top-level nodes with no parent. Requesng the root node returns all child
elements.
• Element nodes represent containers of informaon. Element nodes can contain other
element nodes or simply act as a container of informaon. Example:<permissions></
permissions>
• Aribute nodes are nodes that contain name/value pairs. Example:<entry
name="admin"></entry>
• Text nodes contain plain text. Example:<superuser>yes</superuser>
Explore the API with the API browser, CLI, or debug console to learn how to construct XML
requests.
/config/mgt-config/users
The above path specifies the following XML node that includes all users:
<users>
<entry name="admin">
<permissions>
<role-based>
<superuser>yes</superuser>
</role-based>
</permissions>
</entry>
<entry name="guest">
<permissions>
<role-based>
<custom>
<profile>NewUser</profile>
</custom>
</role-based>
</permissions>
</entry>
</users>
PAN-OS® and Panorama™API Usage Guide Version Version 11 ©2022 Palo Alto Networks, Inc.
10.1
About the PAN-OS API
Another method for selecng the XPath for an XML node is to select the specific node, such as
thesuperuser orNewUser node within the node shown above. Use XPath syntax similar to the
following to drill-down and select a specific node:
/config/mgt-config/users/
entry/permissions/role-based/
superuser[text()='yes']
/config/mgt-config/users/entry/
permissions/role-based/custom/
profile[text()='NewUser']
PAN-OS® and Panorama™API Usage Guide Version Version 12 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
To use the PAN-OS XML API, first use your admin credenals to get an API key
through the keygen command type. You can then use the API key to test a simple
call.
This guide exercises API requests using cURL commands. However, you can use other
API tools such as Postman and RESTClient to make API requests. By default, PAN-OS
uses a self-signed cerficate, so you will need to use -k parameter with cURL requests.
Alternavely, you must replace the self-signed cerficate with one from a known
cerficate authority. If you have an internal cerficate authority, generate your own
cerficate and install it on the firewall.
13
Get Started with the PAN-OS XML API
As a best pracce, set up a separate admin account for XML API access.
PAN-OS® and Panorama™API Usage Guide Version Version 14 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
If you have an exisng key and generate another key for the same user, all exisng sessions
will end for the user and previous API sessions will be deleted. If the cookie for the request
doesn’t exist but you make subsequent requests, configuraon logs will show the user as
unknown.
STEP 1 | To generate an API key, make a GET or POST request to the firewall’s hostname or IP
addresses using the administrave credenals andtype=keygen:
or
A successful API call returns status="success" along with the API key within the key
element:
<response status="success">
<result>
<key>gJlQWE56987nBxIqyfa62sZeRtYuIo2BgzEA9UOnlZBhU==</key>
</result>
</response>
This is an example API Key, when you retrieve your API Key, use the key in its enrety,
including any symbols such as equal signs.
If you use Panorama to manage your firewalls, Panorama and all of the firewalls that it
manages must have the same master key.
PAN-OS® and Panorama™API Usage Guide Version Version 15 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
STEP 2 | When making a request to the firewall, include the base64 converted token in the header
preceded by Authorization: Basic
Example:
STEP 3 | Include the header in each of the subsequent requests to the firewall.
PAN-OS® and Panorama™API Usage Guide Version Version 16 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
All the query strings in Get requests must be a URL-Encoded parameter string. If you use a space
in the URL-Encoded request, you must include either a plus sign or %20 to replace the space.
If you have trouble replicang any of the API requests in our documentaon as a first step, Use
the API Browser to build your requests.
STEP 1 | Make a cURL call to get system informaon, which returns the IP address, hostname, and
model of your firewall. Be sure to include the API key:
When you make your API calls, as an alternave to providing the URL encoded API
key in the request URL, you can use the custom X-PAN-KEY: <key> parameter to
add the key as a name value pair in the HTTP header. For example,curl -H "X-
PAN-KEY: LU234T02234565s2Z1FtZWFyWXJOSTdk1234565234565=" -k
'https://firewall_IP/api/?
type=op&cmd=<show><system><info></info></system></show>'
STEP 2 | Confirm that the response to the above request looks similar to this:
<response status="success">
<result>
<system>
<hostname>PA-3050-A</hostname>
<ip-address>10.2.3.4</ip-address>
<public-ip-address>unknown</public-ip-address>
<netmask>255.255.252.0</netmask>
<default-gateway>10.2.3.1</default-gateway>
<is-dhcp>no</is-dhcp>
<ipv6-address>unknown</ipv6-address>
<ipv6-link-local-address>c123::21b:ffff:feff:c1234/64</ipv6-
link-local-address>
<ipv6-default-gateway/>
PAN-OS® and Panorama™API Usage Guide Version Version 17 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
<mac-address>00:00:00:ff:c7:00</mac-address>
<time>Tue Jan 8 16:22:56 2019</time>
<uptime>0 days, 18:28:38</uptime>
<devicename>PA-3050-A</devicename>
<family>3000</family>
<model>PA-3050</model>
<serial>0017010.1529</serial>
<cloud-mode>non-cloud</cloud-mode>
<sw-version>9.0.0-b36</sw-version>
<global-protect-client-package-version>0.0.0</global-protect-
client-package-version>
<app-version>8111-5239</app-version>
<app-release-date>2019/01/07 15:51:30 PST</app-release-date>
<av-version>3328-3783</av-version>
<av-release-date>2019/01/07 11:22:02 PST</av-release-date>
<threat-version>8111-5239</threat-version>
<threat-release-date>2019/01/07 15:51:30 PST</threat-release-
date>
<wf-private-version>0</wf-private-version>
<wf-private-release-date>unknown</wf-private-release-date>
<url-db>paloaltonetworks</url-db>
<wildfire-version>0</wildfire-version>
<wildfire-release-date/>
<url-filtering-version>2019010.1.00005</url-filtering-
version>
<global-protect-datafile-version>unknown</global-protect-
datafile-version>
<global-protect-datafile-release-date>unknown</global-
protect-datafile-release-date>
<global-protect-clientless-vpn-version>0</global-protect-
clientless-vpn-version>
<global-protect-clientless-vpn-release-date/>
<logdb-version>9.0.10</logdb-version>
<platform-family>3000</platform-family>
<vpn-disable-mode>off</vpn-disable-mode>
<multi-vsys>on</multi-vsys>
<operational-mode>normal</operational-mode>
</system>
</result>
</response>
PAN-OS® and Panorama™API Usage Guide Version Version 18 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
PAN-OS® and Panorama™API Usage Guide Version Version 19 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
2. Drill down further unl you select a request that you want to test.
PAN-OS® and Panorama™API Usage Guide Version Version 20 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
Along with the URL, the API browser also provides the XPath as necessary, as shown
here for a descripon of a predefined applicaon:
PAN-OS® and Panorama™API Usage Guide Version Version 21 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
To learn about changes to the latest version of CLI commands that affect corresponding
PAN-OS XML API requests, see the PAN-OS CLI Quick Start.
Use the CLI to enable debug mode and then run the CLI command to receive the corresponding
XML and XPath in the response.
STEP 1 | Access the CLI.
Use an SSH client or terminal to access your firewall or Panorama CLI.
debug cli on
https://<firewall>/api/?type=op&cmd=<test><url>http://
paloaltonetworks.com</url></test>&key=<apikey>
PAN-OS® and Panorama™API Usage Guide Version Version 22 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
Depending on the CLI command, the XML tag values forcmd will vary. For example,
here is a CLI command for showing firewall informaon:run show system info
The corresponding API call looks like this:
http://<firewall>/debug
PAN-OS® and Panorama™API Usage Guide Version Version 23 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
STEP 3 | Perform the acon you want to replicate through the API.
In the web browser, navigate to the menu and item or acon that you want to perform.
To aid in finding the relevant XML, select Clear in the debug console just before you select the
final menu or acon.
PAN-OS® and Panorama™API Usage Guide Version Version 24 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
</request>
PAN-OS® and Panorama™API Usage Guide Version Version 25 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
2-5 Internal errors Check with technical support when seeing these errors.
7 Object not present Object specified by the xpath is not present. For
example, entry[@name='value'] where no object with
name 'value' is present.
8 Object not unique For commands that operate on a single object, the
specified object is not unique.
10 Reference count not zero Object cannot be deleted as there are other objects
that refer to it. For example, address object sll in use in
policy.
11 Internal error Check with technical support when seeing these errors.
14 Operaon not possible Operaon is allowed but not possible in this case.
For example, moving a rule up one posion when it is
already at the top.
PAN-OS® and Panorama™API Usage Guide Version Version 26 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
16 Unauthorized The API role does not have access rights to run this
query.
21 Internal error Check with technical support when seeing these errors.
22 Session med out The session for this query med out.
PAN-OS® and Panorama™API Usage Guide Version Version 27 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS XML API
PAN-OS® and Panorama™API Usage Guide Version Version 28 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
The following use cases highlight the use of the PAN-OS XML API, either to reduce
repeve steps or to automate tasks normally you perform through the web interface
or CLI.
Because the PAN-OS XML API uses a tree of XML nodes, in your API request you
must specify the correct type and acon along with the XPath Node Selecon. See
Explore the API to learn how to construct XML requests to be successful in using the
API to meet your automaon needs.
29
PAN-OS XML API Use Cases
If successful, the response contains a jobid that you can use to check on the status of your
request.
<response status="success">…
PAN-OS® and Panorama™API Usage Guide Version Version 30 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
If successful, the response contains a jobid that you can use to check on the status of your
request.
<response status="success">…
<response
status="success">
<result>
PAN-OS® and Panorama™API Usage Guide Version Version 31 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
2. Use the jobid in the response to ensure that the system update download completes
successfully:
<response status="success">…
PAN-OS® and Panorama™API Usage Guide Version Version 32 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
<response status="success">…
PAN-OS® and Panorama™API Usage Guide Version Version 33 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
The response contains a list of users along with related informaon including IP addresses,
logins, and client informaon:
<response status="success">
<result>
<entry>
<domain/>
<islocal>yes</islocal>
<username>dward</username>
<computer>Dan’s iPhone</computer>
<client>Apple iOS 8.1.2</client>
<vpn-type>Device Level VPN</vpn-type>
<virtual-ip>192.168.2.1</virtual-ip>
<public-ip>166.173.63.240</public-ip>
<tunnel-type>SSL</tunnel-type>
<login-time>Jan.22 01:50:36</login-time>
<login-time-utc>1421916636</login-time-utc>
<lifetime>2592000</lifetime>
</entry>
</result>
</response>
The <login-time-utc> field is the login date/me in UNIX me format (number of seconds
elapsed since 00:00:00 1 Jan 1970). To find the list of users, filter the output for this field and
compare the <login-time-utc> value to current date and me (or another date and me).
PAN-OS® and Panorama™API Usage Guide Version Version 34 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
</request>&key=<apikey>'
A successful response shows that the user has been successfully disconnected:
<response status="success">
<result>
<response status="success">
<gateway>Home-N</gateway>
<domain>(null)</domain>
<user>dward</user>
<computer>Dan’s iPhone</computer>
</response>
</result>
</response>
PAN-OS® and Panorama™API Usage Guide Version Version 35 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
Currently, you can only usetype=op queries when redirecng queries through Panorama.
Because the PAN-OS XML API uses a tree of XML nodes, in your API request you must
specify the correct type and acon along with the XPath Node Selecon. See Explore
the API to learn how to construct XML requests.
<response
status="success">
<result>
<devices>
name="007200002517">
<serial>007200002342</serial>
<connected>yes</connected>
<unsupported-version>no</unsupported-version>
<deactivated>no</deactivated>
<hostname>PM-6-1-VM</hostname>
<ip-address>10.3.4.137</ip-address>
<mac-addr />
<uptime>81 days, 20:39:41</uptime>
<family>vm</family>
<model>PA-VM</model>
<sw-version>6.1.3</sw-version>
<app-version>555-3129</app-version>
<av-version>2254-2693</av-version>
<wildfire-version>91873-10.174</wildfire-version>
<threat-version>555-3129</threat-version>
<url-db>paloaltonetworks</url-db>
PAN-OS® and Panorama™API Usage Guide Version Version 36 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
<url-filtering-version>2016.02.02.416</url-filtering-
version>
<logdb-version>6.1.3</logdb-version>
<vpnclient-package-version />
<global-protect-client-package-version>0.0.0</global-
protect-client-package-version>
<vpn-disable-mode>no</vpn-disable-mode>
<operational-mode>normal</operational-mode>
<multi-vsys>no</multi-vsys>
<vsys>
name="vsys1">
<display-name>vsys1</display-name>
<shared-policy-status />
<shared-policy-md5sum>4a0913667df83ff1098492e2e2ec1756</
shared-policy-md5sum>
</entry>
</vsys>
</entry>
<!--truncated -->
</devices>
</result>
</response>
To directly target a firewall through Panorama, append the firewall serial number to the
request:
<response status="success">
<result>
<system>
<hostname>firewall</hostname>
<ip-address>10.41.0.8</ip-address>
<netmask>255.255.224.0</netmask>
PAN-OS® and Panorama™API Usage Guide Version Version 37 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
<default-gateway>10.41.0.1</default-gateway>
<is-dhcp>no</is-dhcp>
<ipv6-address>unknown</ipv6-address>
<ipv6-link-local-address>fe80::21c:17cf:feff:c04a/64</ipv6-
link-local-address>
<ipv6-default-gateway/>
<mac-address>00:1b:17:fc:c0:4a</mac-address>
<time>Tue Oct 27 13:39:09 2015</time>
<uptime>12 days, 0:05:26</uptime>
<devicename>pm-firewall</devicename>
<family>3000</family>
<model>PA-3020</model>
<serial>001802000104</serial>
<sw-version>7.1.0-c54</sw-version>
<global-protect-client-package-version>2.0.0</global-protect-
client-package-version>
<app-version>537-2965</app-version>
<app-release-date>2015/10/26 18:10:48</app-release-date>
<av-version>2149-2586</av-version>
<av-release-date>2015/10/26 15:31:55</av-release-date>
<threat-version>537-2965</threat-version>
<threat-release-date>2015/10/26 18:10:48</threat-release-
date>
<wf-private-version>0</wf-private-version>
<wf-private-release-date>unknown</wf-private-release-date>
<url-db>paloaltonetworks</url-db>
<wildfire-version>80683-89773</wildfire-version>
<wildfire-release-date>unknown</wildfire-release-date>
<url-filtering-version>2015.10.27.226</url-filtering-version>
<global-protect-datafile-version>1445974904</global-protect-
datafile-version>
<global-protect-datafile-release-date>2015/10/27 19:41:44</
global-protect-datafile-release-date>
<logdb-version>7.0.9</logdb-version>
<platform-family>3000</platform-family>
<vpn-disable-mode>off</vpn-disable-mode>
<multi-vsys>on</multi-vsys>
<operational-mode>normal</operational-mode>
</system>
</result>
</response>
PAN-OS® and Panorama™API Usage Guide Version Version 38 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
This is a high-level overview of the steps you must take in this procedure. You script or
applicaon must incorporate error-checking and logic to implement this sequence of steps.
Because the PAN-OS XML API uses a tree of XML nodes, in your API request you must
specify the correct type and acon along with the XPath Node Selecon. See Explore
the API to learn how to construct XML requests.
STEP 1 | Check for the latest PAN-OS soware update through Panorama
Check for the latest available PAN-OS soware updates. Include the firewall serial number in
your request:
The response contains an array of results sorted to show the latest version first:
<response status="success">
<result>
<sw-updates last-updated-at="2016/02/03 08:29:09">
<msg />
<versions>
>
<version>7.1</version>
<filename>PanOS_vm-7.1</filename>
<size>540</size>
<size-kb>553964</size-kb>
<released-on>2016/02/02 10:57:20</released-on>
<release-notes><![CDATA[https://10.44.2.19/
updates/ReleaseNotes.aspx?type=sw&versionNumber=7.1.0-
c158&product=panos&platform=vm]]></release-notes>
<downloaded>no</downloaded>
<current>no</current>
<latest>yes</latest>
</entry>
<!-- truncated -->
</versions>
</sw-updates>
</result>
</response>
PAN-OS® and Panorama™API Usage Guide Version Version 39 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
curl -X GET
'https://<firewall>/api/?
key=apikey&type=op&cmd=<request><system><software><download><version>7.1.
-c65</version></download></software></system></
request>&key=<apikey>'
2. Use the jobid in the response to ensure that the system update download completes
successfully:
<response status="success">…
<response status="success">…
<response status="success">
: <result>
: <devices>
: name="007200002517">
PAN-OS® and Panorama™API Usage Guide Version Version 40 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
: <serial>007200002342</serial>
: <connected>yes</connected>
: <unsupported-version>no</unsupported-version>
: <deactivated>no</deactivated>
: <hostname>PM-6-1-VM</hostname>
: <ip-address>10.3.4.137</ip-address>
: <mac-addr />
: <uptime>81 days, 20:39:41</uptime>
<family>vm</family>
<model>PA-VM</model>
<sw-version>6.1.3</sw-version>
<app-version>555-3129</app-version>
<av-version>2254-2693</av-version>
<wildfire-version>91873-10.174</wildfire-version>
<threat-version>555-3129</threat-version>
<url-db>paloaltonetworks</url-db>
<url-filtering-version>2016.02.02.416</url-filtering-
version>
<logdb-version>6.1.3</logdb-version>
<vpnclient-package-version />
<global-protect-client-package-version>0.0.0</global-
protect-client-package-version>
<vpn-disable-mode>no</vpn-disable-mode>
<operational-mode>normal</operational-mode>
<multi-vsys>no</multi-vsys>
<vsys>
name="vsys1">
<display-name>vsys1</display-name>
<shared-policy-status />
<shared-policy-
md5sum>4a0913667df83ff1098492e2e2ec1756</shared-policy-md5sum>
</entry>
</vsys>
</entry>
<!--truncated -->
</devices>
</result>
</response>
The response contains a <serial> XML element that contains each firewall serial number.
The response contains an array of results sorted to show the latest version first:
<response status="success">
<result>
<sw-updates last-updated-at="2016/02/03 08:29:09">
PAN-OS® and Panorama™API Usage Guide Version Version 41 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
<msg />
<versions>
<version>7.1</version>
<filename>PanOS_vm-7.1</filename>
<size>540</size>
<size-kb>553964</size-kb>
<released-on>2016/02/02 10:57:20</released-on>
<release-notes><![CDATA[https://10.44.2.19/updates/
ReleaseNotes.aspx?type=sw&versionNumber=7.1.0-
c158&product=panos&platform=vm]]></release-notes>
<downloaded>no</downloaded>
<current>no</current>
<latest>yes</latest>
</entry>
<!-- truncated -->
</versions>
</sw-updates>
</result>
</response>
The response contains a job status of FIN when the download is complete:
<response status="success">
<result>
<job>
<tenq>2016/02/03 08:32:00</tenq>
<id>3448</id>
<user/>
<type>Downld</type>
PAN-OS® and Panorama™API Usage Guide Version Version 42 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
<status>FIN</status>
<stoppable>no</stoppable>
<result>OK</result>
<tfin>08:32:10</tfin>
<progress>08:32:10</progress>
<details>
<line>Successfully downloaded</line>
<line>Preloading into software manager</line>
<line>Successfully loaded into software manager</line>
</details>
<warnings/>
</job>
</result>
</response>
<response status="success">
<result>Successfully changed HA state to suspended</result>
</response>
PAN-OS® and Panorama™API Usage Guide Version Version 43 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
<response status="success">…
<response status="success">
<result>Successfully changed HA state to functional</result>
</response>
PAN-OS® and Panorama™API Usage Guide Version Version 44 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
Download, upgrade, and installaon requests are asynchronous. The API responds with a
job ID while it processes your request. In your subsequent request, you use this job ID to
check on the result of your original request:
STEP 1 | Check for installed content on your firewall. Run the following request to view current
system informaon:
STEP 2 | Confirm that the API response to the request in the previous step includes the currently
installed updates on your firewall:
<response status="success">
<result>
<system>
<hostname>pm-firewall</hostname>
<ip-address>10.47.0.8</ip-address>
<netmask>255.255.254.0</netmask>
<default-gateway>10.47.0.1</default-gateway>
<is-dhcp>no</is-dhcp>
<ipv6-address>unknown</ipv6-address>
<ipv6-link-local-address>fe80::21b:17ff:feff:c04a/64</ipv6-
link-local-address>
<ipv6-default-gateway/>
<mac-address>00:1b:17:ff:c0:4a</mac-address>
<time>Mon Jul 11 17:51:37 2016</time>
<uptime>11 days, 7:38:34</uptime>
<devicename>pm-firewall</devicename>
<family>3000</family>
<model>PA-3020</model>
<serial>0018010.1104</serial>
<sw-version>7.1.3</sw-version>
<global-protect-client-package-version>2.0.0</global-protect-
client-package-version>
<app-version>598-3427</app-version>
<app-release-date>2016/07/09 22:30:55</app-release-date>
<av-version>2416-2855</av-version>
<av-release-date>2016/07/10 11:27:57</av-release-date>
<threat-version>598-3427</threat-version>
PAN-OS® and Panorama™API Usage Guide Version Version 45 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
<threat-release-date>2016/07/09 22:30:55</threat-release-
date>
<wf-private-version>0</wf-private-version>
<wf-private-release-date>unknown</wf-private-release-date>
<url-db>paloaltonetworks</url-db>
<wildfire-version>80426-81466</wildfire-version>
<wildfire-release-date>2016/07/11 17:45:11</wildfire-release-
date>
<url-filtering-version>2016.07.11.248</url-filtering-version>
<global-protect-datafile-version>1468280405</global-protect-
datafile-version>
<global-protect-datafile-release-date>2016/07/11 23:40:05</
global-protect-datafile-release-date>
<logdb-version>7.0.9</logdb-version>
<platform-family>3000</platform-family>
<vpn-disable-mode>off</vpn-disable-mode>
<multi-vsys>on</multi-vsys>
<operational-mode>normal</operational-mode>
</system>
</result>
</response>
STEP 3 | Note the currently installed versions for the following updates, so that you can compare the
values aer you check for the latest updates:
• global-protect-client-package-version: GlobaProtect
• app-version: Applicaon and threat signatures.
• av-version: Anvirus signatures
• wildfire-version: WildFire malware and anvirus signatures
PAN-OS® and Panorama™API Usage Guide Version Version 46 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
STEP 4 | Check for new, available updates with the following requests and store the version field in
the response, which is the version field for GlobalProtect, and the app-version field for
all others:
• GlobalProtect:
• WildFire:
• Anvirus:
Example response:
<response status="success">
<result>
<sw-updates last-updated-at="2016/05/19 14:34:34">
<msg/>
<versions>
<entry>
<version>4.0.0-c16</version>
<filename>PanGP-4.0.0-c16</filename>
<size>44</size>
<size-kb>45321</size-kb>
<released-on>2016/07/08 15:41:18</released-on>
<release-notes>
<![CDATA[
https://firewall/updates/ReleaseNotes.aspx?
type=sw&versionNumber=4.0.0-c16&product=gpclient&platform=any
]]>
</release-notes>
<downloaded>no</downloaded>
<current>no</current>
<latest>no</latest>
<uploaded>no</uploaded>
</entry>
PAN-OS® and Panorama™API Usage Guide Version Version 47 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
<!--TRUNCATED-->
Take note of the released-on XML field to verify that updates have been released for at
least a week.
STEP 5 | In your script or code, compare the version values for currently installed updates to new,
available updates. It is recommended that you only install updates that have been available
for at least a week.
• WildFire:
• Anvirus:
The response contains a job ID that you can use to check on the status of the request.
Example:
Learn more about Asynchronous and Synchronous Requests to the PAN-OS XML API.
PAN-OS® and Panorama™API Usage Guide Version Version 48 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
• WildFire:
• Anvirus:
The response contains a job ID that you can use to check on the status of the request.
PAN-OS® and Panorama™API Usage Guide Version Version 49 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
STEP 1 | Build an AutoFocus export list. For example, if you want to block potenal aacks from the
Sofacy group, search for Sofacy as the Tag, and then add the appropriate arfacts shown
within the File Analysis tab, such as DNS Acvity, HTTP Requests, and Connecon Acvity.
The response contains a list of IP addresses, domains, or URLs, depending on the arfacts you
save:
{
"bucket_info": {
"daily_points": 10.1,
"minute_points": 200
},
"export_list": [
"176.31.112.10",
"31.220.43.99",
"40.76.58.209",
"62.113.232.196",
"95.215.47.207"
]
}
STEP 2 | Host the export list as a text file on an external web server. To ensure that you have the
latest list of arfacts, frequently refresh the hosted list.
PAN-OS® and Panorama™API Usage Guide Version Version 50 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
STEP 3 | Add the URL for the export list to an external dynamic list. In this example the external
dynamic list uses IP addresses:
STEP 4 | Add the external dynamic list as match criteria in a security policy rule. In this example, the
rule denies access to IP addresses on the external dynamic list for all users on your network:
You must commit only once when you add the reference to the EDL in a policy rule. Any
changes to the external dynamic list do not require a commit.
PAN-OS® and Panorama™API Usage Guide Version Version 51 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
If you perform this step, you can skip Step 2, Create a SAML Identy Provider (IdP) server
profile.
PAN-OS® and Panorama™API Usage Guide Version Version 52 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
PAN-OS® and Panorama™API Usage Guide Version Version 53 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
STEP 3 | Create a SAML authencaon profile using the PAN-OS XML API
Include SAML authencaon profile parameters in your GET request:
• key: API key
• authencaon-profile: authencaon profile name
• enable-single-logout: specify whether you want to enable SAML single logout. The default
value is no.
• request-signing-cerficate: request signing cerficate name
• server-profile: SAML Identy Provider (IdP) server profile name
• cerficate-profile: cerficate profile name
• aribute-name-username: SAML username aribute
• aribute-name-usergroup: SAML user group aribute
• aribute-name-access-domain: SAML admin domain aribute
• aribute-name-admin-role: SAML admin role aribute
STEP 4 | Add users and user groups that are allowed to authencate with this authencaon profile
Include profile name and member list in your request:
• key: API key
• authencaon-profile: authencaon profile name
• member: users or user groups. To include specific users or groups, include them in brackets:
[member1,member 3]. To include all users, includeall.
PAN-OS® and Panorama™API Usage Guide Version Version 54 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
STEP 5 | Assign the authencaon profile to firewall services that require authencaon
For example, to assign the authencaon profile to a superuser administrator account for web
access, include these parameters in your GET request:
• key: API key
• name: admin username
• authencaon-profile: name of the SAML authencaon profile
PAN-OS® and Panorama™API Usage Guide Version Version 55 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
https://<firewall>/api/?
key=apikey&type=op&cmd=<set><quarantine><data></data></quarantine></
set>
The <data></data> content idenfies the device(s) to be quaranned and the following table lists
the tags in the content. All tags listed in the table are required.
PAN-OS® and Panorama™API Usage Guide Version Version 56 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
The following is an example of <data></data> content to add one device to the quaranne list.
<iot-message><version>1.0</version><type>update</type><vsys>vsys1</
vsys><payload><quarantine-add><entry
hostid="host3"><serialno>serial1</serialno><reason>admin1</
reason><source>litest1</source><quarantine-ts>1234</quarantine-ts></
entry></quarantine-add></payload></iot-message>
The following is an example of the <data></data> content to add more than one device to the
quaranne list.
<iot-message><version>1.0</version><type>update</
type><vsys>vsys1</vsys><payload><quarantine-add><entry
hostid="host9"><serialno>123uabcd2</serialno><reason>Magnifier</
reason><source>Magnifier</source><quarantine-ts>7890</quarantine-
ts>&</entry><entry hostid="host8"><serialno>309ufwi88</
serialno><reason>Cortex</reason><source>Cortex</source><quarantine-
ts>4567</quarantine-ts></entry></quarantine-add></payload></iot-
message
PAN-OS® and Panorama™API Usage Guide Version Version 57 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
hostid="host3"><serialno>serial1</serialno><reason>admin1</
reason><source>test1</source><quarantine-ts>1234</quarantine-
ts></entry></quarantine-add></payload></iot-message>'
The output from this command includes the following. The <data></data> content is the
HTML encoded version of your original data content.
<iot-message><version>1.0</
version><type>update</
type><vsys>vsys1</
vsys><payload><quarantine-add><entry
hostid="host3"><serialno>serial1</
serialno><reason>admin1</
reason><source>test1</source><quarantine-
ts>1234</quarantine-ts></entry></quarantine-
add></payload></iot-message>
The URL encoded content for the data content shown above is as follows.
%26lt%3Biot-message%26gt%3B%26lt%3Bversion%26gt%3B1.0%26lt%3B
%2Fversion%26gt%3B%26lt%3Btype%26gt%3Bupdate%26lt%3B%2Ftype
%26gt%3B%26lt%3Bvsys%26gt%3Bvsys1%26lt%3B%2Fvsys%26gt%3B%26lt
%3Bpayload%26gt%3B%26lt%3Bquarantine-add%26gt%3B%26lt%3Bentry
%20hostid%3D%26quot%3Bhost3%26quot%3B%26gt%3B%26gt%3B%26lt
%3Bserialno%26gt%3Bserial1%26lt%3B%2Fserialno%26gt%3B%26lt
%3Breason%26gt%3Badmin1%26lt%3B%2Freason%26gt%3B%26lt%3Bsource
%26gt%3Btest1%26lt%3B%2Fsource%26gt%3B%26lt%3Bquarantine-ts
%26gt%3B1234%26lt%3B%2Fquarantine-ts%26gt%3B%26lt%3B%2Fentry
%26gt%3B%26lt%3B%2Fquarantine-add%26gt%3B%26lt%3B%2Fpayload
%26gt%3B%26lt%3B%2Fiot-message%26gt%3B
PAN-OS® and Panorama™API Usage Guide Version Version 58 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
STEP 2 | Make a request to add your device to the quaranne list on the firewall.
The following example shows a cURL request to add a single compromised device to the
quaranne list.
<response status="success"><result><iot-response>
<version>2.0</version>
<payload>
<quarantine-add>
</quarantine-add>
</payload>
</iot-response>
</result></response>
<response status="success">
<result>
<entry name="12345abcde">
<start>0</start>
<hostid>12345abcde</hostid>
PAN-OS® and Panorama™API Usage Guide Version Version 59 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
<reason>Admin</reason>
<source></source>
<vsys_id>1</vsys_id>
<serialno></serialno>
<user></user>
<timestamp>Tue Feb 4 15:48:32 2020</timestamp>
</entry>
<entry name="host3">
<start>0</start>
<hostid>host3</hostid>
<reason>admin1</reason>
<source>litest1</source>
<vsys_id>1</vsys_id>
<serialno>serial1</serialno>
<user></user>
<timestamp>Mon Apr 13 12:10:55 2020</timestamp>
</entry>
<total>2</total>
</result>
</response>
<response status="success">
<result>
<status>success</status>
<msg>Device is deleted from quarantine list</msg>
</result>
</response>
PAN-OS® and Panorama™API Usage Guide Version Version 60 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
<apikey>&type=op&cmd=<request><certificate><generate><algorithm><RSA><rsa-
nbits>512</rsa-nbits></RSA></algorithm><certificate-name>SSCert</
certificate-name><name>10.1.1.1</name><ca>yes</ca></generate></
certificate></request>"
STEP 2 | Send a request to set the cerficate you created above as a trusted root cerficate and a
forward trust cerficate.
The following requests use the configuraon command and the xpath of the cerficate you
generated to set the cerficate as a forward trust cerficate and as a trusted root cerficate.
PAN-OS® and Panorama™API Usage Guide Version Version 61 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
STEP 3 | Send a request to create a subordinate cerficate using the self-signed cerficate you
generated.
The following request creates a subordinate of the SSCert that you can use to get more
granular control in the chain of trust.
STEP 4 | Send a request to export cerficates locally so that you can install the cerficates on your
clients.
The following request downloads the self-signed cerficate as SSCert.pem.
Alternavely, to import both the cerficate and private key to your firewalls at the
same me, use the following command:
To import a cerficate to a specific template and device on Panorama, use the following
command:
PAN-OS® and Panorama™API Usage Guide Version Version 62 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
The following request renews the self-signed root cerficate that you generated.
PAN-OS® and Panorama™API Usage Guide Version Version 63 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Use Cases
PAN-OS® and Panorama™API Usage Guide Version Version 64 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
The following topics provide common request examples that you can use to beer
understand the PAN-OS XML API.
> PAN-OS XML API Request Types and > Export Files (API)
Acons > Import Files (API)
> Asynchronous and Synchronous > Retrieve Logs (API)
Requests to the PAN-OS XML API
> Apply User-ID Mapping and Populate
> Configuraon (API) Dynamic Groups (API)
> Commit Configuraon (API) > Get Version Info (API)
> Run Operaonal Mode Commands
(API)
> Get Reports (API)
65
PAN-OS XML API Request Types
Request Types
You can currently use the following request types:
Syntax Descripon
Configuraon Acons
In addion to the request type that you specify, use available acons to modify or read
configuraons usingtype=config:
• Acons for Modifying a Configuraon
• Acons for Reading a Configuraon
PAN-OS® and Panorama™API Usage Guide Version Version 66 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
PAN-OS® and Panorama™API Usage Guide Version Version 67 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
• Show acons can use relave XPath, while get acons require absolute XPath.
PAN-OS® and Panorama™API Usage Guide Version Version 68 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
https://<firewall>/api/?key=
apikey&type=report&action=get&job-id=jobid
• Retrieve logs:
https://<firewall>/api/?key=
apikey&type=log&action=get&job-id=jobid
https://<firewall>/api/?key=
apikey&type=export&category=tech-support&action=get&job-
id=jobid
• Commit:
https://<firewall>/api/?key=
apikey&type=commit&cmd=<commit></commit>
• Operaonal commands:
https://<firewall>/api/?key=
PAN-OS® and Panorama™API Usage Guide Version Version 69 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
apikey&type=op&cmd=<show><jobs><id>jobid</id></jobs></show>
PAN-OS® and Panorama™API Usage Guide Version Version 70 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
Configuraon (API)
The requests examples in these topics illustrate how you can use the PAN-OS XML API to
configure your firewall.
• Get Acve Configuraon
• Get Candidate Configuraon
• Set Configuraon
• Edit Configuraon
• Delete Configuraon
• Rename Configuraon
• Clone Configuraon
• Move Configuraon
• Override Configuraon
• Mul-Move or Mul-Clone Configuraon
• View Configuraon Node Values for XPath
STEP 2 | Confirm that the XML response for the query looks similar to the following (truncated):
<response status="success">
<result>
<security>
<rules><entry name="IT DNS Services"><profile-
setting><group><member>best-practice</member></
group></profile-setting><to><member>untrust</member></
to><from><member>trust</member></from><source><member>any</
member></source><destination><member>Data Center</
PAN-OS® and Panorama™API Usage Guide Version Version 71 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
member></destination><source-user><member>any</
member></source-user><category><member>any</
member></category><application><member>dns</member></
application><service><member>application-default</
member></service><hip-profiles><member>any</member></hip-
profiles><action>allow</action><tag><member>Best Practice</
member></tag><log-start>no</log-start><log-setting>default</log-
setting></entry>
...
</rules>
</security>
</result>
</response>
https://<firewall>//api/?type=op&command=<show><arp><entry
name='all'/></arp></show>
STEP 2 | Confirm that the XML response for the query looks like the following (truncated):
<response status="success">
<result>
<max>3000</max>
<total>16</total>
<timeout>1800</timeout>
<dp>dp0</dp>
<entries>
<entry>
<status>c</status>
<ip>10.47.0.1</ip>
<mac>00:1b:17:00:2f:13</mac>
<ttl>1743</ttl>
<interface>ethernet1/1</interface>
<port>ethernet1/1</port>
</entry>
<entry>
<status>c</status>
<ip>10.47.0.10</ip>
<mac>00:50:56:93:68:6f</mac>
<ttl>386</ttl>
<interface>ethernet1/1</interface>
<port>ethernet1/1</port>
</entry>
<!-- truncated -->
</result>
</response>
PAN-OS® and Panorama™API Usage Guide Version Version 72 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
PAN-OS® and Panorama™API Usage Guide Version Version 73 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
Set Configuraon
Useaction=set to add or create a new object at a specified locaon in the PAN-OS
configuraon. Use thexpath parameter to specify the locaon of the object in the configuraon.
For example, if you are adding a new rule to the security rulebase, the xpath-value would be:
/config/devices/entry[@name='localhost.localdomain']/vsys/
entry[@name='vsys1']/rulebase/security
Use theelement parameter to specify a value for the object you are adding or creang using
XML.
PAN-OS® and Panorama™API Usage Guide Version Version 74 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
/config/devices/entry/vsys/entry/rulebase/
security/rules/entry[@name='rule1']
<source><member>src</member></
source><destination><member>dst</member></
destination><service><member>service</
member></
service><application><member>application</
member></application><action>action</
action><source-user><member>src-user</
member></source-user><option><disable-
server-response-inspection>yes-or-no</
disable-server-response-inspection></
option><negate-source>yes-or-no</negate-
source><negate-destination>yes-or-
no</negate-destination><disabled>yes-
or-no</disabled><log-start>yes-or-
no</log-start><log-end>yes-or-no</
log-end><description>description</
description><from><member>src-zone</member></
from><to><member>dst-zone</member></to>
Add an addional member Include the 'list' node in the xpath using
to an address group or list themember[text()='name'] syntax and include the
members in the element parameter. For example, to add an
addional stac address object namedabc to an address group
namedtest, use:
Create a new IP address on Specify the interface and IP address in the request:
a specific interface
curl -X GET "https://<firewall>/api?
key=<apikey>&type=config&action=set&xpath=/
config/devices/
entry[@name='localhost.localdomain']/
network/interface/ethernet/
entry[@name='ethernet1/1']/layer3/
ip&element=<entry name='5.5.5.5/24'/>"
PAN-OS® and Panorama™API Usage Guide Version Version 75 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
Edit Configuraon
Useaction=edit to replace an exisng object hierarchy at a specified locaon in the
configuraon with a new value. Use the xpath parameter to specify the locaon of the object,
including the node to be replaced. Use the element parameter to specify a new value for the
object using its XML object hierarchy (as seen in the output ofaction=show).
STEP 1 | Replace the applicaon(s) currently used in a rule rule1 with a new applicaon:
where
xpath=/config/devices/entry/vsys/entry/rulebase/security/rules/
entry[@name='rule1']/application&element=<application><member>app-
name</member></application>
STEP 2 | Use the response from the config show API request to create the XML body for the element.
STEP 3 | Oponally replace all members in a node with a new set of members using the entry tag in
both the xpath and element parameters. For example, to replace all the address objects in the
address group named test with two new stac members namedabc andxyz, use:
PAN-OS® and Panorama™API Usage Guide Version Version 76 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
name='test'><member>abc</member><member>xyz</member></entry></
static>"
Delete Configuraon
Useaction=delete to delete an object at a specified locaon in the configuraon. Use
thexpath parameter to specify the locaon of the object to be deleted.
Delete a single member object in a group, use the object name in the xpath
asmember[text()='name']. For example, to delete a stac address object named abc in an
address group named test, use the following xpath:
Rename Configuraon
Useaction=rename to rename an object at a specified locaon in the configuraon. Use the
xpath parameter to specify the locaon of the object to be renamed. Use the newname parameter
to provide a new name for the object.
STEP 1 | Use the following API query to rename an address object calledold_address
tonew_address:
STEP 2 | Confirm that the XML response for the request looks like the following:
PAN-OS® and Panorama™API Usage Guide Version Version 77 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
Clone Configuraon
Useaction=clone to clone an exisng configuraon object. Use thexpath parameter to specify
the locaon of the object to be cloned. Use thefrom parameter to specify the source object, and
thenewname parameter to provide a name for the cloned object.
STEP 1 | Use the following API query to clone a security policy called rule1 to rule2:
STEP 2 | Confirm that the XML response for the request looks like the following:
1,2014/03/19 19:07:45,0009C100708,CONFIG,0,0,2014/03/19
19:07:45,10.66.18.1,,clone,admin,Web,Succeeded, config
devices entry vsys
vsys1 rulebase security rules,384,0x8000000000000000
Move Configuraon
Useaction=move to move the locaon of an exisng configuraon object. Use thexpath
parameter to specify the locaon of the object to be moved, thewhere parameter to specify type
of move, anddst parameter to specify the desnaon path.
• where=after&dst=xpath
• where=before&dst=xpath
• where=top
• where=bottom
STEP 1 | Use the following API query to move a security policy calledrule1 to come aerrule2:
PAN-OS® and Panorama™API Usage Guide Version Version 78 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
STEP 2 | Confirm that the XML response for the request looks like the following:
Override Configuraon
Useaction=override to override a seng that was pushed to a firewall from a template. Use
thexpath parameter to specify the locaon of the object to override.
STEP 1 | Override the SNMP Trap profile configuraon sengs that were pushed to the firewall using
a template:
STEP 2 | Confirm that the XML response for the request looks like the following:
PAN-OS® and Panorama™API Usage Guide Version Version 79 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
devicegroup/entry[@name='socal']/address"><member>addr1</
member><member>addr2</member></source></selected-list><all-
errors>no</all-errors>"
STEP 2 | Confirm that the XML response for the request looks like the following:
PAN-OS® and Panorama™API Usage Guide Version Version 80 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
You can validate or revert a candidate configuraon before comming it using Run
Operaonal Mode Commands (API).
• Commit
• Commit-All
Commit
Replace thebody element in thecmd parameter with the XML element for the corresponding
commit operaon.
Use the API Browser to find different opons available for use with force and paral
commits.
• Force Commit—
• Paral commit while excluding shared objects and device and network configuraon—
PAN-OS® and Panorama™API Usage Guide Version Version 81 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
STEP 2 | Confirm that the XML response indicates that there were no changes to commit or that the
changes are queued for commit:
• No pending changes to commit:
• Pending changes:
STEP 3 | Query the status of the job using the job ID:
STEP 4 | Confirm that the XML response details state the Configuraon was commied successfully:
<response status="success">
<result>
<job>
<tenq>2021/07/21 14:33:55</tenq>
<tdeq>14:33:55</tdeq>
<id>4</id>
<user>admin</user>
<type>Commit</type>
PAN-OS® and Panorama™API Usage Guide Version Version 82 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
<status>ACT</status>
<queued>NO</queued>
<stoppable>yes</stoppable>
<result>PEND</result>
<tfin></tfin>
<description></description>
<positionInQ>0</positionInQ>
<progress>55</progress>
<warnings>
<line>Aggregate-ethernet interface ae1 has no
member interfaces.</line>
</warnings>
<details></details>
</job>
</result>
</response>
Commit-All
To centrally manage firewalls from Panorama, use the commit-all API request type to push and
validate shared policy to the firewalls using device groups and configuraon to Log Collectors and
firewalls using templates or template stacks.
PAN-OS® and Panorama™API Usage Guide Version Version 83 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
Use the API Browser to find other opons available for granular commit operaons on Panorama.
In thecmd parameter, you must replace the XML element for the correspondingcommit-all
operaon.
PAN-OS® and Panorama™API Usage Guide Version Version 84 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
Use the API Browser to explore operaonal mode commands and a complete lisng of all the
opons available for thexml-body and their corresponding operaon.
PAN-OS® and Panorama™API Usage Guide Version Version 85 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
PAN-OS® and Panorama™API Usage Guide Version Version 86 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
Remove configuraon locks 1. Change the target template using the following command:
for a parcular template
curl -X GET "https://<firewall>/api/?
key=<apikey>&type=op&cmd=<set><system><setting><target
Template</name></template></target></
setting></system></set>
PAN-OS® and Panorama™API Usage Guide Version Version 87 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
• WildFire Cluster:
• WildFire Cluster:
PAN-OS® and Panorama™API Usage Guide Version Version 88 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
• WildFire Cluster:
PAN-OS® and Panorama™API Usage Guide Version Version 89 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
When you request a report, the API responds asynchronously with a job ID, which you can
use to retrieve the reports. Learn more about Asynchronous and Synchronous Requests
to the PAN-OS XML API.
• Dynamic Reports
• Predefined Reports
• Custom Reports
Dynamic Reports
You can use the API to view a number of dynamic reports, such astop-applications-
summary,top-blocked-url-summary, andtop-spyware-threats-summary. For dynamic
reports, provide either a specific period using theperiod or a me frame usingstarttime
andendtime opons (use a + instead of a space between the date and mestamp). Usetopn to
determine the number of rows.
PAN-OS® and Panorama™API Usage Guide Version Version 90 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
PAN-OS® and Panorama™API Usage Guide Version Version 91 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
Predefined Reports
Predefined reports always return data for the last 24-hour period. You can also get this list
by following the link for predefined reports, such astop-applications,top-attackers,
andbandwidth-trend on the API browser.
Custom Reports
For custom reports, the selecon criteria, such as me frame, group-by, and sort-by are part of the
report definion. The API returns any shared custom reports. Note that quotes are not required
around the report name and any spaces in the report name must be URL encoded to%20.
For custom reports created in a specific VSYS, you can retrieve them directly by specifying
thevsys parameters.
STEP 1 | Retrieve the report definion from the configuraon:
PAN-OS® and Panorama™API Usage Guide Version Version 92 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
The response includes the job ID you can use to view the results:
<response status="success">
<result>
<msg>
<line>Report job enqueued with jobid 6</line>
</msg>
<job>6</job>
</result>
</response>
PAN-OS® and Panorama™API Usage Guide Version Version 93 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
curl -o
<filename> "https://<firewall>/api/??key=apikey&<query-
parameters>"
When using the API query from a web browser, you can specifyto=filename as an oponal
parameter if you would like to provide a different name when saving the file locally.
• Export Packet Captures
• Export Cerficates and Keys
• Export Technical Support Data
PAN-OS® and Panorama™API Usage Guide Version Version 94 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
The file will be retrieved and saved locally using the name
yyyymmdd-filename.
PAN-OS® and Panorama™API Usage Guide Version Version 95 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
https://<firewall>/api/?
key=apikey&type=export&category=<certificate>
&certificate-name=<certificate_name>
&passphrase=<passphrase>
&format=<pkcs12><pem><pkcs10>
&include-key=<yes><no>&vsys=<vsys>
<omit this parameter to import it into a shared location>
PAN-OS® and Panorama™API Usage Guide Version Version 96 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJAJC1HiIAZAiIMA0GCSqGSIb3Df
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVx
aWRnaXRzIFB0eSBMdGQwHhcNMTExMjMxMDg1OTQ0WhcNMT
<!-- TRUNCATED -->
-----END CERTIFICATE-----
Content-Type: application/octet-stream
PAN-OS® and Panorama™API Usage Guide Version Version 97 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
Content-Length: 19658186
Content-Transfer-Encoding: binary
<response status="success">
<result>
<job>
<tenq>2012/06/14 10:11:09</tenq>
<id>2</id>
<user/>
<type>Exec</type>
<status>FIN</status>
<stoppable>no</stoppable>
<result>0K</result>
<tfin>10:12:39</tfin>
<progress>10:12:39</progress>
<details/>
<warnings/>
<resultfile>//tmp/techsupport.tgz</resultfile>
</job>
</result>
</response>
PAN-OS® and Panorama™API Usage Guide Version Version 98 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
When using cURL, you can specify the output file name as an opon to cURL (-o). Aer a
successful retrieval of the job data, the job is automacally deleted by the system.
<response status"success">
<msg>Job 2 removed.</msg>
</response>
PAN-OS® and Panorama™API Usage Guide Version Version 99 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
Imporng Basics
Use cURL to import files to the firewall.
Import files to a firewall via Panorama. First import the file to Panorama, then run a request
batch upload-install op command:
PAN-OS® and Panorama™API Usage Guide Version Version 100 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
Import Files
Use the API Browser to see a full list of import categories.
Import a cerficate or key by specifying the type of the cerficate or key file using
thecategory parameter:
• category=certificate
• category=keypair
• category=high-availability-key
Import a GlobalProtect response pages using an addional parameter for the security profile in
which the page should be imported:
profile=profilename
PAN-OS® and Panorama™API Usage Guide Version Version 101 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
Parameter Descripon
PAN-OS® and Panorama™API Usage Guide Version Version 102 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
Parameter Descripon
query ( Oponal) Specify the match criteria for the logs. This is similar to
the query provided in the web interface under the Monitor tab when
viewing the logs. The query must be URL encoded.
skip ( Oponal) Specify the number of logs to skip when doing a log
retrieval. The default is 0. This is useful when retrieving logs in batches
where you can skip the previously retrieved logs.
dir ( Oponal) Specify whether logs are shown oldest first (forward) or
newest first (backward). Default isbackward.
acon ( Oponal) Log data sizes can be large so the API uses an asynchronous
job scheduling approach to retrieve log data. The inial query returns
a Job ID (job-id) that you can then use for future queries with
theaction parameter:
• action=get—Check status of an acve job or retrieve the log
data when the status isFIN (finished). This is slightly different than
the asynchronous approach to retrieve tech support data where a
separate status acon is available.
• action=finish—Stop an acve job.
• Not specified—When not specified, such as during an inial query,
the system creates a new job to retrieve log data.
A web-browser will automacally URL encode the parameters, but when using cURL,
the query parameter must be URL encoded.
Response:
PAN-OS® and Panorama™API Usage Guide Version Version 103 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
STEP 2 | Retrieve traffic log data using the following request using the job ID as the value returned in
the previous response:
STEP 3 | Confirm that the XML response looks similar to the following:
<response status="success"">
<result>
<job>...</job>
<log>
<logs count="20" progress="100n>
<entry logid="5753304543500710425"> <domain>1</
domain> <receive_time>2012/06/13 15:43:17</receive_time>
<serial>001606000117</serial> <segno>6784588</segno>
<actionflags>0x0</actionflags> <type>TRAFFIC</
type> <subtype>start</subtype> <config_ver>1</config_ver>
<time_generated>2012/06/13 15:43:17</time_generated>
<src>172.16.1.2</src> <dst>10.1.0.246</dst>
<natsrc>10.16.0.96</natsrc> <natdst>10.1.0.246</natdst>
<rule>default allow</rule>
When the job status is FIN (finished), the response automacally includes all the logs in the
XML data response. The <log> node in XML is not present when the job status is sll pending.
Aer successful log data retrieval, the system automacally deletes the job.
STEP 4 | ( Oponal) Delete and acve log retrieval job.To delete an acve log retrieval job, run the
following query:
PAN-OS® and Panorama™API Usage Guide Version Version 104 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
or
With your User-ID API requests, you can use the following oponal parameters:
• vsys=vsys_id—Specify the vsys where you want to apply User-ID mapping.
• target=serialnumber—Specify the firewall by serial number when redirecng through
Panorama.
• Use a GET request if the URL query size is less than 2K and a POST request if the
request size is between 2K to 5MB. Limit the query size to 5MB.
• When mulple login or logout events are generated at the same me, make sure to
follow these guidelines to ensure opmal firewall performance:
• Design your applicaon to queue events and perform batch API updates instead of
sending single event or mapping updates.
• Limit the number of concurrent API calls to five. This limit ensures that there is no
performance impact to the firewall web interface as the management plane web
server handles requests from both the API and the web interface.
(Panorama managed firewalls only) You cannot view the IP addresses of a DAG registered
using XML API on the Panorama web interface.
You must log in to the Panorama CLI to view the registered IP addresses of a DAG
populated using XML API on Panorama:
Use the informaon in the following table to apply User-ID mapping informaon to a firewall:
PAN-OS® and Panorama™API Usage Guide Version Version 105 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
User-ID mapping for a Use this input file format when providing a User-ID mapping for
login, logout, or groups. a login event, logout event, or for groups:
<uid-message>
<version>1.0</version>
<type>update</type>
<payload>
<login>
<entry name="domain\uid1"
ip="10.1.1.1" timeout="20">
</entry>
</login>
<groups>
<entry name="group1">
<members>
<entry name="user1"/
>
<entry name="user2"/
>
</members>
</entry>
<entry name="group2">
<members>
<entry name="user3"/
>
</members>
</entry>
</groups>
</payload>
</uid-message>
Mul-User System Entry Use the following input file format to set up a terminal server
entry on the firewall and to specify the port range and block
size of ports that will be assigned per user. If you are using the
default port range (1025 to 65534) and block size (200) you do
not need to send amultiusersystem setup message; the
firewall will automacally create the terminal server object when
it receives the first login message.
<uid-message>
<payload>
<multiusersystem>
<entry ip="10.1.1.2"
startport="xxxxx" endport="xxxxx"
blocksize="xxx">
</multiusersystem>
PAN-OS® and Panorama™API Usage Guide Version Version 106 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
User-ID XML muluser When the terminal servers sends a login event payload to the
system login event firewall, it can contain mulple login events. The firewall uses the
informaon in the informaon in the login message to populate
its user mapping table. For example, if the firewall received a
packet with a source address and port of 10.1.1.23:20101, it
would map the request to user jparker for policy enforcement.
<uid-message>
<payload>
<login>
<entry name="acme\jparker"
ip="10.1.1.23" blockstart="20100">
</login>
</payload>
<type>update</type>
<version>1.0</version>
</uid-message>
User-ID XML muluser Upon receipt of a logout event message with ablockstart
system logout parameter, the firewall removes the corresponding IP address-
port-user mapping. If the logout message contains a username
and IP address, but noblockstart parameter, the firewall
removes all mappings for the user. If the logout message contains
an IP address only, the firewall removes the mul-user system
and all associated mappings.
<uid-message>
<payload>
<logout>
<entry user="domain\uid2"
ip="10.1.1.2" blockstart="xxxxx">
</logout>
</payload>
<type>update</type>
<version>1.0</version>
</uid-message>
Dynamic address group IP Use the following input file format to dynamically register and
address registraon unregister IP addresses.
You can configure a meout as part of the member element
to automacally unregister IP address-to-tag mapping aer a
specified amount of me. By default, no meout is specified
meaning the mapping will not meout and must be manually
PAN-OS® and Panorama™API Usage Guide Version Version 107 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
<uid-message>
<version>1.0</version>
<type>update</type>
<payload>
<register>
<entry ip="10.1.1.1">
<tag>
<member timeout="3600">CBB09C3D-3416-4734-
BE90-0395B7598DE3</member>
</tag>
</entry>
</register>
<unregister>
<entry ip="10.1.1.3"/>
<tag>
<member>CBB09C3D-3416-4734-
BE90-0395B7598DE5</member>
</tag>
</entry>
</unregister>
</payload>
</uid-message>
Register tags for a user to Use the following input file format to dynamically register tags to
add that user to a dynamic a user and include that user in a dynamic user group.
user group
To register a tag for a user, that user must have an
exisng user mapping or group mapping.
<uid-message>
<version>1.0</version>
<type>update</type>
<payload>
<register-user>
<entry user="paloaltonetworks\john">
<tag>
<member>finished_ethics_training</
member>
<member>mac_user</member>
</tag>
PAN-OS® and Panorama™API Usage Guide Version Version 108 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
Unregister specific tags Use the following input file format to unregister a specific
for a user to remove that dynamic tag from a user and remove the user from the dynamic
user from the dynamic user user group associated with that tag.
group
<uid-message>
<version>1.0</version>
<type>update</type>
<payload>
<unregister-user>
<entry user="paloaltonetworks\john">
<tag>
<member>mac_user</member>
</tag>
</entry>
</unregister-user>
</payload>
</uid-message>
Unregister all tags for a Use the following input file format to unregister all tags for a
user specific user.
<uid-message>
<version>1.0</version>
<type>update</type>
<payload>
<unregister-user>
<entry user="paloaltonetworks\john">
</entry>
</unregister-user>
</payload>
</uid-message>
Clear all tags for all users Use the following input file format to unregister all tags from all
users.
<uid-message>
<version>1.0</version>
<type>update</type>
PAN-OS® and Panorama™API Usage Guide Version Version 109 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
PAN-OS® and Panorama™API Usage Guide Version Version 110 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
STEP 2 | Confirm that the XML response contains the soware version, model, serial number, and
whether mul-vsys mode is on:
<response status="success">
<result>
<sw-version>7.1.0</sw-version>
<multi-vsys>off</multi-vsys>
<model>pa-vm</model>
<serial>007000001222</serial>
</result>
</response>
PAN-OS® and Panorama™API Usage Guide Version Version 111 ©2022 Palo Alto Networks, Inc.
10.1
PAN-OS XML API Request Types
PAN-OS® and Panorama™API Usage Guide Version Version 112 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
To use the PAN-OS® and Panorama™ REST API, first use your administrave
credenals to get an API key. You can then use the API key to make API requests.
> PAN-OS REST API > Create a Tag (REST API)
> Access the PAN-OS REST API > Configure a Security Zone (REST API)
> Resource Methods and Query > Configure a Virtual SD-WAN
Parameters (REST API) Interface (REST API)
> PAN-OS REST API Request and > Create an SD-WAN Policy Pre Rule
Response Structure (REST API)
> PAN-OS REST API Error Codes > Configure an Ethernet Interface
> Work With Objects (REST API) (REST API)
> Create a Security Policy Rule (REST > Update a Virtual Router (REST API)
API) > Work With Decrypon (APIs)
> Work with Policy Rules on Panorama
(REST API)
The PAN-OS REST API covers a subset of the firewall and Panorama funcons, and
you’ll need to use the XML API to complete the configuraon and commit your
changes.
The API requests in this guide use cURL commands. However, you can make API
requests with other tools such as Postman or a RESTClient. By default, PAN-OS uses
a self-signed cerficate, so you will need to use the -k parameter with cURL requests.
Alternavely, you can replace the self-signed cerficate with one from a trusted
cerficate authority. If you have an internal cerficate authority, generate your own
cerficate and install it on the firewall.
113
Get Started with the PAN-OS REST API
PAN-OS® and Panorama™API Usage Guide Version Version 114 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
The following table lists the PAN-OS 10.1 REST API resource URIs that are available on
the firewall. The resource URIs on Panorama are analogous except that resources support
both pre rule and post rule policies. The PAN-OS 10.1 REST API resources offer abilies
like managing policies on the firewall or configuring SD-WAN interfaces and policies on
Panorama. To complete the configuraon, you’ll need to use the XML API on the firewall
and Panorama.
Resource URI
OBJECTS /restapi/v10.1/Objects/Addresses
/restapi/v10.1/Objects/AddressGroups
/restapi/v10.1/Objects/Regions
/restapi/v10.1/Objects/Applicaons
/restapi/v10.1/Objects/ApplicaonGroups
/restapi/v10.1/Objects/ApplicaonFilters
/restapi/v10.1/Objects/Services
/restapi/v10.1/Objects/ServiceGroups
/restapi/v10.1/Objects/Tags
/restapi/v10.1/Objects/
GlobalProtectHIPObjects
PAN-OS® and Panorama™API Usage Guide Version Version 115 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
Resource URI
/restapi/v10.1/Objects/
GlobalProtectHIPProfiles
/restapi/v10.1/Objects/ExternalDynamicLists
/restapi/v10.1/Objects/CustomDataPaerns
/restapi/v10.1/Objects/
CustomSpywareSignatures
/restapi/v10.1/Objects/
CustomVulnerabilitySignatures
/restapi/v10.1/Objects/
CustomURLCategories
/restapi/v10.1/Objects/
AnvirusSecurityProfiles
/restapi/v10.1/Objects/
AnSpywareSecurityProfiles
/restapi/v10.1/Objects/
VulnerabilityProteconSecurityProfiles
/restapi/v10.1/Objects/
URLFilteringSecurityProfiles
/restapi/v10.1/Objects/
FileBlockingSecurityProfiles
/restapi/v10.1/Objects/
WildFireAnalysisSecurityProfiles
/restapi/v10.1/Objects/
DataFilteringSecurityProfiles
/restapi/v10.1/Objects/
DoSProteconSecurityProfiles
/restapi/v10.1/Objects/SecurityProfileGroups
/restapi/v10.1/Objects/
LogForwardingProfiles
/restapi/v10.1/Objects/
AuthencaonEnforcements
PAN-OS® and Panorama™API Usage Guide Version Version 116 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
Resource URI
/restapi/v10.1/Objects/DecryponProfiles
/restapi/v10.1/Objects/
DecryponForwardingProfiles
/restapi/v10.1/Objects/Schedules
/restapi/v10.1/Objects/
SDWANPathQualityProfiles
/restapi/v10.1/Objects/
SDWANTrafficDistribuonProfiles
POLICIES /restapi/v10.1/Policies/SecurityRules
/restapi/v10.1/Policies/NATRules
/restapi/v10.1/Policies/QoSRules
/restapi/v10.1/Policies/
PolicyBasedForwardingRules
/restapi/v10.1/Policies/DecryponRules
/restapi/v10.1/Policies/
TunnelInspeconRules
/restapi/v10.1/Policies/
ApplicaonOverrideRules
/restapi/v10.1/Policies/AuthencaonRules
/restapi/v10.1/Policies/DoSRules
/restapi/v10.1/Policies/SDWANRules
NETWORK /restapi/v10.1/Network/EthernetInterfaces
/restapi/v10.1/Network/
AggregateEthernetInterfaces
/restapi/v10.1/Network/VLANInterfaces
/restapi/v10.1/Network/LoopbackInterfaces
/restapi/v10.1/Network/TunnelIntefaces
PAN-OS® and Panorama™API Usage Guide Version Version 117 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
Resource URI
/restapi/v10.1/Network/SDWANInterfaces
/restapi/v10.1/Network/Zones
/restapi/v10.1/Network/VLANs
/restapi/v10.1/Network/VirtualWires
/restapi/v10.1/Network/VirtualRouters
/restapi/v10.1/Network/IPSecTunnels
/restapi/v10.1/Network/GRETunnels
/restapi/v10.1/Network/DHCPServers
/restapi/v10.1/Network/DHCPRelays
/restapi/v10.1/Network/DNSProxies
/restapi/v10.1/Network/GlobalProtectPortals
/restapi/v10.1/Network/
GlobalProtectGateways
/restapi/v10.1/Network/
GlobalProtectGatewayAgentTunnels
/restapi/v10.1/Network/
GlobalProtectGatewaySatelliteTunnels
/restapi/v10.1/Network/
GlobalProtectGatewayMDMServers
/restapi/v10.1/Network/
GlobalProtectClientlessApps
/restapi/v10.1/Network/
GlobalProtectClientlessAppGroups
/restapi/v10.1/Network/QoSInterfaces
/restapi/v10.1/Network/LLDP
/restapi/v10.1/Network/
GlobalProtectIPSecCryptoNetworkProfiles
PAN-OS® and Panorama™API Usage Guide Version Version 118 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
Resource URI
/restapi/v10.1/Network/
IKEGatewayNetworkProfiles
/restapi/v10.1/Network/
IKECryptoNetworkProfiles
/restapi/v10.1/Network/
MonitorNetworkProfiles
/restapi/v10.1/Network/
InterfaceManagementNetworkProfiles
/restapi/v10.1/Network/
ZoneProteconNetworkProfiles
/restapi/v10.1/Network/QoSNetworkProfiles
/restapi/v10.1/Network/
LLDPNetworkProfiles
/restapi/v10.1/Network/
SDWANInterfaceProfiles
Devices /restapi/v10.1/Device/VirtualSystems
PAN-OS® and Panorama™API Usage Guide Version Version 119 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
predefined
shared shared shared shared shared
for for for for
, ,
Objects Objects Objects Objects
shared vsys
for only only only only
valid
Objects , , , , values on
Panorama:
only vsys vsys vsys vsys
shared
, valid valid valid valid
values on values on values on values on or
vsys Panorama: Panorama: Panorama: Panorama:
device-
, or shared shared shared shared group
panorama-
or or or or
pushed
device- device- device- device-
group group group group
PAN-OS® and Panorama™API Usage Guide Version Version 120 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
or
panorama-
pushed
newname — — — — required —
where — — — — — required,
valid
values:
top
bottom
before
after
PAN-OS® and Panorama™API Usage Guide Version Version 121 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
dst — — — — — required,
when
where
is
before
or
after
The following table shows examples of request formats with query parameters.
PAN-OS® and Panorama™API Usage Guide Version Version 122 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
In PAN-OS 10.1, aer you configure the firewalls and Panorama using the REST API, you
must use the XML API or the other management interfaces to commit your changes to the
running configuraon.
Request Format
The API request format is constructed as shown in the example below:
• Base path and the resource URI for the endpoint. See Access the PAN-OS REST API for details.
• Query parameters. Every request includes query parameters that are passed to the API
endpoint using query strings. The query parameters are appended to the URL with a ? that
indicates the start of the query string. The query parameters appear aer the ?, the parameter
are concatenated with other parameters using the ampersand & symbol.
PAN-OS® and Panorama™API Usage Guide Version Version 123 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
• Request body. When you create a resource with a POST request or edit a resource with a
PUT request, you include a JSON or XML formaed request body in which you specify the
properes for the resource you want to create or modify on the endpoint.
When you make an API request to the firewall or Panorama, the API key is required to
authencate the user who is making the request. You can enter the key with the custom
HTTP headerX-PAN-KEY: <key>. Learn about API Authencaon and Security and
how to Get Your API Key.
{
"@code": "19",
"@status": "success",
"result": {
"@count": "3",
"@total-count": "3",
"entry": [
{
"@location": "vsys",
"@name": "fqdn1",
"@vsys": "vsys1",
"fqdn": "www.test.com"
},
{
"@location": "vsys",
"@name": "Peer1",
"@vsys": "vsys1",
"ip-netmask": "172.0.0.1/24"
},
{
"@location": "vsys",
PAN-OS® and Panorama™API Usage Guide Version Version 124 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
"@name": "Peer2renamed",
"@oldname": "Peer2",
"@vsys": "vsys1",
"ip-netmask": "200.0.0.1/24"
}
]
}
}
{
"code": 3,
"details": [
{
"@type": "CauseInfo",
"causes": [
{
"code": 7,
"description": "Missing Query Parameter: name",
"module": "panui_restapi"
}
]
}
],
"message": "Missing Query Parameter: name"
}
Field Descripon
code Feature-specific error code. The codes are listed in PAN-OS REST
API Error Codes
PAN-OS® and Panorama™API Usage Guide Version Version 125 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
Field Descripon
The details under CauseInfo are for readability
and debugging purposes. The value can change
between soware releases. To avoid your scripts
breaking between releases, don’t parse the values in
details.causes.
PAN-OS® and Panorama™API Usage Guide Version Version 126 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
Error Descripon
Code
6 Conflict. The enty that the caller aempted to create already exists.
7 Forbidden. The caller does not have permission to execute the specified operaon.
16 Unauthorized. The request does not have valid authencaon credenals to perform
the operaon.
9 Failed precondion. The operaon was rejected because the system is not in a state
required for the execuon of the operaon.
11 Out of range. The operaon was aempted past a valid range. And example is
reaching an end-of-file.
13 Internal server error. An unexpected and potenally serious internal error occurred.
PAN-OS® and Panorama™API Usage Guide Version Version 127 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
curl -X POST \
'https://10.1.1.4/restapi/v10.1/Objects/Addresses?
location=shared&name=web-servers-production' \
-H 'X-PAN-KEY: LUFRPT0=' \
-d '{
"entry": [
{
"@location": "shared",
"@name": "web-servers-production",
"description": "what is this for?",
"fqdn": "docs.paloaltonetworks.com",
"tag": {
"member": [
"blue"
]
}
}
]
}'
PAN-OS® and Panorama™API Usage Guide Version Version 128 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
called red to the address object. If the tag does not already exist, you must first create the tag
before you can reference it in the address object.
curl -X PUT \
'https://10.1.1.4/restapi/v10.1/Objects/Addresses?
location=shared&name=web-servers-production' \
-H 'X-PAN-KEY: LUFRPT0=' \
-d '{
"entry": [
{
"@location": "shared",
"@name": "web-servers-production",
"description": "publish servers",
"fqdn": "docs.paloaltonetworks.com",
"tag": {
"member": [
"blue",
"red"
]
}
}
]
}'
The response is
{
"@code": "20",
"@status": "success",
"msg": "command succeeded"
}
curl -X POST \
'https://10.5.196.4/restapi/v10.1/Objects/Addresses:rename?
location=shared&name=web-servers-production&newname=web-server-
publish' \
-H 'X-PAN-KEY: LUFRPT0='
curl -X DELETE \
PAN-OS® and Panorama™API Usage Guide Version Version 129 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
'https://10.1.1.4/restapi/v10.1/Objects/Addresses?
location=shared&name=web-server-production' \
-H 'X-PAN-KEY: LUFRPT0='
curl -X GET \
'https://10.1.1.4/restapi/v10.1/Objects/Addresses?
location=vsys&vsys=vsys1' \
-H 'X-PAN-KEY: LUFRPT0='
And the response includes the list of address objects that are configured on vsys1 on the firewall.
{
"@code": "19",
"@status": "success",
"result": {
"@count": "3",
"@total-count": "3",
"entry": [
{
"@location": "vsys",
"@name": "fqdn1",
"@vsys": "vsys1",
"fqdn": "www.test.com"
},
{
"@location": "vsys",
"@name": "Peer1",
"@vsys": "vsys1",
"ip-netmask": "172.0.0.1/24"
},
{
"@location": "vsys",
"@name": "Peer2renamed",
"@oldname": "Peer2",
"@vsys": "vsys1",
"ip-netmask": "200.0.0.1/24"
}
]
}
}
PAN-OS® and Panorama™API Usage Guide Version Version 130 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
curl -X POST \
'https://10.1.1.4/restapi/v10.1/Objects/Applications?
location=shared&name=email-collaboration-apps' \
-H 'X-PAN-KEY: LUFRPT=' \
-d '{
"entry": [
{
"@location": "shared",
"@name": "email-collaboration-apps",
"able-to-transfer-file": "yes",
"category": "collaboration",
"description": "apps we allow for collaboration",
"risk": "2",
"subcategory": "email",
"technology": "browser-based"
}
]
}'
You can now use this applicaon object in a Security policy rule.
PAN-OS® and Panorama™API Usage Guide Version Version 131 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
Access the PAN-OS REST API. The query parameters include the name of the rule, locaon and
vsys namelocation=vsys&vsys=<vsys_name>&name=<rule_name>. And in the request
body specify the same name, locaon, vsys name, and includes addional properes for the
Security policy rule including the applicaon object you created earlier.
curl -X POST \
'https://10.1.1.4/restapi/v10.1/Policies/SecurityRules?
location=vsys&vsys=vsys1&name=rule-example1' \
-H 'X-PAN-KEY: LUFRPT=' \
-d '{
"entry": [
{
"@location": "vsys",
"@name": "rule-example1",
"@vsys": "vsys1",
"action": "allow",
"application": {
"member": [
"email-collaboration-apps"
]
},
"category": {
"member": [
"any"
]
},
"destination": {
"member": [
"any"
]
},
"from": {
"member": [
"zone-edge1"
]
},
"hip-profiles": {
"member": [
"any"
]
},
"service": {
"member": [
"application-default"
]
},
"source": {
"member": [
"any"
]
},
"source-user": {
"member": [
"any"
]
PAN-OS® and Panorama™API Usage Guide Version Version 132 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
},
"to": {
"member": [
"any"
]
}
}
]
}'
Instead of using an applicaon object, you can list applicaons by name as long as the
applicaons are included in the applicaon content version installed on the firewall.
"application": {
"member": [
"gmail",
"linkedin",
"sendgrid",
"front"
]
}
curl -X PUT \
'https://10.1.1.4/restapi/v10.1/Policies/SecurityRules?
location=vsys&name=rule-example1&vsys=vsys1' \
-H 'X-PAN-KEY: LUFRPT=' \
-d '{
"entry": [
{
"@location": "vsys",
"@name": "rule-example1",
"@vsys": "vsys1",
"action": "allow",
"application": {
"member": [
"email-collaboration-apps"
]
},
"category": {
"member": [
"any"
]
},
"destination": {
"member": [
"any"
]
},
"from": {
PAN-OS® and Panorama™API Usage Guide Version Version 133 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
"member": [
"zone-edge1"
]
},
"hip-profiles": {
"member": [
"any"
]
},
"service": {
"member": [
"application-default"
]
},
"source": {
"member": [
"web-servers-production"
]
},
"source-user": {
"member": [
"any"
]
},
"to": {
"member": [
"any"
]
}
}
]
}'
PAN-OS® and Panorama™API Usage Guide Version Version 134 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
curl -X POST \
'http://10.5.1.70/restapi/v10.1/Objects/LogForwardingProfiles?
name=log-forwarding-LS&location=device-group&device-
group=devicegroup-7' \
-H 'X-PAN-KEY: LUFRPT1=' \
-d ' {
"entry": {
"@name": "log-forwarding-LS",
"match-list": {
"entry": [
{
"@name": "only_traffic_logs",
"filter": "All Logs",
"log-type": "traffic",
"send-to-panorama": "yes"
},
{
"@name": "only_threat_logs",
"filter": "All Logs",
"log-type": "threat",
"send-to-panorama": "yes"
PAN-OS® and Panorama™API Usage Guide Version Version 135 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
}
]
}
}
}'
You can now use this log forwarding object in a Security policy rule.
Use a GET request to fetch the configuraon of the Security policy pre rule you want to
modify and copy the response. You can then use this as a starng point for the request
body in your PUT request and modify as needed to edit the rule.
curl -X PUT \
'http://10.1.1.7/restapi/v10.1/Policies/SecurityPreRules?
LOCATION=device-group&device-group=devicegroup-7&name=allow-dns' \
-H 'X-PAN-KEY: LUFRPT=' \
-d '{
"entry": [
{
"@device-group": "devicegroup-7",
"@location": "device-group",
"@name": "allow-dns",
"action": "allow",
"application": {
"member": [
"dns"
]
},
"category": {
"member": [
"any"
]
},
"destination": {
"member": [
"any"
]
},
"from": {
"member": [
PAN-OS® and Panorama™API Usage Guide Version Version 136 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
"any"
]
},
"hip-profiles": {
"member": [
"any"
]
},
"log-setting": "log-forwarding-LS",
"log-start": "yes",
"service": {
"member": [
"application-default"
]
},
"source": {
"member": [
"any"
]
},
"source-user": {
"member": [
"any"
]
},
"target": {
"negate": "no"
},
"to": {
"member": [
"any"
]
}
}
]
}
The response body indicates the success or failure of the request. If you reference a Security
policy Pre Rule that does not exist because the name of the rule is invalid or the locaon is
incorrect, the response displays as
{
"code": 5,
"details": [
{
"@type": "CauseInfo",
"causes": [
{
"code": 7,
"description": "Object Not Present: No object to
edit.",
"module": "panui_mgmt"
}
]
PAN-OS® and Panorama™API Usage Guide Version Version 137 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
}
],
"message": "Object Not Present"
}
For help with the error codes, see PAN-OS REST API Error Codes.
PAN-OS® and Panorama™API Usage Guide Version Version 138 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
curl -X POST
'https://<Panorama>/restapi/v10.1/objects/tags?location=device-
group&device-group=SD-WAN_Branch&name=Low-Cost-Paths'
-H 'X-PAN-KEY: <your key>
-d '{"entry": {"@name": "Low-Cost-Paths”,
“Comments”: “Groups two low cost broadband links and a backup
link”
}
}'
PAN-OS® and Panorama™API Usage Guide Version Version 139 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
curl -X POST
'https://<Panorama>/restapi/v10.1/network/zones?
location=template&template=SDWAN-Branch-Network&name=Untrust'
-H 'X-PAN-KEY: <api key>'
-d '{
"entry": {
"@name": "Untrust",
"enable-user-identification": "no",
"network": {
"layer3": {
"member": [
"ethernet1/1",
"ethernet1/2",
"ethernet1/3",
"sdwan.1"
]
}
}
}
}'
PAN-OS® and Panorama™API Usage Guide Version Version 140 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
STEP 1 | Get the zone you to which you want to add the Ethernet interface.
The following example requests an exisng security zone.
The response is shown below. Note that this security zone already has on Ethernet interface,
ethernet1/4. You need to include that member in your request to update this zone to avoid
losing this data.
{
"@code": "19",
"@status": "success",
"result": {
"@count": "1",
"@total-count": "1",
"entry": [
{
"@location": "vsys",
"@name": "test",
"@vsys": "vsys1",
"network": {
"layer3": {
"member": [
"ethernet1/4"
]
}
}
}
]
}
}
STEP 2 | Add a new Ethernet interface and include any exisng data.
The following example updates the security zone with (1) a new Ethernet interface,
ethernet1/3 and (2) the member that already existed in the zone, ethernet1/4.
PAN-OS® and Panorama™API Usage Guide Version Version 141 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
"ethernet1/4",
"ethernet1/3"
]
}
}
}
}'
PAN-OS® and Panorama™API Usage Guide Version Version 142 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
curl -X POST
'https://<Panorama>/restapi/v9.1/network/
sdwanInterfaceprofiles?location=template&template=SDWAN-Branch-
Network&name=BroadBand-low-cost'
-H 'X-PAN-KEY: <api key>
-d '{
"entry": {
"@name": "BroadBand-low-cost",
"comment": "Low cost",
"failback-hold-time": 20,
"link-tag": "Broadband-ISP",
"link-type": "Cablemodem",
"maximum-download": 100,
"maximum-upload": 50,
"path-monitoring": "Aggressive",
"probe-frequency": 5,
"probe-idle-time": 60,
"vpn-data-tunnel-support": "yes"
}
}'
PAN-OS® and Panorama™API Usage Guide Version Version 143 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
profile, (b) import the Ethernet interface into a virtual system, and (c) update the Ethernet
interface to specify the SD-WAN interface profile.
1. Configure a Layer 3 Ethernet interface.
The following is an example of an API request to configure a Layer 3 Ethernet interface
that uses DHCP for IP address assignment.
curl -X POST
'https://<Panorama>/restapi/v9.1/network/
ethernetinterfaces?location=template&template=SDWAN-Branch-
Network&name=ethernet1/4'
-H 'X-PAN-KEY: <api key>
-d '{
"entry": {
"@name": "ethernet1/4",
"layer3": {
"dhcp-client": {
"create-default-route": "yes",
"default-route-metric": 10,
"enable": "yes",
"send-hostname": {
"enable": "no",
"hostname": "system-hostname"
}
},
"sdwan-link-settings": {
"enable": "no"
}
}
}
}'
curl -X POST
'https://<Panorama>/restapi/v9.1/device/
virtualsystems?location=template&template=SDWAN-Branch-
Network&name=vsys1'
-H 'X-PAN-KEY: <api key>
-d '{
"entry": [
{
"@location": "template",
"@name": "vsys1",
"@template": "Branch_template",
"import": {
"network": {
"interface": {
PAN-OS® and Panorama™API Usage Guide Version Version 144 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
"member": [
"ethernet1/4"
]
}
}
}
}
]
}'
curl -X PUT
'https://<Panorama>/restapi/v9.1/network/
ethernetinterfaces?location=template&template=SDWAN-Branch-
Network&name=ethernet1/4'
-H 'X-PAN-KEY: <api key>
-d '{
"entry": {
"@name": "ethernet1/4",
"layer3": {
"dhcp-client": {
"create-default-route": "yes",
"default-route-metric": 10,
"enable": "yes",
"send-hostname": {
"enable": "no",
"hostname": "system-hostname"
}
},
"sdwan-link-settings": {
"enable": "yes",
"sdwan-interface-profile": "BroadBand-test"
}
}
}
}'
curl -X POST
'https://<Panorama>/restapi/v9.1/network/
sdwanInterfaces?location=template&template=SDWAN-Branch-
Network&name=sdwan'
-H 'X-PAN-KEY: <api key>
PAN-OS® and Panorama™API Usage Guide Version Version 145 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
-d '{
"entry": {
"@name": "sdwan"
}
}'
curl -X POST
'https://<Panorama>/restapi/v9.1/network/
sdwanInterfaces?location=template&template=SDWAN-Branch-
Network&name=sdwan.1'
-H 'X-PAN-KEY: <api key>
-d '{
"entry": {
"@name": "sdwan.1",
"interface": {
"member": [
"ethernet1/3",
"ethernet1/4"
]
}
}
}'
PAN-OS® and Panorama™API Usage Guide Version Version 146 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
curl -X POST
'https://<Panorama>/restapi/v9.1/objects/
sdwanpathqualityprofiles?location=device-group&device-group=SD-
WAN_Branch&name=general-business2'
-H 'X-PAN-KEY: <api key>
-d '{
"entry": {
"@name": "general-business2",
"metric": {
"jitter": {
"sensitivity": "medium",
"threshold": 20
},
"latency": {
"sensitivity": "medium",
"threshold": 300
},
"pkt-loss": {
"sensitivity": "medium",
"threshold": 5
}
}
}
}'
PAN-OS® and Panorama™API Usage Guide Version Version 147 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
and Weighted Session Distribuon. The profile also includes one or more link tags, which the
distribuon method uses to narrow its selecon of a new path.
The POST request below creates a traffic distribuon profile that uses top-down priority and
includes two link tags:Broadband-ISP andLTE-ISP. See Create a Tag (REST API) for an
example of a REST API request to create a link tag.
curl -X POST
'https://<Panorama>/restapi/v9.1/objects/
sdwantrafficdistributionprofiles?location=device-group&device-
group=SD-WAN_Branch&name=BroadBand2'
-H 'X-PAN-KEY: <api key>
-d '{"entry": {"@name": "BroadBand2","traffic-distribution":
"Top Down Priority","link-tags": {"entry": [
{"@name": "Broadband-ISP"
},
{"@name": "LTE-ISP",
}
]
}
}
}'
curl -X POST
'https://<Panorama>/restapi/v9.1/policies/
sdwanprerules?location=device-group&device-group=SD-
WAN_Branch&name=HQ_Service_Test'
-H 'X-PAN-KEY: <api key>'
-d '{"entry": {"@name": "HQ_Service_Test","from": {"member":
["Trust-PA220”
]
},"to": {"member": ["Untrust-PA220"
]
},"source": {"member": ["any”
]
},"source-user": {"member": ["any"
]
},"destination": {"member": ["any"
PAN-OS® and Panorama™API Usage Guide Version Version 148 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
]
},"application": {"member": ["ping"
]
},"service": {"member": ["any"
]
},"negate-source": "no","negate-destination":
"no","disabled": "no","description": "For SD-WAN test","path-
quality-profile": "general-business","action": {"traffic-
distribution-profile": "BroadBand2"
}
}
}'
PAN-OS® and Panorama™API Usage Guide Version Version 149 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
PAN-OS® and Panorama™API Usage Guide Version Version 150 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
STEP 3 | Import the Ethernet interface into your virtual system (vsys).
The following example updates the import secon of the firewall virtual systemvsys1 with the
Ethernet interface you configured in step 2.
PAN-OS® and Panorama™API Usage Guide Version Version 151 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
STEP 5 | Add the Ethernet interface to an exisng virtual router, like the default virtual router.
The firewall requires a virtual router to obtain routes to other subnets through either
parcipang L3 roung protocols (dynamic routes) or stac routes. See Update a Virtual
Router (REST API) for an example of REST API requests to add an interface to a virtual router.
PAN-OS® and Panorama™API Usage Guide Version Version 152 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
A successful response returns a list of exisng virtual routers and includes detailed informaon
for each one. The response object for this request is large, so the example response below
shows a paral response object. You can see the list of exisng interfaces, which will be
necessary to include as request body parameters if you are updang the interface list in the
virtual router.
PAN-OS® and Panorama™API Usage Guide Version Version 153 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
--header 'X-PAN-Key:<api-key>
--data '{
"entry": {
"@name": "default",
"interface": {
"member": [
"ethernet1/3",
"ethernet1/4"
]
}
}
}'
PAN-OS® and Panorama™API Usage Guide Version Version 154 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
{
"@code": "20",
"@status": "success",
"msg": "command succeeded"
}
PAN-OS® and Panorama™API Usage Guide Version Version 155 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
forwarding interfaces to ensure that the clear text sessions that the firewall forwards for
addional analysis are completely separated from dataplane traffic.
{
"@code": "20",
"@status": "success",
"msg": "command succeeded"
}
PAN-OS® and Panorama™API Usage Guide Version Version 156 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
PAN-OS® and Panorama™API Usage Guide Version Version 157 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
"keyxchg-algo-ecdhe": "yes",
"keyxchg-algo-rsa": "yes",
"max-version": "tls1-2",
"min-version": "tls1-0"
}
}
}'
{
"@code": "20",
"@status": "success",
"msg": "command succeeded"
}
PAN-OS® and Panorama™API Usage Guide Version Version 158 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
{
"@code": "20",
"@status": "success",
"msg": "command succeeded"
}
STEP 5 | Create a decrypon policy using the decrypon profile and decrypon forwarding profile you
created before.
The following POST requests defines the traffic source zones and desnaons to enable
decrypon based on the testdecryptionprofile and testdecryptionforwading
profiles.
PAN-OS® and Panorama™API Usage Guide Version Version 159 ©2022 Palo Alto Networks, Inc.
10.1
Get Started with the PAN-OS REST API
]
},
"source": {
"member": [
"Test"
]
},
"source-hip": {
"member": [
"any"
]
},
"source-user": {
"member": [
"any"
]
},
"to": {
"member": [
"l2-trust"
]
},
"type": {
"ssl-forward-proxy": {}
}
}
}'
{
"@code": "20",
"@status": "success",
"msg": "command succeeded"
}
PAN-OS® and Panorama™API Usage Guide Version Version 160 ©2022 Palo Alto Networks, Inc.
10.1