Add custom tags to the specified monitored entities.
The request consumes and produces an application/json payload.
| POST | SaaS | https://{your-environment-id}.live.dynatrace.com/api/v2/tags |
| Environment ActiveGateCluster ActiveGate | https://{your-activegate-domain}:9999/e/{your-environment-id}/api/v2/tags |
To execute this request, you need an access token with entities.write scope.
To learn how to obtain and use it, see Tokens and authentication.
| Parameter | Type | Description | In | Required |
|---|---|---|---|---|
| entitySelector | string | Specifies the entities where you want to update tags. You must set one of these criteria:
You can add one or more of the following criteria. Values are case-sensitive and the
For more information, see Entity selector in Dynatrace Documentation. To set several criteria, separate them with a comma ( The maximum string length is 2,000 characters. | query | Required |
| from | string | The start of the requested timeframe. You can use one of the following formats:
If not set, the relative timeframe of 24 hours is used ( | query | Optional |
| to | string | The end of the requested timeframe. You can use one of the following formats:
If not set, the current timestamp is used. | query | Optional |
| body | Add | The JSON body of the request. Contains tags to be added to the matching entities. | body | Optional |
AddEntityTags objectA list of tags to be added to monitored entities.
| Element | Type | Description | Required |
|---|---|---|---|
| tags | Add | A list of tags to be added to monitored entities. | Required |
AddEntityTag objectThe custom tag to be added to monitored entities.
| Element | Type | Description | Required |
|---|---|---|---|
| key | string | The key of the custom tag to be added to monitored entities. | Required |
| value | string | The value of the custom tag to be added to monitored entities. May be null | Optional |
This is a model of the request body, showing the possible elements. It has to be adjusted for usage in an actual request.
{"tags": [{"key": "mainApp"},{"key": "bookings","value": "42"}]}
| Code | Type | Description |
|---|---|---|
| 200 | Added | Success |
| 4XX | Error | Client side error. |
| 5XX | Error | Server side error. |
AddedEntityTags objectA list of custom tags added to monitored entities.
| Element | Type | Description |
|---|---|---|
| appliedTags | M | A list of added custom tags. |
| matchedEntitiesCount | integer | The number of monitored entities where the tags have been added. |
METag objectThe tag of a monitored entity.
| Element | Type | Description |
|---|---|---|
| context | string | The origin of the tag, such as AWS or Cloud Foundry. Custom tags use the |
| key | string | The key of the tag. |
| stringRepresentation | string | The string representation of the tag. |
| value | string | The value of the tag. |
ErrorEnvelope object| Element | Type | Description |
|---|---|---|
| error | Error | - |
Error object| Element | Type | Description |
|---|---|---|
| code | integer | The HTTP status code |
| constraintViolations | Constraint | A list of constraint violations |
| message | string | The error message |
ConstraintViolation objectA list of constraint violations
| Element | Type | Description |
|---|---|---|
| location | string | - |
| message | string | - |
| parameterLocation | string | -The element can hold these values
|
| path | string | - |
{"appliedTags": [{"context": "CONTEXTLESS","key": "mainApp","stringRepresentation": "mainApp"},{"context": "CONTEXTLESS","key": "booking","stringRepresentation": "booking"}],"matchedEntitiesCount": 2}
{"error": {"code": 1,"constraintViolations": [{"location": "string","message": "string","parameterLocation": "HEADER","path": "string"}],"message": "string"}}
In this example, the request adds the REST-test and RESTexample custom tags to hosts that already have the easyTravel tag. To achieve that, the entitySelector query parameter is set to type("HOST"),tag("easyTravel").
The API token is passed in the Authorization header.
curl -L -X POST 'https://mySampleEnv.live.dynatrace.com/api/v2/tags?entitySelector=type(%22HOST%22),tag(%22easyTravel%22)' \-H 'Authorization: Api-Token dt0c01.abc123.abcdefjhij1234567890' \-H 'Content-Type: application/json' \--data-raw '{"tags": [{"key": "REST-test"},{"key": "RESTexample"}]}'
https://mySampleEnv.live.dynatrace.com/api/v2/tags?entitySelector=type(%22HOST%22),tag(%22easyTravel%22)
{"tags": [{"key": "REST-test"},{"key": "RESTexample"}]}
{"matchedEntitiesCount": 3,"appliedTags": [{"context": "CONTEXTLESS","key": "REST-test","stringRepresentation": "REST-test"},{"context": "CONTEXTLESS","key": "RESTexample","stringRepresentation": "RESTexample"}]}
200