Skip to main content

Custom APIs in Dynamics 365 CE / CRM / Dataverse

Most Dynamics 365 CE / CRM / Dataverse projects start simple:

  • Plugins on Create/Update
  • Power Automate flows
  • Some JavaScript on forms

Then one day… chaos arrives:

“Where is the business logic implemented?”
Answer: everywhere.

That’s exactly why Custom APIs exist.


🔥 What is a Custom API?

A Custom API is your own Dataverse endpoint.

Instead of updating records directly, you expose a business operation like:

  • ApproveDiscount
  • CreateInvoice
  • ValidateCustomer
  • CloseCaseWithRules

Think of it like building your own “official Dataverse command.”


🧠 Why Custom APIs Are Better Than Plugins (Most of the Time)

Plugins trigger automatically.

Custom APIs trigger intentionally.

That means:

predictable behavior
clean request/response
reusable logic
safe integration pattern


🆚 Custom API vs Plugin (Simple)

Plugin

Custom API

Runs automatically on events

Called explicitly

Hard to control when it runs

Runs only when invoked

Good for enforcement rules

Good for business operations

Often becomes messy over time

Creates clean architecture


🏗 The Enterprise Pattern

Here’s the clean architecture you want:

Instead of:


🚀 Quick Example: Approve Discount API

Requirement:

When sales requests discount approval:

  • validate discount %
  • update opportunity
  • return success/failure message

Instead of a plugin on Opportunity update…

Create a Custom API:

👉 new_ApproveDiscount

Request:

  1. OpportunityId
  2. DiscountPercent
  3. Reason

Response:

  • IsApproved
  • Message

How It Works (Step-by-Step)

1.       Create Custom API in Solution

Power Apps → Solutions → New → Custom API

2.       Add input/output parameters

Just like a real REST endpoint.

3.       Register plugin handler

Your plugin becomes the “backend implementation.”

4.       Call it from anywhere

  • JavaScript
  • Power Automate
  • Azure Function
  • External apps

🔐 Security Advantage 

Custom APIs respect Dataverse security.

So if a user isn’t allowed to approve discounts:
API fails automatically

No extra coding needed.


🏁 Best Practice

Use Custom APIs as the ONLY way external systems modify business-critical records.

This gives you:

  • consistent validation
  • clean audit trail
  • future-proof versioning

Takeaway

Plugins are great for event handling.

But if you want enterprise-grade architecture:

Expose business logic through Custom APIs
Stop letting every system update tables directly

Custom APIs are the difference between:

“It works” and “It scales.”

Comments

Popular posts from this blog

Automation using Azure DevOps for Dynamics 365 CE / CRM / Dataverse

In enterprise Dynamics 365 CE / CRM / Dataverse projects, manual deployments create long-term problems such as: inconsistent releases missing components in Production unmanaged customization pollution deployment failures due to dependencies rollback complexity lack of traceability That is why modern organizations implement Azure DevOps automation for Dynamics 365 CE / CRM using CI/CD pipelines. This blog explains how to architect a complete automation strategy using Azure DevOps for D365 CRM projects. Why Azure DevOps for D365 CRM? Azure DevOps provides: version control (Git repos) build & release pipelines approvals and governance artifact management deployment automation integration with Power Platform tools 📌 Architect Callout If you don’t have CI/CD, you don’t have enterprise ALM. 1. Target ALM Architecture (Enterprise Standard) Recommended Environment Setup A proper CRM ALM environment chain: ...

Solution Layering in Dynamics 365 CE / CRM / Dataverse (Managed vs Unmanaged Explained)

Solution layering is one of the most misunderstood concepts in Dynamics 365 CE / CRM / Dataverse . Many production issues happen because architects and developers don’t fully understand which customization “wins” when multiple solutions modify the same component. This blog explains solution layering in a simple and practical way. ✅ What is Solution Layering? Solution layering means: When multiple solutions modify the same component (form, field, view, etc.), Dataverse decides which customization is applied based on the solution layer order. Every customization sits on a “layer”. 🔥 Types of Layers in D365 There are two major types: 1. Unmanaged Layer Created when you customize directly in the environment Highest priority (usually overrides managed) 2. Managed Layer Created when you import a managed solution Multiple managed solutions can stack on each other 📌 Architect Callout: Unmanaged layer is like “local override”. ...

Architecting Beyond the Box: D365 CE, Power Platform & Azure in the Real World

  Architecting Beyond the Box: D365 CE, Power Platform & Azure in the Real World In most enterprise programs, Dynamics 365 CE and the Power Platform are not the system—they are part of a much larger digital ecosystem. CRM is expected to orchestrate processes, surface insights, integrate with core platforms, and scale with the business. This is where architecture matters more than features. As architects, our job is not to “make it work,” but to make it sustainable . The Common Trap: Overloading the Platform A frequent anti-pattern I see is treating Dataverse and Power Apps as a full replacement for enterprise integration or processing layers: Heavy synchronous plugins for complex business logic Power Automate flows performing batch processing CRM used as a reporting engine Direct point-to-point integrations between systems It works—until it doesn’t. You start seeing: Timeouts in plugins and flows API throttling ...