IntegrationsMicrosoft Dynamics 365

Microsoft Dynamics 365 Integration

Connect Ledly to Microsoft Dynamics 365 to automatically sync leads. This guide walks you through registering an Azure AD application and authorizing Ledly.

Dynamics 365 uses the native Lead entity. Ledly syncs directly to the lead entity using the OData 4.0 Web API.

Prerequisites

  • Microsoft Dynamics 365 Sales license
  • Azure Active Directory (Azure AD) admin access
  • Dynamics 365 System Administrator or Customizer role
  • Ledly Education or Enterprise plan

Step 1: Register an Azure AD Application

  1. Go to the Azure Portal
  2. Navigate to Azure Active Directory -> App registrations
  3. Click New registration

Application Registration

FieldValue
NameLedly Integration
Supported account typesAccounts in this organizational directory only
Redirect URI (Web)https://api.ledly.io/api/dynamics/callback
  1. Click Register

Step 2: Configure API Permissions

  1. On your app registration page, click API permissions
  2. Click Add a permission
  3. Select Dynamics CRM
  4. Select Delegated permissions
  5. Check user_impersonation
  6. Click Add permissions
  7. Click Grant admin consent for [Your Organization]
⚠️

Admin consent is required. Without it, users will see an “Access Denied” error when connecting.


Step 3: Create a Client Secret

  1. On your app registration page, click Certificates & secrets
  2. Click New client secret
  3. Enter a description: Ledly Integration Secret
  4. Select an expiration period (recommended: 24 months)
  5. Click Add
  6. Immediately copy the secret value - it won’t be shown again
🚫

Security Note: Copy the secret value now. After leaving this page, you cannot retrieve it. You’ll need to create a new secret if lost.


Step 4: Get Your Application Details

Collect these values from your Azure AD app registration:

FieldLocation
Application (client) IDOverview page
Directory (tenant) IDOverview page
Client SecretCertificates & secrets (copied in Step 3)
Dynamics URLYour Dynamics environment URL (e.g., https://yourorg.crm.dynamics.com)

Finding Your Dynamics URL

  1. Log in to Power Platform Admin Center
  2. Go to Environments
  3. Select your environment
  4. Copy the Environment URL

Step 5: Configure Application User in Dynamics

For server-to-server authentication, create an Application User:

  1. Go to your Dynamics 365 environment
  2. Navigate to Settings -> Security -> Users
  3. Switch the view to Application Users
  4. Click New
FieldValue
User Name[email protected]
Application IDYour Azure AD Application (client) ID
Full NameLedly Integration
Primary Email[email protected]
  1. Click Save
  2. Click Manage Roles
  3. Assign the Salesperson role (or a custom role with Lead permissions)

The Application User allows Ledly to authenticate without a specific user’s credentials, providing more reliable server-to-server integration.


Step 6: Enter Credentials in Ledly

  1. Log in to Ledly at app.ledly.io
  2. Go to Settings -> CRM Integration
  3. Select Microsoft Dynamics 365 as your CRM
  4. Enter your credentials:
FieldValue
Tenant IDYour Azure AD Directory (tenant) ID
Client IDYour Azure AD Application (client) ID
Client SecretYour client secret
Dynamics URLYour environment URL (e.g., https://yourorg.crm.dynamics.com)
  1. Click Save Credentials
  2. Click Connect with Dynamics 365
  3. Sign in with your Microsoft account when prompted

Once connected, you’ll see the connection status and your Dynamics organization ID on the CRM settings page.


Step 7: Map Fields to Dynamics

After connecting, configure how Ledly fields map to your Dynamics Lead entity.

  1. Go to Settings -> CRM Integration -> Field Mapping
  2. For each Ledly field, select the corresponding Dynamics field
  3. Click Save Mapping

Standard Field Mappings

Ledly FieldDynamics Lead FieldSchema Name
emailEmailemailaddress1
first_nameFirst Namefirstname
last_nameLast Namelastname
phoneBusiness Phonetelephone1
companyCompany Namecompanyname
job_titleJob Titlejobtitle
addressStreet 1address1_line1
cityCityaddress1_city
stateState/Provinceaddress1_stateorprovince
zipZIP/Postal Codeaddress1_postalcode
countryCountry/Regionaddress1_country

Lead Status Mapping

Ledly maps lead statuses to Dynamics Lead State and Status:

Ledly StatusDynamics StateDynamics Status Reason
newOpenNew
contactedOpenContacted
qualifiedQualifiedQualified
disqualifiedDisqualifiedLost

Custom Field Mappings

Map Ledly custom fields to your Dynamics custom fields:

Ledly FieldDynamics FieldSchema Name
program_codeProgram Interestnew_programinterest
start_datePreferred Start Datenew_preferredstartdate
utm_sourceLead Source Detailnew_leadsourcedetail
⚠️

Field mapping must be configured before leads will sync to Dynamics. Unmapped fields will not be sent.

For detailed mapping options, see the Field Mapping Guide.


Bidirectional Sync

Ledly supports bidirectional sync with Dynamics 365, keeping data consistent across both platforms.

Ledly to Dynamics

When a lead is created or updated in Ledly:

  1. Ledly checks if a Lead with matching email exists in Dynamics
  2. If found, the existing Lead is updated
  3. If not found, a new Lead is created
  4. A custom ledly_leadid field stores the Ledly ID for tracking

Dynamics to Ledly

When a Lead is updated in Dynamics:

  1. Dynamics sends a webhook notification via Power Automate
  2. Ledly matches the Lead by ledly_leadid or email
  3. Mapped fields are updated in Ledly
  4. Conflict resolution uses “last write wins” by default

Sync Frequency

DirectionTriggerLatency
Ledly -> DynamicsImmediate on save< 5 seconds
Dynamics -> LedlyWebhook (Power Automate)< 30 seconds
Full syncScheduledEvery 4 hours

Status Tracking

Ledly tracks the sync status for each lead:

StatusDescription
syncedSuccessfully synced to Dynamics
pendingQueued for sync
failedSync failed (see error details)
not_mappedNo field mapping configured

View sync status in Ledly:

  1. Go to Leads -> Select a lead
  2. Click the CRM Sync tab
  3. View sync history and any error messages

Webhook Configuration (Power Automate)

For real-time updates from Dynamics to Ledly, set up a Power Automate flow:

Step 1: Create a Power Automate Flow

  1. Go to Power Automate
  2. Click Create -> Automated cloud flow
  3. Name your flow: Ledly Lead Sync
  4. Select trigger: When a row is added, modified or deleted (Microsoft Dataverse)

Step 2: Configure the Trigger

FieldValue
Change typeAdded or Modified
Table nameLeads
ScopeOrganization

Step 3: Add HTTP Action

  1. Click New step
  2. Search for HTTP
  3. Configure the action:
FieldValue
MethodPOST
URIhttps://api.ledly.io/api/dynamics/webhook
HeadersContent-Type: application/json
BodySee below

Webhook Body:

{
  "leadid": "@{triggerOutputs()?['body/leadid']}",
  "emailaddress1": "@{triggerOutputs()?['body/emailaddress1']}",
  "firstname": "@{triggerOutputs()?['body/firstname']}",
  "lastname": "@{triggerOutputs()?['body/lastname']}",
  "telephone1": "@{triggerOutputs()?['body/telephone1']}",
  "modifiedon": "@{triggerOutputs()?['body/modifiedon']}"
}

Step 4: Add Authentication Header

  1. In the HTTP action, expand Advanced options

  2. Add header: X-Ledly-Webhook-Secret

  3. Value: Your Ledly webhook secret (found in Settings -> Webhooks)

  4. Click Save

Power Automate flows may have execution limits based on your Microsoft 365 license. For high-volume scenarios, consider using Azure Functions.


Rate Limits

Dynamics 365 enforces API rate limits that Ledly respects:

Limit TypeValue
Per user6,000 requests per 5 minutes
Per organization60,000 requests per 5 minutes
Concurrent requests52 per user
⚠️

Large bulk imports may be throttled. Use Ledly’s batch import feature which automatically handles rate limiting.

Token Expiration

  • Access tokens expire after 1 hour
  • Ledly automatically refreshes tokens before expiration
  • Refresh tokens expire after 90 days of inactivity

Troubleshooting

”AADSTS700016: Application Not Found” Error

  • Verify the Application (client) ID is correct
  • Ensure the app registration is in the correct Azure AD tenant
  • Check that the app hasn’t been deleted
  • Admin consent hasn’t been granted for the app
  • Go to Azure AD -> App registrations -> API permissions
  • Click Grant admin consent

”Unauthorized” or “403 Forbidden” Error

  • The Application User may not have the correct security role
  • Verify the user has the Salesperson role or Lead permissions
  • Check that the user is enabled in Dynamics

”Resource Not Found” Error

  • Verify the Dynamics URL is correct (no trailing slash)
  • Ensure you’re using the correct environment URL
  • Check that the Lead entity exists and is accessible

Leads Not Syncing

  1. Check that field mapping is configured
  2. Verify the Application User has Lead create/update permissions
  3. Check the lead’s CRM Sync tab for error details
  4. Ensure Dynamics API limits haven’t been exceeded

Token Refresh Failures

  • Client Secret may have expired
  • Create a new secret in Azure AD and update in Ledly
  • Check that the app registration hasn’t been modified

Power Automate Flow Errors

  1. Check the flow run history for errors
  2. Verify the HTTP action URL is correct
  3. Ensure the webhook secret header is included
  4. Check that required fields are included in the body

Security Best Practices

  1. Rotate client secrets - Azure AD secrets expire. Create a new secret before expiration and update in Ledly
  2. Use least privilege - Grant only the permissions Ledly needs
  3. Monitor sign-in logs - Review Azure AD sign-in logs for unusual activity
  4. Enable conditional access - Consider restricting app access to specific IP ranges
  5. Revoke if compromised - If credentials are exposed, immediately regenerate the client secret

Revoking Access

In Ledly

  1. Go to Settings -> CRM Integration
  2. Click Disconnect

In Azure AD

  1. Go to the Azure Portal
  2. Navigate to Azure Active Directory -> App registrations
  3. Find Ledly Integration
  4. Click Delete

In Dynamics 365

  1. Go to Settings -> Security -> Users
  2. Switch view to Application Users
  3. Find and disable or delete the Ledly Application User

Support

If you encounter issues:

  • Email: [email protected]
  • Include your Dynamics organization ID (Settings -> Customizations -> Developer Resources)
  • Include your Azure AD tenant ID
  • Do NOT send credentials via email