Integration Document

Written By Devin O'Neill ()

Updated at April 15th, 2025

Region

Region Region Id
Europe r1
North America r2
Asia Pacific r3

Categories

  1. Access token
  2. Entity
  3. Contacts
  4. Segments

API for D365 Marketing

Access Token

  • Token is used for security of application. If you want to access API of library then authentication is required. Token is passed in header part of API call.

Get Token API

Method URL
POST: To create a token https://annex.crm.dynamics.com/common/oauth2/token
Header parameter Content-type: application/x-www-form-urlencoded
Post data fields
  1. clientId
  2. clientSecret
  3. authEndPointUrl
  4. username
  5. password
  6. resource


Note: Authorization Type is OAuth 2.0. Need to add an access token for each API execution.

Entity Details

How to Create an Entity into D365 Marketing

  1. Login to a Microsoft Powerapps account.
  2. Navigate to Data >> Tables.
  3. Click on the New Table Button on the left side of the Ribbon. Add Entity Name to the text box.
  4. Copy the name of the created Entity for future use.

The following image shows the tables home screen.

Click on Add Column to add columns to an entity as per the requirements. Add Display Name, Name, Data Type, Required field details.

How to Add/Get Records from an Entity using API

Get Records From Entity

Here, in this API we can pass field names for which we want to get the value & the Top limit records want to fetch from the Entity.

Method URL
GET: To get records from Entity https://annex.crm.dynamics.com/api/data/v9.0/cr0dd_loyaltyactivities? $select=cr0dd_loyaltyid,firstname,lastname,emailaddress1&$top=1000
Header Parameters
  1. authorization: Bearer {{ token }}

Add Records into Entity

Method URL
POST: To add records into Entity https://annex.crm.dynamics.com/api/data/v9.0/cr0dd_loyaltyactivities
Header Parameters
  1. Prefer: return=representation
  2. authorization: Bearer {{ token }}
  3. content-type: application/json

Contacts

Add Contacts

Method URL
POST: To addcontact https://annex.crm.dynamics.com/api/data/v9.0/contacts?$select=contactid,emailaddress1,createdon
Header Parameters
  1. Prefer: return=representation
  2. authorization: Bearer {{ token }}
  3. content-type: application/json

Update Contacts

ContactId i.e. GUID is unique id of the Contact.

Method URL
PATCH: To update contact https://annex.crm.dynamics.com/api/data/v9.0/contacts(contactId)
Header Parameters
  1. authorization: Bearer {{ token }}
  2. content-type: application/json

Get All Contacts

Need to add query & column names for which you want to fetch values for Users.

Method URL
GET: To get all records from Entity https://annex.crm.dynamics.com/api/data/v9.0/contacts $select=cr0dd_loyaltyid,firstname,lastname,emailaddress1
Header Parameters
  1. authorization: Bearer {{ token }}

Get Specific Contact

Need to add a filter & value to get specific records against the filter.

Method URL
GET: To get Specific record from Entity https://annex.crm.dynamics.com/api/data/v9.0/contacts?$filter=emailaddress1  'annextest123@annex.com'
Header Parameters
  1. authorization: Bearer {{ token }}

Sync Contacts from MSD365 to AnnexCloud :


Here, we have Synced Contacts from MSD365 to AnnexCloud. So that, the changes occurred in MSD365 for any Contact will be synced into AnnexCloud end. We have consumed following MSD365 API for the same.

Method URL
GET: Get all contacts as per selection criteria https://annex.crm.dynamics.com/api/data/v9.0/contacts?{{selection criteria}}
Header Parameters
  1. Content-Type: application/json
  2. Authorization: Bearer {{token}}

Segments into MSD365 Marketing

We are working with Dynamic Segments here.

Create Segment

Method URL
POST: Creates a segment within the MSD365 Marketing account https://annex.crm.dynamics.com/api/data/v9.0/msdyncrm_segments
Header Parameters
  1. Content-Type: application/json
  2. Authorization: Bearer {{token}}
Post Data {{data array}}

Update Segment

Method URL
PATCH: Update existing segment https://annex.crm.dynamics.com/api/data/v9.0/msdyncrm_segments({{segment id}})
Header Parameters
  1. Content-Type: application/json
  2. Authorization: Bearer {{token}}
Post Data {{data array}}

Delete Segment

Method URL
DELETE: Delete existing segment https://annex.crm.dynamics.com/api/data/v9.0/msdyncrm_segments({{segment id}})
Header Parameters
  1. Content-Type: application/json
  2. Authorization: Bearer {{token}}

Get Segment List

Method URL
GET: Get lists of segments https://annex.crm.dynamics.com/api/data/v9.0/msdyncrm_segments?{{selection criteria}}
Note: selection criteria means passed fields required in response 
Header Parameters
  1. Content-Type: application/json
  2. Authorization: Bearer {{token}}

Get Segment Details

Method URL
GET: Get lists of segments https://annex.crm.dynamics.com/api/data/v9.0/msdyncrm_segments?{{selection criteria}}
Note: selection criteria means passed filter field (eg. msdyncrm_segmentname eq ‘test’ )
Header Parameters
  1. Content-Type: application/json
  2. Authorization: Bearer {{token}}

Get Members of the Segment

Method URL
POST: Get lists of segments https://annex.crm.dynamics.com/api/data/v9.0/ msdyncrm_FetchContactsByQuery 
Header Parameters
  1. Content-Type: application/json
  2. Authorization: Bearer {{token}}
Post Data {{selection query array}}

Sync Segments From Annex Cloud to Microsoft D365 Marketing

In this use case, we have Consumed MSD API to get Segment List, get Segment Details, get Segment Members & push Segment & members data to Annex Loyalty API.

Sync Segments From Microsoft D365 Marketing to Annex Cloud

In this Use Case, we are fetching Segments & Segments Members from AnnexCloud & pushing the same to MSD 365 by consuming APIs like Add Segment, Update Segment etc.