Policy Import

/api/2.0/fo/compliance/policy/

[POST]

Use the parameter action=import to import compliance policies. Your account must have the Policy Compliance application enabled in order to import policies using this API.

Permissions - Manager

Input Parameters

Parameter

Description

action=import

(Required) Specifies the action type for importing the policy.

echo_request={0|1}

(Optional) Specify 1 to view (echo) input parameters in the XML output. By default these are not included.

xml_file

(Required) File containing the policy details.

title={value}

(Required) The title of the new policy.

create_user_controls={0|1}

(Optional) When not specified, user-defined controls are not created when you import a policy. Specify 1 to include UDCs from the XML file.

 

Sample - Import policy

API request

https://qualysapi.qualys.com/api/2.0/fo/compliance/policy/?action=import&title=My+Policy"

XML output

<!DOCTYPE SIMPLE_RETURN SYSTEM "https://qualysapi.qualys.com/api/2.0/simple_return.dtd">

 

<SIMPLE_RETURN>

   <RESPONSE>

      <DATETIME>2016-09-15T21:32:40Z</DATETIME>

      <TEXT>Successfully imported compliance policy</TEXT>

      <ITEM_LIST>

         <ITEM>

         <KEY>ID</KEY>

         <VALUE>136992</VALUE>

      </ITEM>

      <ITEM>

         <KEY>TITLE</KEY>

         <VALUE>My Policy</VALUE>

      </ITEM>

   </ITEM_LIST>

</RESPONSE>

</SIMPLE_RETURN>

Sample - Import policy with UDCs having remediation information using xml file

API request

curl -u "USERNAME:PASSWORD" -H "X-Requested-With: curl" -H Content-Type:text/xml --data-binary "@UDC_with_Remedy_20200422.xml" "https://qualysapi.qualys.com/api/2.0/fo/compliance/policy/?action=import&title=Policy1&create_user_controls=1"

XML output

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE SIMPLE_RETURN SYSTEM

"https://qualysapi.qualys.com/api/2.0/simple_return.dtd">

<SIMPLE_RETURN>

  <RESPONSE>

    <DATETIME>2020-04-22T22:51:16Z</DATETIME>

    <TEXT>Successfully imported compliance policy</TEXT>

    <ITEM_LIST>

      <ITEM>

        <KEY>ID</KEY>

        <VALUE>1867541</VALUE>

      </ITEM>

      <ITEM>

        <KEY>TITLE</KEY>

        <VALUE>Policy1</VALUE>

      </ITEM>

    </ITEM_LIST>

  </RESPONSE>

</SIMPLE_RETURN>

DTD

<platform API server>/api/2.0/simple_return.dtd