The Pega Digital Experience (DX) API provides a set of model-driven REST API endpoints that enable developers to programmatically view, create, and update cases and assignments. This API is particularly useful for web self-service use cases, where it is important to align your user experience with your digital strategy while continuing to enable your business users to define and modify your application cases and user interface within Pega’s low-code model.
Before you start, ensure you have:
To access the Pega DX API in Pega Infinity or Pega Launchpad, you need to authenticate your requests. This typically involves setting up an authentication profile and resource path.
In Pega Infinity, navigate to the case type you want to use. On the Settings tab, click Integration, and under Microservice APIs, click Generate create case microservice code. This will generate the necessary code and data transforms.
The request body for creating a case typically includes the case type ID, process ID, parent case ID, and content. The content node should contain the required fields for the case.
Example Request Body:
{
"caseTypeID": "YourCaseTypeID",
"processID": "",
"parentCaseID": "",
"content": {
"FieldName1": "Value1",
"FieldName2": "Value2"
}
}
After preparing the JSON, add the request body fields to the “Allow Starting Fields” section.
Before making the API call, generate an access token using your client credentials.
Example Token Request:
https://<Your_Pega_Auth_Domain>/oauth/tokenPOSTContent-Type: application/x-www-form-urlencodedclient_id=<YOUR_CLIENT_ID>client_secret=<YOUR_CLIENT_SECRET>grant_type=client_credentialsExample Token Response:
{
"access_token": "YourAccessToken",
"token_type": "Bearer",
"expires_in": 3600
}
Use the generated request URL, HTTP authentication header, and request body to make the API call in Pega Infinity or Pega Launchpad. Here’s an example of how to make the API call:
Example API Call:
https://<Application_Url>/api/application/v2/caseshttps://<Application_Name>–<Subscriber_Name>.<Custom_Provider_Domain>/api/application/v2/casesRequest:
POSTAuthorization: Bearer <YourAccessToken>Content-Type: application/jsonBody:
{
"caseTypeID": "YourCaseTypeID",
"processID": "",
"parentCaseID": "",
"content": {
"FieldName1": "Value1",
"FieldName2": "Value2"
}
}
After making the API call, verify that the case has been created successfully in Pega Infinity or Pega Launchpad. Retrieve the etag value from the response headers for future reference.
201 Created and a body containing the case details.If the request body includes complex data types, you can use a PATCH call with embedded data to handle these scenarios.
Example Embed Data Call:
https://<Application_Name>–<Subscriber_Name>.<Custom_Provider_Domain>/dx/api/application/v2/cases/<CASE_ID>/actions/<VIEW_ID>?viewType=formPATCHIf-Match: <etag>Content-Type: application/jsonBody:
Certainly! Here’s the JSON with comments and explanations of the operations happening:
{
"content": {}, // Main content of the case
"pageInstructions": [ // Instructions for updating the page content
{
"target": ".Arms", // Targeting the Arms node in the case structure
"content": {}, // Content to be inserted
"listIndex": 1, // Position where the content will be inserted in the list
"instruction": "INSERT" // Operation to be performed: INSERT (adding a new item)
},
{
"target": ".Arms", // Targeting the Arms node
"content": {
"ArmGroupLabel": "Group A" // Label for the arm group
},
"listIndex": 1,
"instruction": "UPDATE" // Operation to be performed: UPDATE (modifying an existing item)
},
{
"target": ".Arms(1).Visits", // Targeting the Visits node within the first Arms element
"content": {}, // Content to be inserted
"listIndex": 1,
"instruction": "INSERT" // Operation to be performed: INSERT (adding a new visit)
},
{
"target": ".Arms(1).Visits", // Targeting the Visits node within the first Arms element
"content": {
"VisitName": "Initial Consultation", // Name of the visit
"Category": "Screening", // Category of the visit
"Duration": "30", // Duration of the visit
"DurationType": "Day", // Type of duration
"Notes": "Initial consultation to discuss the procedure." // Additional notes about the visit
},
"listIndex": 1,
"instruction": "UPDATE" // Operation to be performed: UPDATE (modifying the details of the visit)
},
{
"target": ".Arms(1).Visits(1).ProcedureList", // Targeting the ProcedureList node within the first Visit of the first Arms element
"content": {}, // Content to be inserted
"listIndex": 1,
"instruction": "INSERT" // Operation to be performed: INSERT (adding a new procedure)
},
{
"target": ".Arms(1).Visits(1).ProcedureList", // Targeting the ProcedureList node within the first Visit of the first Arms element
"content": {
"ProcedureName": "Blood Test", // Name of the procedure
"ProcedureCost": "100", // Cost of the procedure
"Notes": "Basic blood test to check overall health." // Additional notes about the procedure
},
"listIndex": 1,
"instruction": "UPDATE" // Operation to be performed: UPDATE (modifying the details of the procedure)
}
]
}
.Arms.ArmsArmGroupLabel to “Group A”..Arms(1).Visits.Arms(1).VisitsVisitName, Category, Duration, DurationType, and Notes..Arms(1).Visits(1).ProcedureList.Arms(1).Visits(1).ProcedureListProcedureName, ProcedureCost, and Notes.Each of these operations is designed to either add new data (INSERT) or modify existing data (UPDATE) within the case structure, ensuring the case data is accurately maintained and updated as needed.
For more detailed information, refer to the Pega DX API Documentation.
If you encounter any issues, check the following:
Using the Pega DX API in Pega Infinity and Pega Launchpad, you can create cases programmatically, aligning your user experience with your digital strategy while leveraging Pega’s powerful case management capabilities.