Create Subscriptions
POST {{apiPath}}/environments/{{envID}}/subscriptions
You can use POST {{apiPath}}/environments/{{envID}}/subscriptions/ to create a new subscriptions resource in the specified environment.
|
The service supports a maximum of 50 subscriptions. Attempts to create more than 50 subscriptions result in a 403 Forbidden error. |
Prerequisites
-
The webhook needs to be configured only for IPv4 addresses. IPv6 addresses are not fully-supported.
-
Refer to Subscriptions (webhooks) for important overview information.
-
Create a population to get a
popID. Refer to Create Population. Run Read All Populations to find an existing population. -
Create an application to get an
appID. Refer to Application Operations. Run Read All Applications to find an existing application.
Request Model
| Property | Type | Required? |
|---|---|---|
|
String[] |
Required |
|
String[] |
Required |
|
String[] |
Optional |
|
String[] |
Optional |
|
Boolean |
Optional |
|
Boolean |
Optional |
|
String |
Required |
|
String[] |
Required |
|
String |
Required |
|
Boolean[] |
Required |
|
Boolean |
Required |
Refer to Subscriptions (webhooks) data model for full property descriptions.
Body
raw ( application/json )
{
"name":"SubscriptionName1",
"filterOptions":{
"includedActionTypes":[
"USER.CREATED",
"USER.UPDATED"
],
"includedPopulations":[
{"id": "{{popID}}"}
],
"includedApplications":[
{"id": "{{appID}}"}
]
},
"httpEndpoint":{
"url":"https://subscriptionendpoint.com",
"headers":{
"some-header":"some-value"
}
},
"format":"ACTIVITY",
"verifyTlsCertificates":true,
"tlsClientAuthKeyPair":{
"id": "{{keyID}}"
},
"enabled":true
}
Example Request
-
cURL
-
C#
-
Go
-
HTTP
-
Java
-
jQuery
-
NodeJS
-
Python
-
PHP
-
Ruby
-
Swift
curl --location --globoff '{{apiPath}}/environments/{{envID}}/subscriptions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{accessToken}}' \
--data '{
"name":"SubscriptionName1",
"filterOptions":{
"includedActionTypes":[
"USER.CREATED",
"USER.UPDATED"
],
"includedPopulations":[
{"id": "{{popID}}"}
],
"includedApplications":[
{"id": "{{appID}}"}
]
},
"httpEndpoint":{
"url":"https://subscriptionendpoint.com",
"headers":{
"some-header":"some-value"
}
},
"format":"ACTIVITY",
"verifyTlsCertificates":true,
"tlsClientAuthKeyPair":{
"id": "{{keyID}}"
},
"enabled":true
}'
var options = new RestClientOptions("{{apiPath}}/environments/{{envID}}/subscriptions")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer {{accessToken}}");
var body = @"{" + "\n" +
@" ""name"":""SubscriptionName1""," + "\n" +
@" ""filterOptions"":{" + "\n" +
@" ""includedActionTypes"":[" + "\n" +
@" ""USER.CREATED""," + "\n" +
@" ""USER.UPDATED""" + "\n" +
@" ]," + "\n" +
@" ""includedPopulations"":[" + "\n" +
@" {""id"": ""{{popID}}""}" + "\n" +
@" ]," + "\n" +
@" ""includedApplications"":[" + "\n" +
@" {""id"": ""{{appID}}""}" + "\n" +
@" ]" + "\n" +
@" }," + "\n" +
@" ""httpEndpoint"":{" + "\n" +
@" ""url"":""https://subscriptionendpoint.com""," + "\n" +
@" ""headers"":{" + "\n" +
@" ""some-header"":""some-value""" + "\n" +
@" }" + "\n" +
@" }," + "\n" +
@" ""format"":""ACTIVITY""," + "\n" +
@" ""verifyTlsCertificates"":true," + "\n" +
@" ""tlsClientAuthKeyPair"":{" + "\n" +
@" ""id"": ""{{keyID}}""" + "\n" +
@" }," + "\n" +
@" ""enabled"":true" + "\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}}/subscriptions"
method := "POST"
payload := strings.NewReader(`{
"name":"SubscriptionName1",
"filterOptions":{
"includedActionTypes":[
"USER.CREATED",
"USER.UPDATED"
],
"includedPopulations":[
{"id": "{{popID}}"}
],
"includedApplications":[
{"id": "{{appID}}"}
]
},
"httpEndpoint":{
"url":"https://subscriptionendpoint.com",
"headers":{
"some-header":"some-value"
}
},
"format":"ACTIVITY",
"verifyTlsCertificates":true,
"tlsClientAuthKeyPair":{
"id": "{{keyID}}"
},
"enabled":true
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
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))
}
POST /environments/{{envID}}/subscriptions HTTP/1.1
Host: {{apiPath}}
Content-Type: application/json
Authorization: Bearer {{accessToken}}
{
"name":"SubscriptionName1",
"filterOptions":{
"includedActionTypes":[
"USER.CREATED",
"USER.UPDATED"
],
"includedPopulations":[
{"id": "{{popID}}"}
],
"includedApplications":[
{"id": "{{appID}}"}
]
},
"httpEndpoint":{
"url":"https://subscriptionendpoint.com",
"headers":{
"some-header":"some-value"
}
},
"format":"ACTIVITY",
"verifyTlsCertificates":true,
"tlsClientAuthKeyPair":{
"id": "{{keyID}}"
},
"enabled":true
}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"name\":\"SubscriptionName1\",\n \"filterOptions\":{\n \"includedActionTypes\":[\n \"USER.CREATED\",\n \"USER.UPDATED\"\n ],\n \"includedPopulations\":[\n {\"id\": \"{{popID}}\"}\n ],\n \"includedApplications\":[\n {\"id\": \"{{appID}}\"}\n ]\n },\n \"httpEndpoint\":{\n \"url\":\"https://subscriptionendpoint.com\",\n \"headers\":{\n \"some-header\":\"some-value\"\n }\n },\n \"format\":\"ACTIVITY\",\n \"verifyTlsCertificates\":true,\n \"tlsClientAuthKeyPair\":{\n \"id\": \"{{keyID}}\"\n },\n \"enabled\":true\n}");
Request request = new Request.Builder()
.url("{{apiPath}}/environments/{{envID}}/subscriptions")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer {{accessToken}}")
.build();
Response response = client.newCall(request).execute();
var settings = {
"url": "{{apiPath}}/environments/{{envID}}/subscriptions",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer {{accessToken}}"
},
"data": JSON.stringify({
"name": "SubscriptionName1",
"filterOptions": {
"includedActionTypes": [
"USER.CREATED",
"USER.UPDATED"
],
"includedPopulations": [
{
"id": "{{popID}}"
}
],
"includedApplications": [
{
"id": "{{appID}}"
}
]
},
"httpEndpoint": {
"url": "https://subscriptionendpoint.com",
"headers": {
"some-header": "some-value"
}
},
"format": "ACTIVITY",
"verifyTlsCertificates": true,
"tlsClientAuthKeyPair": {
"id": "{{keyID}}"
},
"enabled": true
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': '{{apiPath}}/environments/{{envID}}/subscriptions',
'headers': {
'Content-Type': 'application/json',
'Authorization': 'Bearer {{accessToken}}'
},
body: JSON.stringify({
"name": "SubscriptionName1",
"filterOptions": {
"includedActionTypes": [
"USER.CREATED",
"USER.UPDATED"
],
"includedPopulations": [
{
"id": "{{popID}}"
}
],
"includedApplications": [
{
"id": "{{appID}}"
}
]
},
"httpEndpoint": {
"url": "https://subscriptionendpoint.com",
"headers": {
"some-header": "some-value"
}
},
"format": "ACTIVITY",
"verifyTlsCertificates": true,
"tlsClientAuthKeyPair": {
"id": "{{keyID}}"
},
"enabled": true
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "{{apiPath}}/environments/{{envID}}/subscriptions"
payload = json.dumps({
"name": "SubscriptionName1",
"filterOptions": {
"includedActionTypes": [
"USER.CREATED",
"USER.UPDATED"
],
"includedPopulations": [
{
"id": "{{popID}}"
}
],
"includedApplications": [
{
"id": "{{appID}}"
}
]
},
"httpEndpoint": {
"url": "https://subscriptionendpoint.com",
"headers": {
"some-header": "some-value"
}
},
"format": "ACTIVITY",
"verifyTlsCertificates": True,
"tlsClientAuthKeyPair": {
"id": "{{keyID}}"
},
"enabled": True
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer {{accessToken}}'
}
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}}/subscriptions');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer {{accessToken}}'
));
$request->setBody('{\n "name":"SubscriptionName1",\n "filterOptions":{\n "includedActionTypes":[\n "USER.CREATED",\n "USER.UPDATED"\n ],\n "includedPopulations":[\n {"id": "{{popID}}"}\n ],\n "includedApplications":[\n {"id": "{{appID}}"}\n ]\n },\n "httpEndpoint":{\n "url":"https://subscriptionendpoint.com",\n "headers":{\n "some-header":"some-value"\n }\n },\n "format":"ACTIVITY",\n "verifyTlsCertificates":true,\n "tlsClientAuthKeyPair":{\n "id": "{{keyID}}"\n },\n "enabled":true\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}}/subscriptions")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer {{accessToken}}"
request.body = JSON.dump({
"name": "SubscriptionName1",
"filterOptions": {
"includedActionTypes": [
"USER.CREATED",
"USER.UPDATED"
],
"includedPopulations": [
{
"id": "{{popID}}"
}
],
"includedApplications": [
{
"id": "{{appID}}"
}
]
},
"httpEndpoint": {
"url": "https://subscriptionendpoint.com",
"headers": {
"some-header": "some-value"
}
},
"format": "ACTIVITY",
"verifyTlsCertificates": true,
"tlsClientAuthKeyPair": {
"id": "{{keyID}}"
},
"enabled": true
})
response = http.request(request)
puts response.read_body
let parameters = "{\n \"name\":\"SubscriptionName1\",\n \"filterOptions\":{\n \"includedActionTypes\":[\n \"USER.CREATED\",\n \"USER.UPDATED\"\n ],\n \"includedPopulations\":[\n {\"id\": \"{{popID}}\"}\n ],\n \"includedApplications\":[\n {\"id\": \"{{appID}}\"}\n ]\n },\n \"httpEndpoint\":{\n \"url\":\"https://subscriptionendpoint.com\",\n \"headers\":{\n \"some-header\":\"some-value\"\n }\n },\n \"format\":\"ACTIVITY\",\n \"verifyTlsCertificates\":true,\n \"tlsClientAuthKeyPair\":{\n \"id\": \"{{keyID}}\"\n },\n \"enabled\":true\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "{{apiPath}}/environments/{{envID}}/subscriptions")!,timeoutInterval: Double.infinity)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("Bearer {{accessToken}}", 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
201 Created
{
"_links": {
"self": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/subscriptions/9773fa25-a4f4-40d8-ac25-0d53338247c1"
},
"environment": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
}
},
"id": "9773fa25-a4f4-40d8-ac25-0d53338247c1",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"name": "SubscriptionName1",
"filterOptions": {
"includedActionTypes": [
"USER.CREATED",
"USER.UPDATED"
],
"includedPopulations": [
{
"id": "60971d3b-cc5a-4601-9c44-2be541f91bf1"
}
],
"includedApplications": [
{
"id": "cdecf42f-9fdb-4b46-a75d-6ff608a4109d"
}
]
},
"httpEndpoint": {
"url": "https://subscriptionendpoint.com",
"headers": {
"some-header": "some-value"
}
},
"format": "ACTIVITY",
"enabled": true,
"createdAt": "2021-03-15T22:30:48.958Z",
"verifyTlsCertificates": true,
"tlsClientAuthKeyPair": {
"id": "56efz334-20d1-4861-8c45-6d0ccfd4db4e"
}
}