Custom tags API - DELETE tags

Deletes the specified custom tag from the specified monitored entities.

The request produces an application/json payload.

Early Adopter

This request is an Early Adopter release and may be changed in non-compatible way.

DELETE
  • Managed https://{your-domain}/e/{your-environment-id}/api/v2/tags
  • SaaS https://{your-environment-id}.live.dynatrace.com/api/v2/tags

Authentication

To execute this request, you need the Write entities (entities.write) permission assigned to your API token. To learn how to obtain and use it, see Tokens and authentication.

Parameters

Parameter Type Description In Required
key string

The tag to be deleted.

query required
value string

The tag to be deleted.

query optional
deleteAllWithKey boolean

The tag to be deleted.

query optional
entitySelector string

Specifies the entities where you want to delete tags.

You need to set one of these criteria:

  • Entity type: type("TYPE")
  • Dynatrace entity ID: entityId("id"). You can specify several IDs, separated by a comma (entityId("id-1","id-2")).

And you can add one or several of the following criteria. Values are case-sensitive and the EQUALS operator is used unless otherwise specified.

  • Tag: tag("value"). Tags in [context]key:value, key:value, and value formats are detected and parsed automatically. If a value-only tag has a colon (:) in it, you must escape the colon with a backslash(\). Otherwise, the tag will be parsed as a key:value tag. All tag values are case-sensitive.
  • Management zone ID: mzId(123)
  • Management zone name: mzName("value")
  • Entity name: entityName("value"). The CONTAINS operator is used and the value is not case-sensitive.
  • Health state (HEALTHY,UNHEALTHY): healthState("HEALTHY")
  • Entity attribute: <attribute>("value1","value2"). For the list of available attributes, see the Entity selector help page.

To set several criteria, separate them with a comma (,). For example, type("HOST"),healthState("HEALTHY"). Only results matching all criteria are included in response.

The length of the string is limited to 10,000 characters.

query required
from string

The start of the requested timeframe.

You can use one of the following formats:

  • Timestamp in UTC milliseconds.
  • Human-readable format of 2021-01-25T05:57:01.123+01:00. If no time zone is specified, UTC is used. You can use a space character instead of the T. Seconds and fractions of a second are optional.
  • Relative timeframe, back from now. The format is now-NU/A, where N is the amount of time, U is the unit of time, and A is an alignment. The alignment rounds all the smaller values to the nearest zero in the past. For example, now-1y/w is one year back, aligned by a week. You can also specify relative timeframe without an alignment: now-NU. Supported time units for the relative timeframe are:
    • m: minutes
    • h: hours
    • d: days
    • w: weeks
    • M: months
    • y: years

If not set, the relative timeframe of 24 hours is used (now-24h).

query optional
to string

The end of the requested timeframe.

You can use one of the following formats:

  • Timestamp in UTC milliseconds.
  • Human-readable format of 2021-01-25T05:57:01.123+01:00. If no time zone is specified, UTC is used. You can use a space character instead of the T. Seconds and fractions of a second are optional.
  • Relative timeframe, back from now. The format is now-NU/A, where N is the amount of time, U is the unit of time, and A is an alignment. The alignment rounds all the smaller values to the nearest zero in the past. For example, now-1y/w is one year back, aligned by a week. You can also specify relative timeframe without an alignment: now-NU. Supported time units for the relative timeframe are:
    • m: minutes
    • h: hours
    • d: days
    • w: weeks
    • M: months
    • y: years

If not set, the current timestamp is used.

query optional

Response

Response codes

Code Description
200

Success

Response body

The DeletedEntityTags object

Deleted custom tag.

Element Type Description
matchedEntitiesCount integer

The number of monitored entities where the tag has been deleted.

Example

In this example, the request deletes the REST-test custom tag creates in the POST request example. Again the entitySelector query parameter is set to type("HOST"),tag("easyTravel").

The API token is passed in the Authorization header.

Curl

curl -L -X DELETE 'https://mySampleEnv.live.dynatrace.com/api/v2/tags?entitySelector=type(%22HOST%22),tag(%22easyTravel%22)&tag=REST-test' \
-H 'Authorization: Api-Token abcdefjhij1234567890'

Request URL

https://mySampleEnv.live.dynatrace.com/api/v2/tags?entitySelector=type(%22HOST%22),tag(%22easyTravel%22)&tag=REST-test

Response body

{
  "deletedTag": {
    "context": "CONTEXTLESS",
    "key": "REST-test",
    "stringRepresentation": "REST-test"
  },
  "matchedEntitiesCount": 3
}

Response code

200