Back

Dynamics 365 CRM API Essential Guide

Aug 2, 20246 minute read

What type of API does Dynamics 365 CRM provide?

Dynamics 365 CRM offers multiple types of APIs for developers to interact with the system. The main types of APIs available for Dynamics 365 CRM are:

  1. REST API (Web API)

The primary and most modern API for Dynamics 365 CRM is the REST-based Web API. This API provides a RESTful interface for interacting with Dynamics 365 data and metadata. Key points about the Web API include:

  • It uses OData v4 protocol
  • Supports JSON and OData Atom formats
  • Provides a consistent programming experience across all Dynamics 365 Customer Engagement apps
  • Recommended for new development projects
  1. SOAP API (Organization Service)

While less modern, the SOAP-based Organization Service is still available and supported. Some key points about the Organization Service:

  • Uses SOAP protocol
  • Primarily used for older integrations or specific scenarios
  • Still supported but not recommended for new development
  1. SDK APIs

Dynamics 365 also provides Software Development Kit (SDK) APIs for various programming languages, which often wrap the Web API or Organization Service. These include:

  • .NET SDK
  • JavaScript/TypeScript SDK for web resource development

Does the Dynamics 365 CRM API have webhooks?

Availability of Webhooks

The Dynamics 365 CRM API supports webhooks, introduced in Dynamics 365 for Customer Engagement apps version 9.0.

Types of Events

You can subscribe to various server events using webhooks, including:

  • Entity create, update, and delete events (e.g., updating a contact entity)
  • Custom events triggered by plugins or custom workflow activities

Key Features and Considerations

  1. Webhooks enable integration of Dynamics 365 data with custom code hosted on external services.

  2. They use a lightweight HTTP pattern with a publish/subscribe model.

  3. Authentication options include:

    • HttpHeader: Key-value pairs in the request header
    • WebhookKey: A query string parameter
    • HttpQueryString: Key-value pairs as query string parameters
  4. Webhooks can be used for both synchronous and asynchronous steps.

  5. They send POST requests with JSON payloads consumable by any programming language or web application.

  6. Scalability considerations:

    • Azure Service Bus is better for high-scale processing with full queueing mechanisms
    • Webhooks can scale to the point where your hosted web service can handle the messages

Implementation and Testing

  1. To implement webhooks:

    • Create or configure a service to consume webhook requests
    • Register webhook steps on the Dynamics 365 service
    • Optionally, invoke webhooks from plugins or custom workflow activities
  2. Test webhook registrations using request logging sites like RequestBin before implementing your own service.

  3. Register and test webhooks using the plugin registration tool.

Rate Limits and other limitations

Here are the key points about the API Rate Limits for the Dynamics 365 CRM API:

Service Protection API Limits

  • Microsoft applies limits to API usage to ensure consistent availability and performance for all users.

  • The limits are designed to detect when client applications are making extraordinary demands on server resources.

  • Normal users of interactive clients should not be affected. Only client applications performing extraordinary API requests will be impacted.

How Limits are Enforced

  • Two of the service protection API limits are evaluated within a 5 minute (300 second) sliding window.

  • Limits are enforced per user. Each authenticated user is limited independently.

  • Limits are based on three factors:

    1. Number of requests sent by a user
    2. Combined execution time to process requests
    3. Number of concurrent requests sent by a user

Specific Limits

For Dynamics 365 CRM (Dataverse), the default limits are:

  • Number of requests: 6,000 within a 5-minute sliding window
  • Execution time: 20 minutes (1,200 seconds) within a 5-minute sliding window
  • Number of concurrent requests: 52

Other Key Points

  • Limits are enforced per user, per application ID, per web server.

  • When limits are exceeded, a 429 Too Many Requests error is returned.

  • Certain services like Document Routing Agent, Retail Server API, etc. are currently exempt from these limits.

  • Resource-based limits are also enforced based on overall environment resource utilization.

  • Limits may vary between environments and are subject to change.

Best Practices

  • Consider strategies like decreasing records selected in lists or using batch operations to avoid hitting limits.

  • Monitor API usage to track throttling.

  • Be prepared to handle 429 errors and implement retry logic with backoff.

In summary, while normal interactive usage should not be affected, applications making high-volume API calls need to be designed with these limits in mind to ensure smooth operation within the Dynamics 365 CRM environment.

Latest API Version

The most recent version of the Dynamics 365 CRM API is version 9.2, which was released in October 2021 as part of the 2021 release wave 2. This version introduced several new features and improvements to the Dynamics 365 Customer Engagement platform.

Key points to consider:

• The Dynamics 365 CRM API is part of the broader Dynamics 365 Customer Engagement platform.

• Microsoft regularly updates the API to introduce new features, improve performance, and enhance security.

• Version 9.2 includes updates to the Web API, which is the RESTful API for interacting with Dynamics 365 data.

• Developers should always refer to the official Microsoft documentation for the most up-to-date information on API versions and features.

Best practices:

  1. Stay informed about new releases and updates to ensure you're using the latest features and security improvements.

  2. When developing applications that integrate with Dynamics 365 CRM, always use the most recent stable version of the API to take advantage of new capabilities and optimizations.

  3. Be aware of any deprecated features or changes in newer versions that might affect your existing integrations.

  4. Regularly review your API usage and update your applications to align with the latest best practices and performance recommendations provided by Microsoft.

It's important to note that while version 9.2 is the most recent major release, Microsoft may have released minor updates or patches since then. Always check the official Microsoft documentation for the most current information on API versions and features.

How to get a Dynamics 365 CRM developer account and API Keys?

To get a developer account for Dynamics 365 CRM and create an API integration, you'll need to follow these steps:

  1. Sign up for a Microsoft 365 Developer Program:

    • Visit the Microsoft 365 Developer Program website
    • Click on "Join now" and sign in with your Microsoft account
    • Complete the registration process
  2. Set up a Developer sandbox environment:

    • Once registered, you'll have access to a free Developer sandbox
    • This sandbox includes Dynamics 365 apps and sample data
  3. Enable the Dynamics 365 CRM app:

    • In your Developer sandbox, navigate to the Admin center
    • Find and enable the Dynamics 365 Customer Engagement app
  4. Create an Azure Active Directory (AAD) application:

    • Go to the Azure portal
    • Navigate to Azure Active Directory > App registrations
    • Create a new application registration
  5. Configure API permissions:

    • In your AAD application, go to API permissions
    • Add the necessary Dynamics 365 CRM API permissions
  6. Obtain API credentials:

    • In your AAD application, find the Application ID and Directory ID
    • Generate a client secret
  7. Set up your development environment:

    • Choose your preferred programming language and tools
    • Install the necessary SDKs or libraries for Dynamics 365 CRM integration

What can you do with the Dynamics 365 CRM API?

Here are the key data models you can interact with using the Dynamics 365 CRM API, along with what is possible for each:

Entity

  • Create, read, update, and delete entity records
  • Query and filter entity data
  • Perform operations on multiple records in bulk
  • Retrieve metadata about entity definitions

Possible operations:

  • CRUD operations on records
  • Complex queries and filtering
  • Bulk create/update/delete
  • Retrieve entity metadata

Attribute

  • Read attribute metadata and definitions
  • Create, update, and delete custom attributes
  • Set and retrieve attribute values on records

Possible operations:

  • Get attribute metadata
  • Create/update/delete custom attributes
  • Set/get attribute values

Relationship

  • Create, read, update, and delete entity relationships
  • Associate and disassociate related records
  • Query related records

Possible operations:

  • CRUD operations on relationships
  • Associate/disassociate records
  • Query related data

Option Set

  • Create, read, update, and delete option sets
  • Retrieve option set metadata
  • Get/set option set values on records

Possible operations:

  • CRUD operations on option sets
  • Get option set metadata
  • Set/get option values

Business Process Flow

  • Create, read, update, and delete business process flows
  • Activate/deactivate process flows
  • Move records through process stages

Possible operations:

  • CRUD operations on process flows
  • Activate/deactivate flows
  • Progress records through stages

Security Model

  • Create, read, update, and delete security roles
  • Assign/remove security roles from users
  • Set field-level security

Possible operations:

  • CRUD operations on security roles
  • Manage role assignments
  • Configure field security

Metadata

  • Retrieve metadata about entities, attributes, relationships etc.
  • Create and update custom metadata
  • Query metadata definitions

Possible operations:

  • Get metadata definitions
  • Create/update custom metadata
  • Query metadata

The API provides comprehensive access to interact with and manipulate the core data models and structures within Dynamics 365 CRM. This allows for extensive customization and integration capabilities.