PingOne Platform APIs - Early Access

Read All Promotions

   

GET {{apiPath}}/environments/{{envID}}/promotions

Use the GET {{apiPath}}/environments/{{envID}}/promotions request to return the details for all promotions. Included in the response are the automatically generated promotion plans for each promotion.

Headers

Authorization      Bearer {{accessToken}}

Example Request

  • cURL

  • C#

  • Go

  • HTTP

  • Java

  • jQuery

  • NodeJS

  • Python

  • PHP

  • Ruby

  • Swift

curl --location --globoff '{{apiPath}}/environments/{{envID}}/promotions' \
--header 'Authorization: Bearer {{accessToken}}'
var options = new RestClientOptions("{{apiPath}}/environments/{{envID}}/promotions")
{
  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}}/promotions"
  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}}/promotions 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}}/promotions")
  .method("GET", body)
  .addHeader("Authorization", "Bearer {{accessToken}}")
  .build();
Response response = client.newCall(request).execute();
var settings = {
  "url": "{{apiPath}}/environments/{{envID}}/promotions",
  "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}}/promotions',
  '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}}/promotions"

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}}/promotions');
$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}}/promotions")

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}}/promotions")!,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/promotions?limit=25"
        }
    },
    "_embedded": {
        "promotions": [
            {
                "_links": {
                    "environment": {
                        "href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
                    },
                    "self": {
                        "href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/promotions/8ae17de9-8e2a-41db-916e-3e46adaf16d9"
                    }
                },
                "id": "8ae17de9-8e2a-41db-916e-3e46adaf16d9",
                "createdAt": "2024-09-06T14:37:30.873Z",
                "updatedAt": "2024-09-06T14:37:30.873Z",
                "sourceEnvironmentId": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6",
                "rootResourceId": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6",
                "targetEnvironmentId": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6",
                "sourceSnapshotId": "c719a926-dee7-4026-b2f6-70f569c9d60d",
                "targetSnapshotId": "520f5827-cb3c-44cd-9b43-76a56fd46d0f",
                "status": "READY",
                "selectedResources": [
                    "5ab94557-59c3-4afc-bbf6-046444bd04b8"
                ],
                "mapping": {
                    "5ab94557-59c3-4afc-bbf6-046444bd04b8": "f0c75a0b-859e-433d-9edc-07a7c847e185"
                },
                "promotionPlan": {
                    "steps": [
                        {
                            "action": "PUT",
                            "resourceUrl": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/themes/f0c75a0b-859e-433d-9edc-07a7c847e185",
                            "payload": {
                                "environment": {
                                    "id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
                                },
                                "id": "f0c75a0b-859e-433d-9edc-07a7c847e185",
                                "template": "default",
                                "default": true,
                                "configuration": {
                                    "logoType": "IMAGE",
                                    "logo": {
                                        "href": "https://d3uinntk0mqu3p.cloudfront.net/branding/market/a3d073bc-3108-49ad-b96c-404bea59a1d0.png",
                                        "id": "00000000-0000-0000-0000-000000000000"
                                    },
                                    "backgroundColor": "#ededed",
                                    "backgroundType": "DEFAULT",
                                    "bodyTextColor": "#686f77",
                                    "cardColor": "#ffffff",
                                    "headingTextColor": "#686f77",
                                    "linkTextColor": "#2996cc",
                                    "buttonColor": "#2996cc",
                                    "buttonTextColor": "#ffffff",
                                    "name": "Ping Default"
                                },
                                "modified": "2021-05-12T18:32:14.694Z"
                            },
                            "totalDistance": 12
                        }
                    ]
                },
                "description": "Test promotion of branding"
            },
            {
                "_links": {
                    "environment": {
                        "href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
                    },
                    "self": {
                        "href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/promotions/1d0ff9f4-0fae-4859-9dfa-0aa6cac9150e"
                    }
                },
                "id": "1d0ff9f4-0fae-4859-9dfa-0aa6cac9150e",
                "createdAt": "2024-09-06T14:24:53.970Z",
                "updatedAt": "2024-09-06T14:24:53.970Z",
                "sourceEnvironmentId": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6",
                "rootResourceId": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6",
                "targetEnvironmentId": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6",
                "sourceSnapshotId": "cc64ea07-1da0-4bf8-b487-5c178667d8c8",
                "targetSnapshotId": "77a10527-328a-432c-b04a-9530d3232164",
                "status": "READY",
                "selectedResources": [
                    "ec987933-5b03-4b05-8468-13239c5a2362"
                ],
                "promotionPlan": {
                    "steps": [
                        {
                            "action": "POST",
                            "resourceUrl": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/agreements/",
                            "payload": {
                                "id": "ec987933-5b03-4b05-8468-13239c5a2362",
                                "environment": {
                                    "id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
                                },
                                "name": "Agreement_2",
                                "description": "Terms of service agreement",
                                "reconsentPeriodDays": 180,
                                "totalConsents": 0,
                                "totalExpiredConsents": 0,
                                "consentsAggregatedAt": "2024-09-06T14:24:54.399Z",
                                "enabled": false
                            },
                            "totalDistance": 100
                        }
                    ]
                },
                "description": "Test promotion of agreement"
            }
        ]
    },
    "count": 2,
    "size": 2
}