PingOne Platform APIs

Evaluate a Bulk Decision Request

 

POST {{apiPath}}/environments/{{envId}}/decisionEndpoints/{{decisionEndpointId}}

The POST {{apiPath}}/v1/environments/{{envId}}/decisionEndpoints/{{decisionEndpointId}} operation executes a bulk decision request against the decision endpoint specified by its ID in the request URL. The request body requires the decisionRequests property. The parameters and userContext properties are optional.

This operation uses the application/vnd.pingidentity.decisionengine.authorize.bulk+json custom media type in the Content-Type request header.

When successful, a 200 OK status code is returned. A 400 Payload Too Large error is returned if the batch size exceeds the maximum allowed value of 20.

Prerequisites

Request Model

For property descriptions, refer to Bulk policy decision evaluation request data model.

Property Type Required

decisionRequests

Array

Required

parameters

Object

Optional

userContext.user.id

UUID

Optional

Headers

Authorization      Bearer {{sharedSecret}}

Content-Type      application/vnd.pingidentity.decisionengine.authorize.bulk+json

Body

raw ( application/vnd.pingidentity.decisionengine.authorize.bulk+json )

{
  "parameters": {
    "channel": "web"
  },
  "userContext": {
    "user": {
      "id": "{{userId}}"
    }
  },
  "decisionRequests": [
    {
      "parameters": {
        "Prospect name": "B. Vo"
      },
      "userContext": {
        "user": {
          "id": "{{userId}}" // Overrides shared userContext
        }
      }
    },
    {
      "parameters": {
        "Prospect name": "A. Mann",
        "channel": "mobile" // Overrides shared channel parameter
      }
    }
  ]
}

Example Request

  • cURL

  • C#

  • Go

  • HTTP

  • Java

  • jQuery

  • NodeJS

  • Python

  • PHP

  • Ruby

  • Swift

curl --location --globoff '{{apiPath}}/environments/{{envId}}/decisionEndpoints/{{decisionEndpointId}}' \
--header 'Content-Type: application/vnd.pingidentity.decisionengine.authorize.bulk+json' \
--header 'Authorization: Bearer {{sharedSecret}}' \
--data '{
  "parameters": {
    "channel": "web"
  },
  "userContext": {
    "user": {
      "id": "{{userId}}"
    }
  },
  "decisionRequests": [
    {
      "parameters": {
        "Prospect name": "B. Vo"
      },
      "userContext": {
        "user": {
          "id": "{{userId}}" // Overrides shared userContext
        }
      }
    },
    {
      "parameters": {
        "Prospect name": "A. Mann",
        "channel": "mobile" // Overrides shared channel parameter
      }
    }
  ]
}'
var options = new RestClientOptions("{{apiPath}}/environments/{{envId}}/decisionEndpoints/{{decisionEndpointId}}")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("", Method.Post);
request.AddHeader("Content-Type", "application/vnd.pingidentity.decisionengine.authorize.bulk+json");
request.AddHeader("Authorization", "Bearer {{sharedSecret}}");
var body = @"{" + "\n" +
@"  ""parameters"": {" + "\n" +
@"    ""channel"": ""web""" + "\n" +
@"  }," + "\n" +
@"  ""userContext"": {" + "\n" +
@"    ""user"": {" + "\n" +
@"      ""id"": ""{{userId}}""" + "\n" +
@"    }" + "\n" +
@"  }," + "\n" +
@"  ""decisionRequests"": [" + "\n" +
@"    {" + "\n" +
@"      ""parameters"": {" + "\n" +
@"        ""Prospect name"": ""B. Vo""" + "\n" +
@"      }," + "\n" +
@"      ""userContext"": {" + "\n" +
@"        ""user"": {" + "\n" +
@"          ""id"": ""{{userId}}"" // Overrides shared userContext" + "\n" +
@"        }" + "\n" +
@"      }" + "\n" +
@"    }," + "\n" +
@"    {" + "\n" +
@"      ""parameters"": {" + "\n" +
@"        ""Prospect name"": ""A. Mann""," + "\n" +
@"        ""channel"": ""mobile"" // Overrides shared channel parameter" + "\n" +
@"      }" + "\n" +
@"    }" + "\n" +
@"  ]" + "\n" +
@"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "{{apiPath}}/environments/{{envId}}/decisionEndpoints/{{decisionEndpointId}}"
  method := "POST"

  payload := strings.NewReader(`{
  "parameters": {
    "channel": "web"
  },
  "userContext": {
    "user": {
      "id": "{{userId}}"
    }
  },
  "decisionRequests": [
    {
      "parameters": {
        "Prospect name": "B. Vo"
      },
      "userContext": {
        "user": {
          "id": "{{userId}}" // Overrides shared userContext
        }
      }
    },
    {
      "parameters": {
        "Prospect name": "A. Mann",
        "channel": "mobile" // Overrides shared channel parameter
      }
    }
  ]
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/vnd.pingidentity.decisionengine.authorize.bulk+json")
  req.Header.Add("Authorization", "Bearer {{sharedSecret}}")

  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))
}
POST /environments/{{envId}}/decisionEndpoints/{{decisionEndpointId}} HTTP/1.1
Host: {{apiPath}}
Content-Type: application/vnd.pingidentity.decisionengine.authorize.bulk+json
Authorization: Bearer {{sharedSecret}}

{
  "parameters": {
    "channel": "web"
  },
  "userContext": {
    "user": {
      "id": "{{userId}}"
    }
  },
  "decisionRequests": [
    {
      "parameters": {
        "Prospect name": "B. Vo"
      },
      "userContext": {
        "user": {
          "id": "{{userId}}" // Overrides shared userContext
        }
      }
    },
    {
      "parameters": {
        "Prospect name": "A. Mann",
        "channel": "mobile" // Overrides shared channel parameter
      }
    }
  ]
}
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/vnd.pingidentity.decisionengine.authorize.bulk+json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"parameters\": {\n    \"channel\": \"web\"\n  },\n  \"userContext\": {\n    \"user\": {\n      \"id\": \"{{userId}}\"\n    }\n  },\n  \"decisionRequests\": [\n    {\n      \"parameters\": {\n        \"Prospect name\": \"B. Vo\"\n      },\n      \"userContext\": {\n        \"user\": {\n          \"id\": \"{{userId}}\" // Overrides shared userContext\n        }\n      }\n    },\n    {\n      \"parameters\": {\n        \"Prospect name\": \"A. Mann\",\n        \"channel\": \"mobile\" // Overrides shared channel parameter\n      }\n    }\n  ]\n}");
Request request = new Request.Builder()
  .url("{{apiPath}}/environments/{{envId}}/decisionEndpoints/{{decisionEndpointId}}")
  .method("POST", body)
  .addHeader("Content-Type", "application/vnd.pingidentity.decisionengine.authorize.bulk+json")
  .addHeader("Authorization", "Bearer {{sharedSecret}}")
  .build();
Response response = client.newCall(request).execute();
var settings = {
  "url": "{{apiPath}}/environments/{{envId}}/decisionEndpoints/{{decisionEndpointId}}",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/vnd.pingidentity.decisionengine.authorize.bulk+json",
    "Authorization": "Bearer {{sharedSecret}}"
  },
  "data": "{\n  \"parameters\": {\n    \"channel\": \"web\"\n  },\n  \"userContext\": {\n    \"user\": {\n      \"id\": \"{{userId}}\"\n    }\n  },\n  \"decisionRequests\": [\n    {\n      \"parameters\": {\n        \"Prospect name\": \"B. Vo\"\n      },\n      \"userContext\": {\n        \"user\": {\n          \"id\": \"{{userId}}\" // Overrides shared userContext\n        }\n      }\n    },\n    {\n      \"parameters\": {\n        \"Prospect name\": \"A. Mann\",\n        \"channel\": \"mobile\" // Overrides shared channel parameter\n      }\n    }\n  ]\n}",
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require('request');
var options = {
  'method': 'POST',
  'url': '{{apiPath}}/environments/{{envId}}/decisionEndpoints/{{decisionEndpointId}}',
  'headers': {
    'Content-Type': 'application/vnd.pingidentity.decisionengine.authorize.bulk+json',
    'Authorization': 'Bearer {{sharedSecret}}'
  },
  body: '{\n  "parameters": {\n    "channel": "web"\n  },\n  "userContext": {\n    "user": {\n      "id": "{{userId}}"\n    }\n  },\n  "decisionRequests": [\n    {\n      "parameters": {\n        "Prospect name": "B. Vo"\n      },\n      "userContext": {\n        "user": {\n          "id": "{{userId}}" // Overrides shared userContext\n        }\n      }\n    },\n    {\n      "parameters": {\n        "Prospect name": "A. Mann",\n        "channel": "mobile" // Overrides shared channel parameter\n      }\n    }\n  ]\n}'

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests
import json

url = "{{apiPath}}/environments/{{envId}}/decisionEndpoints/{{decisionEndpointId}}"

payload = "{\n  \"parameters\": {\n    \"channel\": \"web\"\n  },\n  \"userContext\": {\n    \"user\": {\n      \"id\": \"{{userId}}\"\n    }\n  },\n  \"decisionRequests\": [\n    {\n      \"parameters\": {\n        \"Prospect name\": \"B. Vo\"\n      },\n      \"userContext\": {\n        \"user\": {\n          \"id\": \"{{userId}}\" // Overrides shared userContext\n        }\n      }\n    },\n    {\n      \"parameters\": {\n        \"Prospect name\": \"A. Mann\",\n        \"channel\": \"mobile\" // Overrides shared channel parameter\n      }\n    }\n  ]\n}"
headers = {
  'Content-Type': 'application/vnd.pingidentity.decisionengine.authorize.bulk+json',
  'Authorization': 'Bearer {{sharedSecret}}'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('{{apiPath}}/environments/{{envId}}/decisionEndpoints/{{decisionEndpointId}}');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Content-Type' => 'application/vnd.pingidentity.decisionengine.authorize.bulk+json',
  'Authorization' => 'Bearer {{sharedSecret}}'
));
$request->setBody('{\n  "parameters": {\n    "channel": "web"\n  },\n  "userContext": {\n    "user": {\n      "id": "{{userId}}"\n    }\n  },\n  "decisionRequests": [\n    {\n      "parameters": {\n        "Prospect name": "B. Vo"\n      },\n      "userContext": {\n        "user": {\n          "id": "{{userId}}" // Overrides shared userContext\n        }\n      }\n    },\n    {\n      "parameters": {\n        "Prospect name": "A. Mann",\n        "channel": "mobile" // Overrides shared channel parameter\n      }\n    }\n  ]\n}');
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 "json"
require "net/http"

url = URI("{{apiPath}}/environments/{{envId}}/decisionEndpoints/{{decisionEndpointId}}")

http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/vnd.pingidentity.decisionengine.authorize.bulk+json"
request["Authorization"] = "Bearer {{sharedSecret}}"
request.body = "{\n  \"parameters\": {\n    \"channel\": \"web\"\n  },\n  \"userContext\": {\n    \"user\": {\n      \"id\": \"{{userId}}\"\n    }\n  },\n  \"decisionRequests\": [\n    {\n      \"parameters\": {\n        \"Prospect name\": \"B. Vo\"\n      },\n      \"userContext\": {\n        \"user\": {\n          \"id\": \"{{userId}}\" // Overrides shared userContext\n        }\n      }\n    },\n    {\n      \"parameters\": {\n        \"Prospect name\": \"A. Mann\",\n        \"channel\": \"mobile\" // Overrides shared channel parameter\n      }\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
let parameters = "{\n  \"parameters\": {\n    \"channel\": \"web\"\n  },\n  \"userContext\": {\n    \"user\": {\n      \"id\": \"{{userId}}\"\n    }\n  },\n  \"decisionRequests\": [\n    {\n      \"parameters\": {\n        \"Prospect name\": \"B. Vo\"\n      },\n      \"userContext\": {\n        \"user\": {\n          \"id\": \"{{userId}}\" // Overrides shared userContext\n        }\n      }\n    },\n    {\n      \"parameters\": {\n        \"Prospect name\": \"A. Mann\",\n        \"channel\": \"mobile\" // Overrides shared channel parameter\n      }\n    }\n  ]\n}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "{{apiPath}}/environments/{{envId}}/decisionEndpoints/{{decisionEndpointId}}")!,timeoutInterval: Double.infinity)
request.addValue("application/vnd.pingidentity.decisionengine.authorize.bulk+json", forHTTPHeaderField: "Content-Type")
request.addValue("Bearer {{sharedSecret}}", forHTTPHeaderField: "Authorization")

request.httpMethod = "POST"
request.httpBody = postData

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

{
    "summary": {
        "requested": 2,
        "errors": 0,
        "successful": 2
    },
    "correlationId": "6f0a2dca-8a9c-4849-8bf0-3bcfca0213b1",
    "authorizationVersion": {
        "id": "fedcba09-8765-4321-fedcba098765"
    },
    "timestamp": "2021-06-11T04:18:32.820482Z",
    "responses": [
        {
            "id": "12345678-90ab-cdef-1234-567890abcdef",
            "elapsedMicroseconds": 830492,
            "decision": "PERMIT",
            "statements": [
                {
                    "name": "Advice Name",
                    "code": "advice-code",
                    "payload": "{\"data\": \"more data\"}"
                }
            ],
            "status": {
                "code": "OKAY",
                "messages": [],
                "errors": []
            }
        },
        {
            "id": "fedcba09-8765-cdef-4321-fedcba098765",
            "elapsedMicroseconds": 492048,
            "decision": "INDETERMINATE",
            "status": {
                "code": "OKAY",
                "messages": [],
                "errors": []
            }
        }
    ]
}