PingOne Platform APIs

Step 1. View Consent History for an Agreement

   

GET {{apiPath}}/environments/{{envID}}/activities?filter=resources.id eq "{{agreeID}}" 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 agreement.

Add these as query parameters in your request URL:

Filter Value Description

resources.id eq

"{{agreeID}}"

The UUID for the agreement.

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.

Headers

Authorization      Bearer {{accessToken}}

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{{agreeID}}%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 \"{{agreeID}}\" 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{{agreeID}}%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 "{{agreeID}}" 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 \"{{agreeID}}\" 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 \"{{agreeID}}\" 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 "{{agreeID}}" 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 \"{{agreeID}}\" 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 "{{agreeID}}" 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 \"{{agreeID}}\" 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{{agreeID}}%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/701320c1-6b4e-4f44-886f-8bcc8f2c0cfd"
                    }
                },
                "id": "701320c1-6b4e-4f44-886f-8bcc8f2c0cfd",
                "recordedAt": "2024-06-27T21:08:22.681Z",
                "createdAt": "2024-06-27T21:08:22.725Z",
                "correlationId": "230ad398-cb96-4fc8-a209-4bd9ca5a3997",
                "actors": {
                    "client": {
                        "id": "98a40ed3-02b3-422b-938a-b9082e387d12",
                        "name": "Worker App Access Token",
                        "environment": {
                            "id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
                        },
                        "href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/applications/98a40ed3-02b3-422b-938a-b9082e387d12",
                        "type": "CLIENT"
                    }
                },
                "source": {
                    "userAgent": "PostmanRuntime/7.37.0",
                    "ipAddress": "23.242.53.194"
                },
                "action": {
                    "type": "AGREEMENT_CONSENT.ACCEPTED",
                    "description": "Agreement Consent Accepted"
                },
                "resources": [
                    {
                        "type": "AGREEMENT",
                        "id": "facfccff-e313-4a92-87df-8e3533249a57",
                        "name": "facfccff-e313-4a92-87df-8e3533249a57",
                        "environment": {
                            "id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
                        },
                        "href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/agreements/facfccff-e313-4a92-87df-8e3533249a57"
                    }
                ],
                "result": {
                    "status": "SUCCESS",
                    "description": "Consent accepted for user:'abf0f78c-c1e8-4407-a3d9-eb1056d145a6' to agreement:'facfccff-e313-4a92-87df-8e3533249a57' and revision:'fc0b9cca-fded-4eed-8d5b-23fc8822b064'"
                }
            },
            {
                "_links": {
                    "self": {
                        "href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/activities/9e91e57d-6e31-44ec-ad4a-e413dcf02e2a"
                    }
                },
                "id": "9e91e57d-6e31-44ec-ad4a-e413dcf02e2a",
                "recordedAt": "2024-06-25T20:40:48.733Z",
                "createdAt": "2024-06-25T20:40:48.746Z",
                "correlationId": "9c44dc03-6cb0-4c90-9c94-e4a6c8ed901d",
                "internalCorrelation": {
                    "transactionId": "8d84b41b-3c75-4ac2-9639-c15ec33a5679",
                    "sessionId": "5b99b16f-a2d2-4ef1-aa1c-34435ad442ce"
                },
                "actors": {
                    "client": {
                        "id": "4f8a6b59-9076-4b91-929f-17359f76a05a",
                        "name": "WebAppWithAgreement_1719347902",
                        "environment": {
                            "id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
                        },
                        "href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/applications/4f8a6b59-9076-4b91-929f-17359f76a05a",
                        "type": "CLIENT"
                    },
                    "user": {
                        "id": "9fd5d03e-57c8-4b5b-bc29-a9e29e195795",
                        "name": "agreement_user_1719348026",
                        "environment": {
                            "id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
                        },
                        "population": {
                            "id": "01c12ec1-e070-47ad-a497-374c3454ae58"
                        },
                        "href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/9fd5d03e-57c8-4b5b-bc29-a9e29e195795",
                        "type": "USER"
                    }
                },
                "source": {
                    "userAgent": "PostmanRuntime/7.37.0",
                    "ipAddress": "23.242.53.194"
                },
                "action": {
                    "type": "AGREEMENT_CONSENT.ACCEPTED",
                    "description": "Agreement Consent Accepted"
                },
                "resources": [
                    {
                        "type": "AGREEMENT",
                        "id": "facfccff-e313-4a92-87df-8e3533249a57",
                        "name": "facfccff-e313-4a92-87df-8e3533249a57",
                        "environment": {
                            "id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
                        },
                        "href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/agreements/facfccff-e313-4a92-87df-8e3533249a57"
                    }
                ],
                "result": {
                    "status": "SUCCESS",
                    "description": "Consent accepted for user:'9fd5d03e-57c8-4b5b-bc29-a9e29e195795' to agreement:'facfccff-e313-4a92-87df-8e3533249a57' and revision:'fc0b9cca-fded-4eed-8d5b-23fc8822b064'"
                }
            }
        ]
    }
}