PingOne Platform APIs

Step 1: Get the environment ID

GET {{apiPath}}/environments?limit=1

You can use the GET /environments endpoint to retrieve all environment resources associated with your organization.

The response data returns information about every environment referenced by your organization. For each environment resource, the data contains links for related resources as well as the properties for the environment. The id property identifies the UUID for the environment resource. The response data shows the environment resources associated with this organization. The limit attribute is set to 1, so only one environment is included in the response.

If you review the response to the right (or below), you’ll notice the ID for our environment is 020ed26b-ae15-4783-8fb3-gd65816dc391.

Headers

Authorization      Bearer {{accessToken}}

Example Request

  • cURL

  • C#

  • Go

  • HTTP

  • Java

  • jQuery

  • NodeJS

  • Python

  • PHP

  • Ruby

  • Swift

curl --location --globoff '{{apiPath}}/environments?limit=1' \
--header 'Authorization: Bearer {{accessToken}}'
var options = new RestClientOptions("{{apiPath}}/environments?limit=1")
{
  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?limit=1"
  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?limit=1 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?limit=1")
  .method("GET", body)
  .addHeader("Authorization", "Bearer {{accessToken}}")
  .build();
Response response = client.newCall(request).execute();
var settings = {
  "url": "{{apiPath}}/environments?limit=1",
  "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?limit=1',
  'headers': {
    'Authorization': 'Bearer {{accessToken}}'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests

url = "{{apiPath}}/environments?limit=1"

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?limit=1');
$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?limit=1")

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?limit=1")!,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": {
        "next": {
            "href": "https://example.com/v1/environments?cursor=ZW52SWQ9MDMxMjg5NzYtNmRhZi00NjdmLWJmMWYtNjMxZTFmMGQ4Mjhm&limit=1"
        },
        "self": {
            "href": "https://example.com/v1/environments?limit=1"
        }
    },
    "_embedded": {
        "environments": [
            {
                "_links": {
                    "self": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391"
                    },
                    "license": {
                        "href": "https://example.com/v1/organizations/bed432e6-676a-4ebe-b5a5-6b3b54e46bda/licenses/08b0cc35-7fd4-4c1f-9f84-6b323174cc72"
                    },
                    "organization": {
                        "href": "https://example.com/v1/organizations/bed432e6-676a-4ebe-b5a5-6b3b54e46bda"
                    },
                    "populations": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/populations"
                    },
                    "users": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/users"
                    },
                    "applications": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/applications"
                    },
                    "activities": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/activities"
                    },
                    "branding": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/branding"
                    },
                    "features": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/features"
                    },
                    "resources": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/resources"
                    },
                    "passwordPolicies": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/passwordPolicies"
                    },
                    "userActivities": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/userActivities"
                    },
                    "signOnPolicies": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/signOnPolicies"
                    },
                    "keys": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/keys"
                    },
                    "templates": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/templates"
                    },
                    "notificationsSettings": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/notificationsSettings"
                    },
                    "schemas": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/schemas"
                    },
                    "gateways": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/gateways"
                    },
                    "capabilities": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/capabilities"
                    },
                    "activeIdentityCounts": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/activeIdentityCounts"
                    },
                    "propagation/plans": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/propagation/plans"
                    },
                    "propagation/stores": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/propagation/stores"
                    },
                    "propagation/revisions/id:latest": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/propagation/revisions/id:latest"
                    },
                    "billOfMaterials": {
                        "href": "https://example.com/v1/environments/020ed26b-ae15-4783-8fb3-gd65816dc391/billOfMaterials"
                    }
                },
                "id": "020ed26b-ae15-4783-8fb3-gd65816dc391",
                "name": "example",
                "organization": {
                    "id": "bed432e6-676a-4ebe-b5a5-6b3b54e46bda"
                },
                "type": "SANDBOX",
                "region": "NA",
                "createdAt": "2020-06-09T18:07:12.221Z",
                "updatedAt": "2021-01-21T21:42:10.815Z",
                "license": {
                    "id": "08b0cc35-7fd4-4c1f-9f84-6b323124cc72"
                }
            }
        ]
    },
    "size": 1
}