Try it free

Anonymization API - PUT anonymization job

  • Reference

Creates a user session anonymization job. The job anonymizes all user sessions in the specified timeframe by masking the user ID (userIds) and IP address (ips).

The IP address is masked by replacing its last octet with 0.

To identify user sessions to be anonymized, you can specify either the user ID, IP address, an internal application ID or a combination of them. If you specify multiple criteria, OR logic applies.

  • Every session of the specified user ID(s) gets anonymized, regardless of the IP address it came from.
  • Every session from the specified IP address gets anonymized, even if it belongs to a user ID that has not been specified
  • Every session that contains at least one user action, event or error with the given internal application ID get anonymized, regardless of the user ID or IP address. You can specify multiple user IDs and IP addresses, but only a single internal application ID.

Regardless of how you identify user sessions, both the user ID and IP address are masked. You can't undo anonymization.

The request produces an application/json payload. The response body contains the clusterRequestIds in case of Premium High-Availability clusters and the requestId of the anonymization job, which you can use to check the job status.

PUTManagedDynatrace for Governmenthttps://{your-domain}/e/{your-environment-id}/api/v1/anonymize/anonymizationJobs
PUTEnvironment ActiveGatehttps://{your-activegate-domain}/e/{your-environment-id}/api/v1/anonymize/anonymizationJobs

Authentication

Api-Token:

To execute this request, you need an access token with UserSessionAnonymization scope.

To learn how to obtain and use it, see Personal access tokens.

Parameters

ParameterTypeDescriptionInRequired
startTimestampinteger

The start timestamp of the user session to anonymize, in UTC milliseconds.

If not set the earliest available time is used.

queryOptional
endTimestampinteger

The end timestamp of the user session to anonymize, in UTC milliseconds.

If not set the current time is used.

queryOptional
userIdsstring[]

The UserID of the user to anonymize.

You can specify several IDs, in the following format: userIds=user1&userIds=user2.

queryOptional
ipsstring[]

The IP address of the user to anonymize. All user sessions from this IP will be anonymized.

You can specify several IPs, in the following format: ips=ip1&ips=ip2.

queryOptional
internalApplicationIdstring

The internal application ID used to identify sessions that should be anonymized.

All user sessions that contain at least one user action, event or error with the given application ID will be anonymized.

If you specify additional fields to be anonymized on user actions or events, only those user actions and events with the corresponding application ID will be anonymized.

queryOptional
additionalFieldstring[]

A list of fields to be anonymized.

You can specify several fields, in the following format: additionalField=field1&additionalField=field2.

The element can hold these values
  • ip
  • content
  • country
  • region
  • city
  • userId
  • isp
  • stringProperties
  • longProperties
  • doubleProperties
  • dateProperties
  • carrier
  • userActions.name
  • userActions.domain
  • userActions.targetUrl
  • userActions.syntheticEvent
  • userActions.stringProperties
  • userActions.longProperties
  • userActions.doubleProperties
  • userActions.dateProperties
  • events.name
  • events.domain
  • events.page
  • events.pageGroup
  • events.pageReferrer
  • events.pageReferrerGroup
  • errors.name
  • errors.domain
queryOptional

Response

Response codes

CodeTypeDescription
200AnonymizationIdResult

Success. The response body contains the ID of the anonymization job. You can use the ID to check the job status.

400-

Failed. The input is invalid. See the response body for details.

4XXErrorEnvelope

Client side error.

5XXErrorEnvelope

Server side error.

Response body objects

The AnonymizationIdResult object

ElementTypeDescription
clusterRequestIdsAnonymizationClusterRequestID[]

A list of tuples of request ID and cluster name

requestIdstring

The ID of the newly created anonymization job. If multiple datacenters are involved a list separated by "|" will be returned

The AnonymizationClusterRequestID object

A list of tuples of request ID and cluster name

ElementTypeDescription
dcNamestring-
idinteger-

Response body JSON models

{
"clusterRequestIds": [
{
"dcName": "string",
"id": 1
}
],
"requestId": "-4013759873546847071|7354684707140137598"
}

Best practices

Combine all user IDs and IP addresses into a single request

Anonymization jobs are processed one after another, and each job processes all user sessions in the specified timeframe. A job can therefore take a long time, and every additional request delays the jobs that are enqueued after it.

If you need to anonymize several users, submit one request that contains all of their user IDs and IP addresses instead of one request per user ID or IP address. Repeat the userIds and ips query parameters for each value:

PUT /api/v1/anonymize/anonymizationJobs?userIds=john.smith&userIds=mary.smith&ips=192.0.2.15&ips=198.51.100.7

If your list is too long for a single request URL, split it into a few large requests rather than many small ones.

Specify timestamps in UTC milliseconds

The startTimestamp and endTimestamp parameters accept Unix epoch timestamps in milliseconds, in UTC. Common mistakes:

  • Timestamps in seconds: A 10-digit value such as 1535760000 is interpreted as a date in January 1970, so the job doesn't cover the intended timeframe. If endTimestamp is in seconds, no user sessions are anonymized. Make sure your timestamps have 13 digits, for example, 1535760000000.
  • Date strings: Values such as 2018-09-01 or 2018-09-01T00:00:00Z aren't supported, and the request fails.
  • Local time instead of UTC: Convert your local start and end times to UTC before you calculate the timestamps. Otherwise, the timeframe is shifted by your UTC offset.

To convert a UTC date to a timestamp in milliseconds, you can use, for example:

# Linux (GNU date)
date -u -d '2018-09-01T00:00:00Z' +%s000
# macOS (BSD date)
date -u -j -f '%Y-%m-%dT%H:%M:%S' '2018-09-01T00:00:00' +%s000

If you're not sure in which timeframe the user sessions occurred, omit startTimestamp. The job then covers all stored user session data up to endTimestamp (or the current time, if endTimestamp isn't set).

Check the job status before you submit the request again

A job that is waiting for execution reports progress of -1. This is expected when other jobs are queued before it. Don't submit the same request again; use the returned requestId to check the job status instead.

Validation errors

The request is rejected with response code 400 if:

  • None of userIds, ips, or internalApplicationId is specified.
  • A userIds or ips value is empty.
  • An ips value isn't a valid IP address.

Example

In this example, the request starts a job to anonymize all sessions of users john.smith and mary.smith in the time frame between 00:00:00 September 1, 2018 and 23:59:59 September 10, 2018 UTC (corresponding to the 1535760000000 and 1536623999000 timestamps, respectively).

The API token is passed in the Authorization header.

The response contains the ID of the anonymization job, which can be used to check its status.

Curl

curl -X PUT \
'https://mySampleEnv.live.dynatrace.com/api/v1/anonymize/anonymizationJobs?startTimestamp=1535760000000&endTimestamp=1536623999000&userIds=john.smith&userIds=mary.smith' \
-H 'Authorization: Api-Token dt0c01.abc123.abcdefjhij1234567890'

Request URL

https://mySampleEnv.live.dynatrace.com/api/v1/anonymize/anonymizationJobs?startTimestamp=1535760000000&endTimestamp=1536623999000&userIds=john.smith&userIds=mary.smith

Response content

{
"clusterRequestIds": [
{
"id": -7520440752290577000,
"dcName": ""
}
],
"requestId": "-7520440752290577781"
}

Response code

200