Step 2. View Consent History for a User
GET {{apiPath}}/environments/{{envID}}/activities?filter=resources.id eq "{{agreementUserID}}" and (action.type eq "AGREEMENT_CONSENT.ACCEPTED")
The /environments/{{envID}}/activities endpoint can be used to return activity events for a specified environment. This request can accept SCIM filtering expressions as query parameters to fine-tune the response. For this activity, use a GET request with SCIM filtering expressions included as query parameters to focus response data on consent agreement history for a specific user.
Add these as query parameters in your request URL:
| Filter | Value | Description |
|---|---|---|
resources.type eq |
"user" |
The resource type. |
resources.id eq |
"{{agreementUserID}}" |
The UUID for the user. |
action.type eq |
"AGREEMENT_CONSENT.ACCEPTED" |
The action type that indicates agreement consent was accepted. |
Below is a description of the SCIM operators used in the filters above:
-
eq(equals) -
and(logical AND for building compound expressions in which both expressions are true.)
Learn more about query filters and SCIM operators in the GET Read Audit Activities section of the PingOne Platform API Reference documentation.
Example Request
-
cURL
-
C#
-
Go
-
HTTP
-
Java
-
jQuery
-
NodeJS
-
Python
-
PHP
-
Ruby
-
Swift
curl --location --globoff '{{apiPath}}/environments/{{envID}}/activities?filter=resources.id%20eq%20%22{{agreementUserID}}%22%20and%20(action.type%20eq%20%22AGREEMENT_CONSENT.ACCEPTED%22)' \
--header 'Authorization: Bearer {{accessToken}}'
var options = new RestClientOptions("{{apiPath}}/environments/{{envID}}/activities?filter=resources.id eq \"{{agreementUserID}}\" and (action.type eq \"AGREEMENT_CONSENT.ACCEPTED\")")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("", Method.Get);
request.AddHeader("Authorization", "Bearer {{accessToken}}");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{apiPath}}/environments/{{envID}}/activities?filter=resources.id%20eq%20%22{{agreementUserID}}%22%20and%20(action.type%20eq%20%22AGREEMENT_CONSENT.ACCEPTED%22)"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "Bearer {{accessToken}}")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
GET /environments/{{envID}}/activities?filter=resources.id eq "{{agreementUserID}}" and (action.type eq "AGREEMENT_CONSENT.ACCEPTED") HTTP/1.1
Host: {{apiPath}}
Authorization: Bearer {{accessToken}}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("{{apiPath}}/environments/{{envID}}/activities?filter=resources.id eq \"{{agreementUserID}}\" and (action.type eq \"AGREEMENT_CONSENT.ACCEPTED\")")
.method("GET", body)
.addHeader("Authorization", "Bearer {{accessToken}}")
.build();
Response response = client.newCall(request).execute();
var settings = {
"url": "{{apiPath}}/environments/{{envID}}/activities?filter=resources.id eq \"{{agreementUserID}}\" and (action.type eq \"AGREEMENT_CONSENT.ACCEPTED\")",
"method": "GET",
"timeout": 0,
"headers": {
"Authorization": "Bearer {{accessToken}}"
},
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'GET',
'url': '{{apiPath}}/environments/{{envID}}/activities?filter=resources.id eq "{{agreementUserID}}" and (action.type eq "AGREEMENT_CONSENT.ACCEPTED")',
'headers': {
'Authorization': 'Bearer {{accessToken}}'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
url = "{{apiPath}}/environments/{{envID}}/activities?filter=resources.id eq \"{{agreementUserID}}\" and (action.type eq \"AGREEMENT_CONSENT.ACCEPTED\")"
payload = {}
headers = {
'Authorization': 'Bearer {{accessToken}}'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('{{apiPath}}/environments/{{envID}}/activities?filter=resources.id eq "{{agreementUserID}}" and (action.type eq "AGREEMENT_CONSENT.ACCEPTED")');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Authorization' => 'Bearer {{accessToken}}'
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
require "uri"
require "net/http"
url = URI("{{apiPath}}/environments/{{envID}}/activities?filter=resources.id eq \"{{agreementUserID}}\" and (action.type eq \"AGREEMENT_CONSENT.ACCEPTED\")")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer {{accessToken}}"
response = http.request(request)
puts response.read_body
var request = URLRequest(url: URL(string: "{{apiPath}}/environments/{{envID}}/activities?filter=resources.id%20eq%20%22{{agreementUserID}}%22%20and%20(action.type%20eq%20%22AGREEMENT_CONSENT.ACCEPTED%22)")!,timeoutInterval: Double.infinity)
request.addValue("Bearer {{accessToken}}", forHTTPHeaderField: "Authorization")
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
}
task.resume()
Example Response
200 OK
{
"_links": {
"self": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/activities"
}
},
"_embedded": {
"activities": [
{
"_links": {
"self": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/activities/46340c9d-eaf0-46da-abc0-7ce66671aaa0"
}
},
"id": "46340c9d-eaf0-46da-abc0-7ce66671aaa0",
"recordedAt": "2024-06-26T18:09:55.340Z",
"createdAt": "2024-06-26T18:09:55.360Z",
"correlationId": "56833e8c-843e-418a-8160-81adbe6b2178",
"internalCorrelation": {
"transactionId": "c8ea2cde-c066-48cc-b558-f124f58e9d46",
"sessionId": "7a1f92c6-9be6-4195-99cd-d7db0b1d35eb"
},
"actors": {
"client": {
"id": "e1e5294f-a1a8-46af-b200-bb3110bb9dc4",
"name": "WebAppWithAgreement_1719425339",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/applications/e1e5294f-a1a8-46af-b200-bb3110bb9dc4",
"type": "CLIENT"
},
"user": {
"id": "69d23c1b-de3c-48a1-9446-c1ca6e8f26fc",
"name": "agreement_user_1719425219",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"population": {
"id": "17969c17-cfcb-4a73-a500-ca239a2f15cd"
},
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/69d23c1b-de3c-48a1-9446-c1ca6e8f26fc",
"type": "USER"
}
},
"source": {
"userAgent": "PostmanRuntime/7.37.0",
"ipAddress": "23.242.53.194"
},
"action": {
"type": "AGREEMENT_CONSENT.ACCEPTED",
"description": "Agreement Consent Accepted"
},
"resources": [
{
"type": "USER",
"id": "69d23c1b-de3c-48a1-9446-c1ca6e8f26fc",
"name": "agreement_user_1719425219",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"population": {
"id": "17969c17-cfcb-4a73-a500-ca239a2f15cd"
},
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/69d23c1b-de3c-48a1-9446-c1ca6e8f26fc"
}
],
"result": {
"status": "SUCCESS",
"description": "Consented to agreement with id:a3686bd9-c13c-4951-8f3f-aea9f93e2bd3"
}
},
{
"_links": {
"self": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/activities/7c06f9c6-8c65-4cbd-b0c1-1d36ef542b37"
}
},
"id": "7c06f9c6-8c65-4cbd-b0c1-1d36ef542b37",
"recordedAt": "2024-06-26T18:07:55.180Z",
"createdAt": "2024-06-26T18:07:55.306Z",
"correlationId": "d2050287-d5e5-45ba-a644-9b84372ad92d",
"internalCorrelation": {
"transactionId": "ee8a9589-13ab-411f-995c-5021b06b05a2",
"sessionId": "7a1f92c6-9be6-4195-99cd-d7db0b1d35eb"
},
"actors": {
"client": {
"id": "5376cff2-27c0-4c3b-83a5-4cc7ab471bd5",
"name": "WebAppWithAgreement_1719425153",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/applications/5376cff2-27c0-4c3b-83a5-4cc7ab471bd5",
"type": "CLIENT"
},
"user": {
"id": "69d23c1b-de3c-48a1-9446-c1ca6e8f26fc",
"name": "agreement_user_1719425219",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"population": {
"id": "17969c17-cfcb-4a73-a500-ca239a2f15cd"
},
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/69d23c1b-de3c-48a1-9446-c1ca6e8f26fc",
"type": "USER"
}
},
"source": {
"userAgent": "PostmanRuntime/7.37.0",
"ipAddress": "23.242.53.194"
},
"action": {
"type": "AGREEMENT_CONSENT.ACCEPTED",
"description": "Agreement Consent Accepted"
},
"resources": [
{
"type": "USER",
"id": "69d23c1b-de3c-48a1-9446-c1ca6e8f26fc",
"name": "agreement_user_1719425219",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"population": {
"id": "17969c17-cfcb-4a73-a500-ca239a2f15cd"
},
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/69d23c1b-de3c-48a1-9446-c1ca6e8f26fc"
}
],
"result": {
"status": "SUCCESS",
"description": "Consented to agreement with id:71d36818-c8fc-4efd-b702-c5e87ad88119"
}
}
]
}
}