Step 1: Read all notification templates
GET {{apiPath}}/environments/{{envID}}/templates
The GET /environments/{{envID}}/templates endpoint returns a list of all notifications template resources for the specified environment resource. Each template.id corresponds to one or more compatible notification types.
For this use case, use the general template for email, SMS, and voice notification content in steps 2-7. For push notification content in steps 8 and 9, use the transaction template.
Example Request
-
cURL
-
C#
-
Go
-
HTTP
-
Java
-
jQuery
-
NodeJS
-
Python
-
PHP
-
Ruby
-
Swift
curl --location --globoff '{{apiPath}}/environments/{{envID}}/templates' \
--header 'Authorization: Bearer {{accessToken}}'
var options = new RestClientOptions("{{apiPath}}/environments/{{envID}}/templates")
{
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}}/templates"
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}}/templates 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}}/templates")
.method("GET", body)
.addHeader("Authorization", "Bearer {{accessToken}}")
.build();
Response response = client.newCall(request).execute();
var settings = {
"url": "{{apiPath}}/environments/{{envID}}/templates",
"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}}/templates',
'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}}/templates"
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}}/templates');
$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}}/templates")
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}}/templates")!,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/templates"
},
"environment": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"next": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/templates?cursor=new_device_paired"
}
},
"_embedded": {
"templates": [
{
"_links": {
"self": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/templates/email_verification_admin"
},
"environment": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
}
},
"id": "email_verification_admin",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"description": "Admins will receive this message to verify their email address.",
"deliveryMethods": [
"Email"
],
"displayName": "Email Address Verification (Admin)",
"createdAt": "2022-09-19T00:00:00.000Z",
"updatedAt": "2022-09-26T00:00:00.000Z",
"variables": {
"user.username": {
"required": false
},
"user.name.given": {
"required": false
},
"user.name.family": {
"required": false
},
"code": {
"required": true,
"requiredForDeliveryMethods": [
"Email"
]
}
},
"allowDynamicVariables": true
},
{
"_links": {
"self": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/templates/email_verification_user"
},
"environment": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
}
},
"id": "email_verification_user",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"description": "Users will receive this message to verify their email address.",
"deliveryMethods": [
"Email"
],
"displayName": "Email Address Verification (User)",
"createdAt": "2022-09-19T00:00:00.000Z",
"updatedAt": "2022-09-26T00:00:00.000Z",
"variables": {
"user.username": {
"required": false
},
"user.name.given": {
"required": false
},
"user.name.family": {
"required": false
},
"code": {
"required": true,
"requiredForDeliveryMethods": [
"Email"
]
}
},
"allowDynamicVariables": true
},
{
"_links": {
"self": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/templates/general"
},
"environment": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
}
},
"id": "general",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"description": "Use this multi-purpose template to create custom notifications.",
"deliveryMethods": [
"SMS",
"Email",
"Voice"
],
"displayName": "General",
"createdAt": "2022-07-10T13:53:48.000Z",
"updatedAt": "2022-07-10T13:53:48.000Z",
"allowDynamicVariables": true
},
{
"_links": {
"self": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/templates/transaction"
},
"environment": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
}
},
"id": "transaction",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"description": "Users will receive this message for transaction approval.",
"deliveryMethods": [
"SMS",
"Email",
"Push",
"Voice"
],
"displayName": "Transaction",
"createdAt": "2020-03-18T09:42:00.705Z",
"updatedAt": "2020-03-18T09:42:00.705Z",
"variables": {
"user.username": {
"required": false
},
"user.name.given": {
"required": false
},
"user.name.family": {
"required": false
},
"otp": {
"required": true,
"requiredForDeliveryMethods": [
"SMS",
"Email",
"Voice"
]
}
},
"allowDynamicVariables": true
},
{
"_links": {
"self": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/templates/verification_code_template"
},
"environment": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
}
},
"id": "verification_code_template",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"description": "Users will receive this message to verify their email address.",
"deliveryMethods": [
"Email"
],
"displayName": "Verification Code",
"createdAt": "2019-01-10T16:39:56.000Z",
"updatedAt": "2019-01-10T16:39:56.000Z",
"variables": {
"user.username": {
"required": false
},
"user.name.given": {
"required": false
},
"user.name.family": {
"required": false
},
"code.value": {
"required": true,
"requiredForDeliveryMethods": [
"Email"
]
}
},
"allowDynamicVariables": true
},
{
"_links": {
"self": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/templates/recovery_code_template"
},
"environment": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
}
},
"id": "recovery_code_template",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"description": "Users who need to reset their password will receive this message.",
"deliveryMethods": [
"Email"
],
"displayName": "Password Recovery",
"createdAt": "2019-01-10T16:39:56.000Z",
"updatedAt": "2019-01-10T16:39:56.000Z",
"variables": {
"user.username": {
"required": false
},
"user.name.given": {
"required": false
},
"user.name.family": {
"required": false
},
"code.value": {
"required": true,
"requiredForDeliveryMethods": [
"Email"
]
}
},
"allowDynamicVariables": true
},
{
"_links": {
"self": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/templates/device_pairing"
},
"environment": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
}
},
"id": "device_pairing",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"description": "Users will receive this message to pair their device for strong authentication.",
"deliveryMethods": [
"SMS",
"Email",
"Voice"
],
"displayName": "Device Pairing",
"createdAt": "2018-12-17T13:34:36.000Z",
"updatedAt": "2018-12-17T13:34:36.000Z",
"variables": {
"user.username": {
"required": false
},
"user.name.given": {
"required": false
},
"user.name.family": {
"required": false
},
"current-year": {
"required": false
},
"otp": {
"required": true,
"requiredForDeliveryMethods": [
"SMS",
"Email",
"Voice"
]
}
},
"allowDynamicVariables": true
},
{
"_links": {
"self": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/templates/strong_authentication"
},
"environment": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
}
},
"id": "strong_authentication",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"description": "Users will receive this message for strong authentication.",
"deliveryMethods": [
"SMS",
"Email",
"Push",
"Voice"
],
"displayName": "Strong Authentication",
"createdAt": "2018-12-10T10:45:05.000Z",
"updatedAt": "2018-12-10T10:45:05.000Z",
"variables": {
"user.username": {
"required": false
},
"user.name.given": {
"required": false
},
"user.name.family": {
"required": false
},
"current-year": {
"required": false
},
"otp": {
"required": true,
"requiredForDeliveryMethods": [
"SMS",
"Email",
"Voice"
]
}
},
"allowDynamicVariables": true
},
{
"_links": {
"self": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/templates/new_device_paired"
},
"environment": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
}
},
"id": "new_device_paired",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"description": "When a new device is paired, a notification will be sent to the user that a device has been registered to their account.",
"deliveryMethods": [
"SMS",
"Email"
],
"displayName": "New Device Paired",
"createdAt": "1970-01-20T11:40:25.868Z",
"updatedAt": "1970-01-20T11:40:25.868Z",
"variables": {
"device.name": {
"required": true,
"requiredForDeliveryMethods": [
"SMS",
"Email"
]
},
"org.name": {
"required": false
}
},
"allowDynamicVariables": true
}
]
},
"count": 9,
"size": 9
}