User authentication using events API

Note

On September 1, 2023, Dynamics 365 Marketing and Dynamics 365 Customer Insights began to be sold together under a single product SKU called Dynamics 365 Customer Insights. The individual applications have been renamed Dynamics 365 Customer Insights - Journeys and Dynamics 365 Customer Insights - Data, respectively. For more information, see Dynamics 365 Customer Insights FAQs

Starting on September 1, 2023, new Customer Insights - Journeys customers receive real-time journeys features only. For more information, see Default real-time journeys installation. Many documentation pages currently refer to outbound features that may not be available or may work differently in real-time journeys. The documentation content is being updated to note whether it applies to real-time journeys or outbound marketing.

The events API supports user authentication with Microsoft Entra ID. To link the events API to your Microsoft Entra ID, you need to add your Microsoft Entra ID Client ID and Microsoft Entra ID Metadata Endpoint to your web application setting. More information: Creating a Microsoft Entra ID tenant and adding a web application to the tenant

To authenticate the user against the API, you need to add the Authorization header containing the token_id bearer to each API request.

This token_id can be retrieved by authenticating the user against Microsoft Entra ID.

Request

curl -X GET \ 
  'https:// b7c1ad1ab7fa4a7482b16315d94a26af.svc-tip.dynamics.com/EvtMgmt/api/v2.0/events/published?emApplicationtoken=VZsLZhx251OM9uJa..' \ 
  -H 'Authorization: Bearer eyJ0eXAiOiJK…\ 
  -H 'Origin: https://localhost:4200' 

Contact matching strategy

The events API will automatically try to link contacts from Microsoft Entra ID to the contacts in Dynamics 365 Customer Insights - Journeys.

To do so, it uses a contact matching strategy that can be configured in the event administration settings. By default, first name, last name, and email are used as the contact matching strategy. More information: Event administration

In case no matching contact is found, a new contact is created automatically.

Note

Linked contact entities contain an attribute called msevtmgt_aadobjectid that stores the object ID of the user in Microsoft Entra ID.

Retrieving information of authenticated user

The events API provides an endpoint that returns the information and contact ID of the authenticated user.

Request

curl -X GET \
  'https:// b7c1ad1ab7fa4a7482b16315d94a26af.svc-tip.dynamics.com/EvtMgmt/api/v2.0/users/authenticated?emApplicationtoken=VZsLZhx251OM9uJa..' \
  -H 'Authorization: Bearer eyJ0eXAiOiJK…\ 
  -H 'Origin: https://localhost:4200'

Response

{
   "id":"05ef77de-b882-e911-a970-000d3a4e9aa0",
   "firstName":"John",
   "lastName":"Doe",
   "email":"joe.doe@contoso.com",
   "isAnonymous":false
}