Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PAN-OS XML API Examples
For the below examples, your PAN-OS API key "api_key" is obtained by executing the follwing with your PAN-OS credentials:
curl -g -k -X GET 'https://hostname/api/?type=keygen&user=username&password=password'
Get Config
curl -g -k -X GET 'https://hostname/api/?type=config&action=show&key=api_key'
Install Auth Code/Licence
curl -g -k -X GET 'https://hostname/api/?type=op&cmd=<request><license><fetch><auth-code>I1234567</auth-code></fetch></license></request>&key=api_key'
Install API Key for Auth Code/Licence Deactivation
curl -g -k -X GET 'https://hostname/api/?type=op&cmd=<request><license><api-key><set><key>123abc123abc123abc</key></set></api-key></license></request>&key=api_key'
Remove Auth Code/Licence
curl -g -k -X GET 'https://hostname/api/?type=op&cmd=<request><license><deactivate><VM-Capacity><mode>auto</mode></VM-Capacity></deactivate></license></request>&key=api_key'
Add a Device Group to Panorama
curl -g -k -X GET 'https://hostname/api/?type=config&action=set&xpath=/config/devices/entry[@name='\''localhost.localdomain'\'']/device-group/entry[@name='\''dg-name'\'']&element=<devices/>&key=api_key'
Add a Template to Panorama
curl -g -k -X GET 'https://hostname/api/?type=config&action=set&xpath=/config/devices/entry[@name='\''localhost.localdomain'\'']/template/entry[@name='\''template-name'\'']&element=<config><devices/></config>&key=api_key'
Add a Template Stack to Panorama
curl -g -k -X GET 'https://hostname/api/?type=config&action=set&xpath=/config/devices/entry[@name='\''localhost.localdomain'\'']/template-stack/entry[@name='\''stack-name'\'']&element=<settings/>&key=api_key'
Add a Template to Template Stack in Panorama
curl -g -k -X GET 'https://hostname/api/?type=config&action=edit&xpath=/config/devices/entry[@name='\''localhost.localdomain'\'']/template-stack/entry[@name='\''stack-name'\'']/templates&element=<templates><member>template-name</member></templates>>&key=api_key'
Get a Tech-Support file
1. Request tech support, which will result in a Job ID
curl -g -k -X GET 'https://hostname/api/?type=export&category=tech-supportkey=api_key'
2. Check status of the request job
curl -g -k -X GET 'https://hostname/api/?type=export&category=tech-support&action=status&job-id=job_id&key=api_key'
3. When the job is finished, download the tech-support file
curl -g -k -X GET 'https://hostname/api/?type=export&category=tech-support&action=get&job-id=906&key=api_key'
@pan-jeffhochberg

This comment has been minimized.

Copy link

@pan-jeffhochberg pan-jeffhochberg commented Jan 30, 2020

Hi there! This is a great starting point! Have you ever looked into Postman (getpostman.com)? There are free and paid-for versions. You can create a "collection" in Postman and use that for testing API calls. I use it for testing/validation with the PAN-OS and Licensing APIs. I highly recommend it. You can always create a collection, then export it in JSON format, then share it here on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment