How to create a Static Host List through a REST API call to Clearpass


You might want to be able to create a Static Host List on CPPM through an API call rather than creating manually. 


This article shows us how we can create a Static Host List by making a REST API call to ClearPass. 


This article assumes that the initial configuration of ClearPass for making REST API calls is done. If that is not done please go through the document attached and do the initial configuration for making ClearPass allow REST API calls.

Once we are in a state where we are able to perform API calls to ClearPass we would have already been using "Bearer" access token. Using that access token we can make the API call.

The first thing we need to verify is the privilege level for the access token. You can make the following API call to get the privilege level


curl -X GET "https://<ClearPass IP/hostname>/api/oauth/privileges" \
     -H "Accept: application/json" \
     -H "Authorization:Bearer fead747cd31974052513e36ba7360d87717add12" \
     -m 30 \
     -v \

The output for the above call would list all the privileges available for that access token

  "privileges": [


To make an API call to create/modify/view a Static Host List we need to make sure that the cppm_static_host_list privilege is listed as one of the privilege. If that is not returned as a privilege then we need to understand that  the access token that we are using does not have the privilege level and we need to either create a new API client or modify the existing API client.

The API client we are using should have Super Administrator as the Operator Profile


If your Clearpass system is an upgraded system from earlier versions to Clearpass 6.6 or for some reason you are not seeing the Super Administrator as an Operator profile then you need to create a new Operator Profile called Super Administrator with the privileges as shown in the screenshot below

Once we have the right operator profile mapped to the API Client there are 2 options for Grant Type 

If you choose Client credentials as the Grant Type then you can directly use the Client Secret that would be shown immediately for generating the Access token.

However if you choose Username and password as the Grant Type then you need to use the client secret along with the appropriate username/password that assigns the Operator profile called Super Administrator. 

(Remember that this ties to OAuth2 API User Access Service on ClearPass and also the translation rules in ClearPass Guest. The steps on how to generate an access token are covered in detail in the document attached)


Once we make sure that the cppm_static_host_list is part of the privileges we can make the following API calls to create/modify/view Static Host Lists

Create a Static Host List

curl -X POST "https://<ClearPass IP/hostname>/api/static-host-list" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer fead747cd31974052513e36ba7360d87717add12" \
     --data '{
  "name": "REST-SHL",
  "description": "SHL created through REST API call",
  "host_format": "list",
  "host_type": "MACAddress",
  "value": "aa:bb:cc:dd:ee:ff,aa:bb:cc:dd:ee:11"
            -m 30 \
            -v \

If the creation is successful you would get HTTP 2xx status code. If it fails for some reason you might get a different HTTP status code.

You can include multiple MAC addresses separated by a comma as shown above and similarly you can also create a Static Host List of IP addresses. The model for the kind of data allowed is below

StaticHostList {

id (integer, optional): Numeric ID of the static host list,

name (string, optional): Name of the static host list,

description (string, optional): Description of the static host list,

host_format (string, optional) = ['subnet' or 'regex' or 'list']: Format of the static host list,

host_type (string, optional) = ['IPAddress' or 'MACAddress']: Host type of the static host list,

value (string, optional): List of static hosts in the selected format


To fetch the list of Static Host Lists


curl -X GET "" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer fead747cd31974052513e36ba7360d87717add12" \
            -m 30 \
            -v \


To delete a Static Host List


curl -X DELETE "https://<ClearPass IP/hostname>/api/static-host-list/3007" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer fead747cd31974052513e36ba7360d87717add12" \
            -m 30 \
            -v \

where 3007 is the id of the Static Host List. You can get the ID of the Static Host List by performing a GET on Static Host Lists.


Similarly you can also update an existing Static Host List using the PATCH method where 3006 is the id of the Static Host List

curl -X PATCH "" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer fead747cd31974052513e36ba7360d87717add12" \
     --data '{
  "value": "aa:bb:cc:dd:ee:ff,aa:bb:cc:dd:ee:11,aa:bb:cc:dd:ee:22"
            -m 30 \
            -v \

Please note that Delete and Update of Static Host lists can also be performed based on name not only based on id.




Verification for each operation can be done by examining the Status Code and response data for each API call


Create SHL Response for the Create done in the configuration above


  "id": 3007,
  "name": "REST-SHL",
  "description": "SHL created through REST API call",
  "host_format": "list",
  "host_type": "MACAddress",
  "value": "aa:bb:cc:dd:ee:ff,aa:bb:cc:dd:ee:11",
  "_links": {
    "self": {
      "href": "https://<ClearPass IP/HostName>/api/static-host-list/3007"


View SHL Response

  "_links": {
    "self": {
      "href": "https://<ClearPass IP/HostName>/api/static-host-list?calculate_count=false&offset=0&limit=25&sort=%2Bid&filter=%7B%7D"
    "first": {
      "href": "https://<ClearPass IP/HostName>/api/static-host-list?calculate_count=false&offset=0&limit=25&sort=%2Bid&filter=%7B%7D"
  "_embedded": {
    "items": [
        "id": 3007,
        "name": "REST-SHL",
        "description": "SHL created through REST API call",
        "host_format": "list",
        "host_type": "MACAddress",
        "value": "aa:bb:cc:dd:ee:ff,aa:bb:cc:dd:ee:11",
        "_links": {
          "self": {
            "href": "https://<ClearPass IP/HostName>/api/static-host-list/3007"


Delete SHL Response 

Response Body

no content

Response Code





Using the ClearPass HTTP APIs.pdf
Version history
Revision #:
2 of 2
Last update:
‎11-15-2016 10:31 AM
Updated by:
Labels (1)
Search Airheads
Showing results for 
Search instead for 
Did you mean: