Create a new tag and possibly child tags.
Permissions required:
Managers with full scope, other users must have these permissions: Access Permission “API Access”, Tag Permission “Create User Tag”, Tag Permission “Modify Dynamic Tag Rules” (to create a dynamic tag)
Provider name is mandatory in case of Cloud Asset tag.
API request
curl -u "USERNAME:PASSWORD" -H "Content-type: text/xml" -X "POST" --data-binary @-"<qualys_base_url>/qps/rest/2.0/create/am/tag" < file.xml
Note: “file.xml” contains the request POST data.
Request POST data
<?xml version="1.0" encoding="UTF-8" ?>
<ServiceRequest>
<data>
<Tag>
<name>Parent Tag</name>
<ruleType>Groovy</ruleType>
<ruleText>if(asset.getAssetType()!=Asset.AssetType.HOST) return false;
return asset.hasVulnsWithSeverity(4,5)</ruleText>
<created>2014-02-06T19:14:50Z</created>
<modified>2014-02-06T19:14:50Z</modified>
<color>#FFFFFF</color>
<children>
<set>
<TagSimple>
<name>Child 1</name>
</TagSimple>
<TagSimple>
<name>Child 2</name>
</TagSimple>
<TagSimple>
<name>Child 3</name>
</TagSimple>
</set>
</children>
</Tag>
</data>
</ServiceRequest>
Response
<?xml version="1.0" encoding="UTF-8"?>
<ServiceResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="<qualys_base_url>/qps/xsd/2.0/am/tag.xsd">
<responseCode>SUCCESS</responseCode>
<count>1</count>
<data>
<Tag>
<id>1589217</id>
<name>Parent Tag</name>
<created>2014-02-06T19:14:50Z</created>
<modified>2014-02-06T19:14:50Z</modified>
<color>#FFFFFF</color>
<ruleText>if(asset.getAssetType()!=Asset.AssetType.HOST) return false;
return asset.hasVulnsWithSeverity(4,5)</ruleText>
<ruleType>GROOVY</ruleType>
<children>
<list>
<TagSimple>
<id>1</id>
<name>Child 1</name>
</TagSimple>
<TagSimple>
<id>2</id>
<name>Child 2</name>
</TagSimple>
<TagSimple>
<id>3</id>
<name>Child 3</name>
</TagSimple>
</list>
</children>
</Tag>
</data>
</ServiceResponse>
<responseCode>SUCCESS</responseCode>
API request
curl -n -u "USERNAME:PASSWORD" -H "content-type: text/xml"-X "POST" --
"<qualys_base_url>/rest/2.0/create/am/tag" < file.xml
Note: “file.xml” contains the request POST data.
Request POST data
<?xml version="1.0" encoding="UTF-8" ?>
<ServiceRequest>
<data>
<Tag>
<name>critical_3</name>
<criticalityScore>3</criticalityScore>
<color>#FFFFFF</color>
</Tag>
</data>
</ServiceRequest>
Response
<?xml version="1.0" encoding="UTF-8"?>
<ServiceResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="<qualys_base_url>/qps/rest/2.0/create/am/tag">
<responseCode>SUCCESS</responseCode>
<count>1</count>
<data>
<Tag>
<id>7824612</id>
<name>critical_3</name>
<created>2021-06-08T13:09:00Z</created>
<modified>2021-06-08T13:09:00Z</modified>
<color>#FFFFFF</color>
<criticalityScore>3</criticalityScore>
</Tag>
</data>
</ServiceResponse>
The <ruletype> implies with the Asset Inventory Rule in the Cloud Platform user interface.
API request
curl --location --request "POST"
--header 'Authorization: Basic cXVheXNfY2YyOlFhdGVtcEAxMjM='
--header 'Content-Type: application/xml'
--data-raw
"<qualys_base_url>/rest/2.0/create/am/tag" < file.xml
Note: “file.xml” contains the request POST data.
Request POST data
<?xml version="1.0" encoding="UTF-8" ?>
<ServiceRequest>
<data>
<Tag>
<name>Create_Tag_OperatingSystemLifecycleStageEOL1</name>
<ruleText>operatingSystem.lifecycle.stage:`EOL`</ruleText>
<ruleType>GLOBAL_ASSET_VIEW</ruleType>
</Tag>
</data>
</ServiceRequest>
Response
<?xml version="1.0" encoding="UTF-8"?>
<ServiceResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="<qualys_base_url>/qps/xsd/2.0/am/tag.xsd">
<responseCode>SUCCESS</responseCode>
<count>1</count>
<data>
<Tag>
<id>22450446</id>
<name>Create_Tag_OperatingSystemLifecycleStageEOL1</name>
<created>2022-12-15T05:13:57Z</created>
<modified>2022-12-15T05:13:57Z</modified>
<color>#FFFFFF</color>
<ruleText>operatingSystem.lifecycle.stage:`EOL`</ruleText>
<ruleType>GLOBAL_ASSET_VIEW</ruleType>
</Tag>
</data>
</ServiceResponse>
Prerequisite- Full or Trial CSAM subscription.
Permissions- Managers with full scope and other users will have the following permissions:-
- API Access
- Create User Tag
- Modify Dynamic Tag Rules
API request
curl -u "USERNAME:PASSWORD" -H "Content-type: text/xml" -X "POST" -- data-binary @- "<qualys_base_url>/qps/rest/2.0/create/am/tag/" < file.xml
Note: “file.xml” contains the request POST data.
Request POST data
<?xml version="1.0" encoding="UTF-8" ?>
<ServiceRequest>
<data>
<Tag>
<name>public-tagset-05 </name>
<ruleType>TAG_SET</ruleType>
<ruleText>
<![CDATA[
<?xml version="1.0" encoding="UTF-8" standalone="yes"?></ruleText><TAG_SET_TAG><INCLUDE_TAG><TAG_LIST><Tag><PARENT>18890412</PARENT><CHILD></CHILD></Tag><Tag><PARENT>18890012</PARENT><CHILD></CHILD></Tag></TAG_LIST><SCOPE>ANY</SCOPE></INCLUDE_TAG><EXCLUDE_TAG><TAG_LIST/><SCOPE>ANY</SCOPE></EXCLUDE_TAG></TAG_SET_TAG>]]>
</ruleText>
</Tag>
</data>
</ServiceRequest>
Response
<?xml version="1.0" encoding="UTF-8" ?>
<ServiceRequest>
<data>
<Tag>
<name>public-tagset-05 </name>
<ruleType>TAG_SET</ruleType>
<ruleText>
<![CDATA[
<?xml version="1.0" encoding="UTF-8" standalone="yes"?></ruleText><TAG_SET_TAG><INCLUDE_TAG><TAG_LIST><Tag><PARENT>18890412</PARENT><CHILD></CHILD></Tag><Tag><PARENT>18890012</PARENT><CHILD></CHILD></Tag></TAG_LIST><SCOPE>ANY</SCOPE></INCLUDE_TAG><EXCLUDE_TAG><TAG_LIST/><SCOPE>ANY</SCOPE></EXCLUDE_TAG></TAG_SET_TAG>]]>
</ruleText>
</Tag>
</data>
</ServiceRequest>
<platform API server>/qps/xsd/2.0/am/tag.xsd
Check out the following article on our Community to learn how to create asset tags using the Groovy programming language. You’ll also get several Groovy rule examples that you can start using today.