PAN-OS REST API Request and Response Structure

The PAN-OS REST API enables you to perform CRUD operations with objects and use them in policy rules. A resource in the PAN-OS REST API is an endpoint that you can configure with parameters. When you make requests with the endpoints, you get responses that contain information. The request and response formats support JSON (default) and XML.
In PAN-OS 9.0, after 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 configuration.

Request Format

The API request format is constructed as shown in the example below:
https://
<IP address or FQDN of the firewall or Panorama>
/restapi/
<PAN-OS version>
/
<resource URI>
?<query parameters> &key=
<apikey>
request body
Code copied to clipboard
Unable to copy due to lack of browser support.
  • 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 after the 
    ?
    , the parameter are concatenated with other parameters using the ampersand 
    &
     symbol.
    Query Parameters on the firewall
    • name (name) of the resource.
    • location (vsys, predefined, shared, panorama-pushed) of the resource on which you want to perform the operation. A predefined object or rule is built-in to the firewall and you cannot edit, rename or delete predefined objects or policy rules.
    • virtual system (vsys) name for the resource, if location is vsys or panorama-pushed.
    • input format (input-format). JSON is default, or XML. You can specify an input format for HTTP methods that have a request body, such as PUT to update and POST to create a resource.
    • output format (output-format) JSON default, or XML
    Query Parameters on Panorama
    • name (name) of the resource.
    • location (predefined, shared, device-group, panorama-pushed) of the resource on which you want to perform the operation. A predefined object or rule is built-in to Panorama and you cannot edit, rename or delete predefined objects or policy rules.
    • device group (device-group) name of the Panorama device group to which you have assigned the firewalls, if location is device-group.
    • input format (input-format). JSON is default, or XML. You can specify an input format for HTTP methods that have a request body, such as PUT to update and POST to create a resource.
    • output format (output-format) JSON default, or XML
  • API key (
    key=
    ). When you make an API request to the firewall or Panorama, the API key is required to authenticate the user who is making the request. You can enter the key as a query parameter or add it as a custom header in the request. Learn about API Authentication and Security and how to Get Your API Key.
  • Request body. When you create a resource with a PUT request or edit a resource with a POST request, you include a JSON or XML formatted request body in which you specify the properties for the resource you want to create or modify on the endpoint.

Response Format

The HTTP Response has three elements: status, code, and result. The code is a numeric value. Refer to the PAN-OS XML API Error Codes for details on the error code included in the HTTP response message.
{ "@status": "success", "@code": "19", "result": { "@total-count": "3", "@count": "3", "entry": [ { "@name": "fqdn1", "@location": "vsys", "@vsys": "vsys1", "fqdn": "www.test.com" }, { "@name": "Peer1", "@location": "vsys", "@vsys": "vsys1", "ip-netmask": "172.0.0.1/24" }, { "@name": "Peer2renamed", "@oldname": "Peer2", "@location": "vsys", "@vsys": "vsys1", "ip-netmask": "200.0.0.1/24" } ] } }
Code copied to clipboard
Unable to copy due to lack of browser support.

Related Documentation