Calling the Event API
  • 14 Jun 2024
  • 3 Minutes to read
  • Contributors
  • Dark
    Light

Calling the Event API

  • Dark
    Light

Article summary

The API allows adding events to the Darwinium engine and enrichment of a journey with data that is otherwise not scrapable using content extractions. Usecases include:

  • Adding and risk assessing events when operating not on the Edge (Tags Deployment)

  • Receiving the full data associated to a journey or event to make a real-time decision on

  • Logins where additional identity data such as the user's first name and last name are not included in a form post

  • Payments where beneficiary or sender details are missing or provided as IDs and we wish to perform subsequent risk assessment

The additional context provided as part of journey enrichment may be used by other steps in the journey through the use of import dependencies, and the decisions and additional attributes are available through forensics, if an event is recorded.

1.  In Darwinium Portal, create an API step in your journey

Calls to the Darwinium API are bound to a journey and a given step.
To create an API step, open your journey in Darwinium Portal, click the dropdown next to the "+" button on the journey step overview:


Then configure for the API step:

  • Step Name

  • Event Type

  • (optional) Import dependencies: The data from dependencies will be inherited into the step and response. Used for import precomputed scores and signals.

  • (optional) Workflows. Features, Rulesets and Models can be added just like any other step.

Make sure to commit and deploy the changes to the journey.

2. Calling API: To generate an event

Now the API can be called.

a. Authentication: a valid client certificate that has been configured with access to your node. See : Setting up certificates & Access

b. Headers: Input and output is JSON.
Note: If calling the API for enrichment with Darwinium event identifier, it must be specified in the from_identifier Header, not the Body.

  • Content-Type = 'application/json'

  • Accept = 'application/json'

  • from_identifier = '<identifiervalue>'      (optional)

c. URL: The API is called using the POST method to your journey step.

https://<your>-<words>.node.darwinidentity.com:9443/api/event/<journey>/<step>
  • <your>-<words>: This is the two random words assigned to your node's subdomain. They can be retrieved from Darwinium Portal > Admin > Nodes

  • <journey>: This is the journey name specified in configuration of your deployed .journey.yaml file. Note this can be different to the name of the file.

  • <step>: This is the step name you gave in 1. (eg. APICall)


d. Body: The post body consists of a JSON hierarchy of the attributes you wish to include. The Darwinium API Helper can assist with the format of this JSON for the attributes you wish to include.
Example:

{
  "identity": {
    "ACCOUNT": {
      "email": {
        "PERSONAL": {
          "email": "<insert value here>"
        }
      }
    }
  }
}

Using the Darwinium API Helper

As a convenience, the Darwinium journey editor provides a means of quickly assembling API calls in the required format. Simply click Help me construct an API call to this step on the Step Summary tab of an API step, and a new tab should appear with your steps details completed. You are then able to select which attribute(s) you wish to input as part of your API call. Boilerplate is then generated with mock values for each input which can then be used by your integration.

Side-by-side view of the API helper (right) and a corresponding API step in a journey (left)

 

API Assistant anytime

Like other key helpers in Darwinium, the API assistant can be opened any time you are in the workflows editor by opening the command palette (F1) and selecting Darwinium: Start API Helper

3. Calling API: With existing  journey_id or identifier

The journey_id or identifier is required if you wish to provide the enrichment or receive data back within context of a journey that was already initiated.

The Darwinium identifier passes as a Header, not in the Body

To call the API and return data of a specific previous event, the Darwinium identifier value should be added as a Header named: from_identifier.


A useful approach is adding the Darwinium identifier and/or journey_id as a header on existing requests to your downstream service within a Darwinium step.

Inserting Darwinium event identifier as a header named dwnidentifier
Inserting Darwinium journey_id as a header named dwnjourneyid. Note the Journey dependency.

 

Inserting Headers Consideration

When inserting headers, consult your web development team to ensure security policies will expect and permit them

 Examples

 Example API Code



Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence