Create Credential Issuance Rule
POST {{apiPath}}/environments/{{envID}}/credentialTypes/{{credentialTypeID}}/issuanceRules
Use the POST {{apiPath}}/environments/{{envID}}/credentialTypes/{{credentialTypeID}}/issuanceRules operation to create a credential issuance rule for the specified credential type in the specified environment.
|
You cannot create an issuance rule for a credential type if that credential type has |
Prerequisites
Create a credential type (automated) or Create a credential type (managed) to get a credentialTypeId for the endpoint. Refer also to Credential Types.
Request Model
Refer to Credential Issuance Rules data model for full property descriptions.
| Property | Type | Required? |
|---|---|---|
|
Object |
Required |
|
String |
Required |
|
String |
Required |
|
String |
Required |
|
String |
Optional |
|
Object |
Optional |
|
String[] |
Required/Optional |
|
String[] |
Required/Optional |
|
String |
Required/Optional |
|
Object |
Optional |
|
Object |
Optional |
|
String |
Required |
|
String |
Required |
|
Object[] |
Required/Optional |
|
String |
Required |
|
If |
When an action in automation is set to PERIODIC and the period arrives, the credential service uses a notification template appropriate to the action, credential_issued, credential_updated, or credential_revoked, to send notice of the action taken to the user via email or SMS text. The notification.template object can define a variant and locale for the notifications, if needed, and applies to actions initiated periodically and actions initiated by an Apply Credential Issuance Rule Staged Changes request.
|
The |
Example Request
-
cURL
-
C#
-
Go
-
HTTP
-
Java
-
jQuery
-
NodeJS
-
Python
-
PHP
-
Ruby
-
Swift
curl --location --globoff '{{apiPath}}/environments/{{envID}}/credentialTypes/{{credentialTypeID}}/issuanceRules' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{accessToken}}' \
--data '{
"status": "ACTIVE",
"digitalWalletApplication": {
"id": "{{digitalWalletApplicationID}}"
},
"filter": {
"populationIds": [
"{{popID}}"
]
},
"automation": {
"issue": "PERIODIC",
"update": "ON_DEMAND",
"revoke": "ON_DEMAND"
}
}'
var options = new RestClientOptions("{{apiPath}}/environments/{{envID}}/credentialTypes/{{credentialTypeID}}/issuanceRules")
{
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" +
@" ""status"": ""ACTIVE""," + "\n" +
@" ""digitalWalletApplication"": {" + "\n" +
@" ""id"": ""{{digitalWalletApplicationID}}""" + "\n" +
@" }," + "\n" +
@" ""filter"": {" + "\n" +
@" ""populationIds"": [" + "\n" +
@" ""{{popID}}""" + "\n" +
@" ]" + "\n" +
@" }," + "\n" +
@" ""automation"": {" + "\n" +
@" ""issue"": ""PERIODIC""," + "\n" +
@" ""update"": ""ON_DEMAND""," + "\n" +
@" ""revoke"": ""ON_DEMAND""" + "\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}}/credentialTypes/{{credentialTypeID}}/issuanceRules"
method := "POST"
payload := strings.NewReader(`{
"status": "ACTIVE",
"digitalWalletApplication": {
"id": "{{digitalWalletApplicationID}}"
},
"filter": {
"populationIds": [
"{{popID}}"
]
},
"automation": {
"issue": "PERIODIC",
"update": "ON_DEMAND",
"revoke": "ON_DEMAND"
}
}`)
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}}/credentialTypes/{{credentialTypeID}}/issuanceRules HTTP/1.1
Host: {{apiPath}}
Content-Type: application/json
Authorization: Bearer {{accessToken}}
{
"status": "ACTIVE",
"digitalWalletApplication": {
"id": "{{digitalWalletApplicationID}}"
},
"filter": {
"populationIds": [
"{{popID}}"
]
},
"automation": {
"issue": "PERIODIC",
"update": "ON_DEMAND",
"revoke": "ON_DEMAND"
}
}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"status\": \"ACTIVE\",\n \"digitalWalletApplication\": {\n \"id\": \"{{digitalWalletApplicationID}}\"\n },\n \"filter\": {\n \"populationIds\": [\n \"{{popID}}\"\n ]\n },\n \"automation\": {\n \"issue\": \"PERIODIC\",\n \"update\": \"ON_DEMAND\",\n \"revoke\": \"ON_DEMAND\"\n }\n}");
Request request = new Request.Builder()
.url("{{apiPath}}/environments/{{envID}}/credentialTypes/{{credentialTypeID}}/issuanceRules")
.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}}/credentialTypes/{{credentialTypeID}}/issuanceRules",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer {{accessToken}}"
},
"data": JSON.stringify({
"status": "ACTIVE",
"digitalWalletApplication": {
"id": "{{digitalWalletApplicationID}}"
},
"filter": {
"populationIds": [
"{{popID}}"
]
},
"automation": {
"issue": "PERIODIC",
"update": "ON_DEMAND",
"revoke": "ON_DEMAND"
}
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': '{{apiPath}}/environments/{{envID}}/credentialTypes/{{credentialTypeID}}/issuanceRules',
'headers': {
'Content-Type': 'application/json',
'Authorization': 'Bearer {{accessToken}}'
},
body: JSON.stringify({
"status": "ACTIVE",
"digitalWalletApplication": {
"id": "{{digitalWalletApplicationID}}"
},
"filter": {
"populationIds": [
"{{popID}}"
]
},
"automation": {
"issue": "PERIODIC",
"update": "ON_DEMAND",
"revoke": "ON_DEMAND"
}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "{{apiPath}}/environments/{{envID}}/credentialTypes/{{credentialTypeID}}/issuanceRules"
payload = json.dumps({
"status": "ACTIVE",
"digitalWalletApplication": {
"id": "{{digitalWalletApplicationID}}"
},
"filter": {
"populationIds": [
"{{popID}}"
]
},
"automation": {
"issue": "PERIODIC",
"update": "ON_DEMAND",
"revoke": "ON_DEMAND"
}
})
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}}/credentialTypes/{{credentialTypeID}}/issuanceRules');
$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 "status": "ACTIVE",\n "digitalWalletApplication": {\n "id": "{{digitalWalletApplicationID}}"\n },\n "filter": {\n "populationIds": [\n "{{popID}}"\n ]\n },\n "automation": {\n "issue": "PERIODIC",\n "update": "ON_DEMAND",\n "revoke": "ON_DEMAND"\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}}/credentialTypes/{{credentialTypeID}}/issuanceRules")
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({
"status": "ACTIVE",
"digitalWalletApplication": {
"id": "{{digitalWalletApplicationID}}"
},
"filter": {
"populationIds": [
"{{popID}}"
]
},
"automation": {
"issue": "PERIODIC",
"update": "ON_DEMAND",
"revoke": "ON_DEMAND"
}
})
response = http.request(request)
puts response.read_body
let parameters = "{\n \"status\": \"ACTIVE\",\n \"digitalWalletApplication\": {\n \"id\": \"{{digitalWalletApplicationID}}\"\n },\n \"filter\": {\n \"populationIds\": [\n \"{{popID}}\"\n ]\n },\n \"automation\": {\n \"issue\": \"PERIODIC\",\n \"update\": \"ON_DEMAND\",\n \"revoke\": \"ON_DEMAND\"\n }\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "{{apiPath}}/environments/{{envID}}/credentialTypes/{{credentialTypeID}}/issuanceRules")!,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/credentialTypes/8a3a6157-5fb9-40b7-96c0-909331858248/issuanceRules/7888a5ed-ae7b-482c-973d-afd27973099c"
}
},
"id": "7888a5ed-ae7b-482c-973d-afd27973099c",
"createdAt": "2023-03-01T20:29:51.912Z",
"updatedAt": "2023-03-01T20:29:51.912Z",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"credentialType": {
"id": "8a3a6157-5fb9-40b7-96c0-909331858248"
},
"status": "ACTIVE",
"digitalWalletApplication": {
"id": "6815c8a6-bc0b-4105-8f37-50f6c35583d7"
},
"filter": {
"populationIds": [
"e85091a0-ddca-422e-935e-d1faf139df3d"
]
},
"automation": {
"issue": "PERIODIC",
"update": "ON_DEMAND",
"revoke": "ON_DEMAND"
}
}