Webhooks and Session Data and Cloud Secrets
Introduction
This document will describe the steps required to take advantage of placeholder variable substitution when sending Webhooks from TrustX.
Variable substitution is used to generate the webhook headers and body at the time of the webhook execution. This allows for the substitution of variable for secrets or for the inclusion of specific data related to the process instance at the time of execution.
This document will describe the steps required to take advantage of Session Data when sending webhooks from TrustX. For more information on Session Data, see the Session Data page.
Also covered in this document will be utilizing Cloud Secrets within a webhook. For more information on Cloud Secrets, see the Cloud Secrets Guide.
Three scenarios will be covered including the following use cases:
- Sending a webhook using Session Data.
- Sending a webhook using a Cloud Secret in the request body.
- Sending a webhook using a Cloud Secret in the request header.
Webhook and Session Data
Session Data can be included as part of the request body of a webhook. First, follow the steps to create a webhook as outlined in the Webhooks Guide by navigating to the 'Webhooks' tab on the left-navigation bar. On this page, select the orange 'New Webhook' button.

Clicking this button will open the webhook creation page. Enter details about the webhook such as name and description, then select the 'Body' option from the list of available tabs.

Placeholder variables for substitution can be placed anywhere in the body of the webhook. To define a session data placeholder to substitute the placeholder must follow the format {{processvar._myjsonpathexpression_}}"
i.e.
- a prefix of:
{{processvar
. - a JSONPath expression to query the session data
- and a suffix of:
}}
JSONPath is a query language used to navigate and extract data from JSON documents. It provides a way to specify a path expression that points to a specific part of the JSON data, allowing you to retrieve the desired information efficiently.
Webhooks used JSONPath expressions as a way to traverse the 'session data' structure and extract information to include when sending the webhook.
Simple Example:
In this example we include a single piece of information in the webhook - the issuing state name for the document.
{
"issuingStateName": "{{processvar._idDocs[\"doc1\"].currentDocumentCapture.processorResults[\"documentProcessorDocInfo\"].issuingStateName}}"
}
The JSON includes the "issuingStateName"
and the value is evaluated using variable substitution as the value in the format of a placeholder variable: {{processvar.}}
The placeholder variable contains a JSON path expression: _idDocs["doc1"].currentDocumentCapture.processorResults["documentProcessorDocInfo"].issuingStateName
.
The JSONPath expression can be broken down as follows:
_idDocs["doc1"]
: This part points to an Document object with the key"doc1"
inside an object named_idDocs
..currentDocumentCapture
: After finding the Document with the key"doc1"
the expression references the currentDocumentCapture object (DocumentCapture) of the Document..processorResults["documentProcessorDocInfo"]:
Now that we have the DocumentCapture, we are looking for a processing result named "documentProcessorDocInfo"..issuingStateName:
Now that we have the DocumentProcessorDocInfo, we retrieve the object's issuingStateName for inclusion.
When executing the webhook as part of a process definition, the following webhook will be received.
{
{
"issuingStateName": "Ireland",
"trustX": {
"processInstanceId": "BDTLRAN3HKWL7JLQOQ5CSXRMSQ",
"processDefinitionVersion": 5,
"webhookDefinitionVersion": 9,
"processDefinitionName": "JYSEACEZPORWSWOC3TKIGYFQ2I;ac_webhook_test;5",
"processDefinitionId": "JYSEACEZPORWSWOC3TKIGYFQ2I",
"webhookDefinitionId": "PMXT2LGEGLDCPFL6BBMCYIMTHM",
"tenantId": "skydev1",
"webhookDefinitionUrl": "https://typedwebhook.tools/webhook/5a878daa-88bb-42ab-af52-8e9b7d749c63",
"webhookDefinitionName": "webhook-pd-example",
"name": "webhook-pd-example",
"createdDtm": 1691513770208
}
}
Further Examples:
Webhooks variable substitution can index into all of the data included in session data, in the examples below we will look to demonstrate some of the more common use cases:
Including a Complex Type
Variable substitution is not limited to 'leaf' elements such as .issuingStateName
discussed above, complex types can also be included. In the example below we include the document processing 'info' i.e. the general information about the recognized document.
{
"docInfo":"{{processvar._idDocs[\"doc1\"].currentDocumentCapture.processorResults[\"documentProcessorDocInfo\"]}}"
}
The JSON includes the "docInfo"
and the value is evaluated using variable substitution as the value in the format of a placeholder variable: {{processvar.}}
The placeholder variable contains a JSON path expression: _idDocs[\"doc1\"].currentDocumentCapture.processorResults[\"documentProcessorDocInfo\"]
.
The JSONPath expression can be broken down as follows:
_idDocs["doc1"
: This part points to an Document object with the key"doc1"
inside an object named_idDocs
..currentDocumentCapture
: After finding the Document with the key"doc1"
the expression references the currentDocumentCapture object (DocumentCapture) of the Document..processorResults["documentProcessorDocInfo"]:
Now that we have the DocumentCapture, we are looking for a processing result named "documentProcessorDocInfo". The documentProcessorDocInfo provides information about the document that was recognized and some basic attributes of the document.
{
{
"docInfo": {
"type": "Ireland - Driving License (2013)",
"classification": "Driving License",
"expiryDate": "2024-07-11",
"issuedDate": "2014-07-17",
"issuingStateName": "Ireland"
}
"trustX": {
"processInstanceId": "BDTLRAN3HKWL7JLQOQ5CSXRMSQ",
"processDefinitionVersion": 5,
"webhookDefinitionVersion": 9,
"processDefinitionName": "JYSEACEZPORWSWOC3TKIGYFQ2I;ac_webhook_test;5",
"processDefinitionId": "JYSEACEZPORWSWOC3TKIGYFQ2I",
"webhookDefinitionId": "PMXT2LGEGLDCPFL6BBMCYIMTHM",
"tenantId": "skydev1",
"webhookDefinitionUrl": "https://typedwebhook.tools/webhook/5a878daa-88bb-42ab-af52-8e9b7d749c63",
"webhookDefinitionName": "webhook-pd-example",
"name": "webhook-pd-example",
"createdDtm": 1691513770208
}
}
Including a _checks results
Check the result of a specific check can be achieved as follows:
{
"documentQualityOutcome": "{{processvar._checks.visualIntegrity.doc1.front.documentQuality.outcome}}",
}
The JSON includes the "documentQualityOutcome"
and the value is evaluated using variable substitution as the value in the format of a placeholder variable: {{processvar.}}
The placeholder variable contains a JSON path expression: _checks.visualIntegrity.doc1.front.documentQuality.outcome
.
_checks"
: This part points to an checks object (a map of values)..visualIntegrity.doc1.front
: After finding the Checks the expression references thevisualIntegrity.doc1.front
checks..documentQuality.outcome:
Now that we have the checks, we are referencing the outcome of documentQuality check.
When executing the webhook as part of a process definition the following webhook will be received.
{
"documentQualityOutcome": [
"PASS"
],
"trustX": {
"processInstanceId": "BDTLRAN3HKWL7JLQOQ5CSXRMSQ",
"processDefinitionVersion": 5,
"webhookDefinitionVersion": 9,
"processDefinitionName": "JYSEACEZPORWSWOC3TKIGYFQ2I;ac_webhook_test;5",
"processDefinitionId": "JYSEACEZPORWSWOC3TKIGYFQ2I",
"webhookDefinitionId": "PMXT2LGEGLDCPFL6BBMCYIMTHM",
"tenantId": "skydev1",
"webhookDefinitionUrl": "https://typedwebhook.tools/webhook/5a878daa-88bb-42ab-af52-8e9b7d749c63",
"webhookDefinitionName": "Webhook_Example",
"name": "Webhook_Example",
"createdDtm": 1691513770208
}
}
Including Additional Token Parameters in a Webhook
Additional Parameters defined in the creation of a Process Token are accessible from the _initVars
variable.
Additional Parameters can be accessed by using the key of the Additional Parameter. For example, to access the "email' value, users can use:
"tokenInfo": "{{processvar._initVars.params[\"email\"]}}"
The JSON includes the "tokenInfo"
and the value is evaluated using variable substitution as the value in the format of a placeholder variable: {{processvar._initVars.params[\"email\"]}}
_initVars"
: This part points to a _initVars object (a map of values)..params[\"email\"]
: Accesses the parameters of the _initVars object and retrieves the email.
_initVars.params
refers to the Initial Variable parameters. In this case, the "email" parameter can be retrieved and sent from the Webhook.
When the Webhook is sent, the user will receive the following information:
{
"tokenInfo": [
"daon123@gmail.com"
],
"trustX": {
"processDefinitionName": "jfapkfdjsfadpoifsadj",
"webhookDefinitionVersion": 1,
"processDefinitionVersion": 1,
"processInstanceId": "CRRVW2TJAIPDUZ3UDXSMMVAQVI",
"webhookDefinitionName": "web1110b1",
"webhookDefinitionUrl": "https://typedwebhook.tools/webhook/6c8b6073-4f91-4893-a07f-81355937ba25",
"tenantId": "skyqc1",
"webhookDefinitionId": "R2JPCP7OUBS6FQLVB3VM2IT5ZA",
"processDefinitionId": "4QOTXYYJLDKT7UYIX6NCTCJGRY",
"createdDtm": "2023-10-11T10:19:07.692"
}
}
Cloud Secrets in the Request Header
This section will discuss using Cloud Secrets in the request header of a webhook. Navigate to the webhook creation page and select the 'Headers' tab. Click the green 'Add New Header' button to add an additional header key-value pair.

The key represents the variable name. The value will store the Cloud Secret.
Example:
In this example we want to add a Header called X-API-Key
to provide authentication, the secret to be included is selected from the available 'cloud secrets'.

Once all Header entries are set, click the 'Save' button at the bottom-right of the screen to complete the webhook creation.
When executing the webhook as part of a process definition the following webhook headers will be received including the cloud secret set above - X-API-Key:

Note: When setting an Authorization header with a bearer token, the cloud secret value should be set as Bearer {mytoken}.
Cloud Secrets in the Request Body
This section will discuss using Cloud Secrets in the request body of a webhook. Similar to using Session Data with webhooks, Cloud Secrets can be implemented when creating a new webhook and selecting the 'Body' tab.
To use a Cloud Secret in the request body, the format "mysecret": "{{cloudsecret._yoursecret_}}"
is used.
Example:
{
"mysecret": "{{cloudsecret._yoursecret_}}"
}

Once the Body is finalized, click the 'Save' button at the bottom-right of the screen to complete the webhook creation.
When executing the webhook as part of a process definition the following webhook will be received.
Response Example
{
"mysecret": "mySecretValue"
],
"trustX": {
"processInstanceId": "BDTLRAN3HKWL7JLQOQ5CSXRMSQ",
"processDefinitionVersion": 5,
"webhookDefinitionVersion": 9,
"processDefinitionName": "JYSEACEZPORWSWOC3TKIGYFQ2I;ac_webhook_test;5",
"processDefinitionId": "JYSEACEZPORWSWOC3TKIGYFQ2I",
"webhookDefinitionId": "PMXT2LGEGLDCPFL6BBMCYIMTHM",
"tenantId": "skydev1",
"webhookDefinitionUrl": "https://typedwebhook.tools/webhook/5a878daa-88bb-42ab-af52-8e9b7d749c63",
"webhookDefinitionName": "Webhook_Example",
"name": "Webhook_Example",
"createdDtm": 1691513770208
}
}
Testing Webhooks
Various testing tools are available online such as webhook.site and typedwebhook.tools that can be used for testing webhooks. Note that Daon cannot provide support for any third party applications or tools, including the tools listed in this document.