Retrieve outbound marketing interactions for a contact using code

Note

Dynamics 365 Marketing and Dynamics 365 Customer Insights are now Customer Insights - Journeys and Customer Insights - Data. For more information, see Dynamics 365 Customer Insights FAQs

New Customer Insights - Journeys customers receive real-time journeys features only. For more information, see Default real-time journeys installation.

Important

This article only applies to outbound marketing, which will be removed from the product on June 30, 2025. To avoid interruptions, transition to real-time journeys before this date. More information: Transition overview

Important

The method below to retrieve interactions has been deprecated and may not be available in the future.

To retrieve interaction data, the current recommended method is to set up Azure Blob storage and connect it to the Dynamics 365 Customer Insights - Journeys app. Learn more: Prepare for analytic reporting with Power BI

Use the msdyncrm_LoadInteractionsPublic action to programmatically retrieve interactions for a contact. This action is useful for responding to get-my-data requests to comply with various privacy laws and regulations.

Tip

You can also generate request and response classes for this action to include in your application code. More information: Generate early-bound types for an action

Action parameters

The msdyncrm_LoadInteractionsPublic action expects the following input parameters:

Name Type Description
ContactId Edm.String ID of the contact record to retrieve the interactions for. Required.
DateFrom Edm.String Start date in the MM-DD-YYYY format from which you want to retrieve interactions. Optional.
DateTo Edm.String End date in the MM-DD-YYYY format until which you want to retrieve interactions. Optional.
InteractionType Edm.String Type of interaction to be retrieved. Required.
You can specify one of the following values:
  • ActivityContactBlocked
  • ActivityContactDispatched
  • ActivityContactProcessingFailed
  • CreateCrmActivityContactProcessed
  • CreateCustomChannelActivityContactProcessed
  • CustomChannelResponse
  • CustomerJourneyContactRecordUpdated
  • EmailBlockBounced
  • EmailBlocked
  • EmailClicked
  • EmailContainsBlockListedLinks
  • EmailDelivered
  • EmailFeedbackLoop
  • EmailForwarded
  • EmailHardBounced
  • EmailOpened
  • EmailSendingFailed
  • EmailSent
  • EmailSoftBounced
  • EmailSubscriptionSubmit
  • EventCheckIn
  • EventRegistration
  • FormSubmitted
  • FormVisited
  • InvalidRecipientAddress
  • InvalidSenderAddress
  • LeadScoreBoost
  • OutOfEmailCredits
  • PassThroughActivityContactProcessed
  • RedirectLinkClicked
  • SchedulerActivityContactProcessed
  • SegmentRelationshipEdited
  • SegmentSubscribed
  • SegmentUnsubscribed
  • SplitterActivityContactProcessed
  • SurveyResponse
  • TriggerActivityContactProcessed
  • TriggerCrmWorkflowActivityContactProcessed
  • WebsiteClicked
  • WebsiteVisited
Top Edm.Int32 Optional. Non-negative integer that limits the number of interactions returned for a contact record. Optional.
SkipToken Edm.String Identifies a starting point in the collection of interactions returned for a contact record. Optional.

Action return type

The msdyncrm_LoadInteractionsPublic action returns the following value:

Name Type Description
msdyncrm_LoadInteractionsPublicResponse ComplexType Contains the response from msdyncrm_LoadInteractionsPublic action. It contains the following properties that contain the structured data of the type:
Name Type Description
Data Edm.String List of interactions as an escaped JSON array.
NextSkipToken Edm.String Identifies the next cursor or bookmark in the collection of interactions returned for a contact record.

Example

Request

POST [Organization URI]/api/data/v9.0/msdyncrm_LoadInteractionsPublic HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
  
{
    "InteractionType": "WebsiteClicked",
    "ContactId": "33dd33dd-ee44-ff55-aa66-77bb77bb77bb",
}

Response

The response contains a JSON object with a Data property containing the full list of interactions.

HTTP/1.1 200 OK  
Content-Type: application/json; odata.metadata=minimal  
OData-Version: 4.0

{
    "@odata.context":"[Organization URI]/api/data/v9.0/$metadata#Microsoft.Dynamics.CRM.msdyncrm_LoadInteractionsPublicResponse",
    "Data":"[{\"InteractionId\":\"172C1E59A3CD4D85B392316DD76651CE\",\"InteractionType\":\"EmailSent\",\"Timestamp\":\"2018-02-23T13:10:48Z\",\"OrganizationId\":\"00aa00aa-bb11-cc22-dd33-44ee44ee44ee\",\"EmailDomain\":\"microsoft.com\",\"ActivityId\":\"11bb11bb-cc22-dd33-ee44-55ff55ff55ff\",\"SendingId\":\"22cc22cc-dd33-ee44-ff55-66aa66aa66aa\",\"ContactId\":\"33dd33dd-ee44-ff55-aa66-77bb77bb77bb\",\"MessageId\":\"44ee44ee-ff55-aa66-bb77-88cc88cc88cc\",\"CustomerJourneyId\":\"55ff55ff-aa66-bb77-cc88-99dd99dd99dd\",\"CustomerJourneyIterationId\":\"66aa66aa-bb77-cc88-dd99-00ee00ee00ee\",\"UsageType\":\"CustomerJourney\",\"EmailAddressUsed\":\"[email protected]\"}]",
    "NextSkipToken":null
}