Domain 5 β€” Module 3 of 9 33%
17 of 26 overall
Domain 5: Extend the Platform Free ⏱ ~12 min read

Custom APIs & Business Events

Create your own Dataverse endpoints that any app, flow, or external system can call. Learn custom API messages, custom API plug-ins, and business events for real-time event publishing.

Creating your own Dataverse operations

Simple explanation

Think of custom APIs as adding new buttons to a universal remote control.

Dataverse comes with built-in operations: Create, Update, Delete, Retrieve. These are like the standard buttons on a TV remote β€” power, volume, channel. But what if you need a β€œCalculate Shipping” button or a β€œValidate Insurance” button? You create a custom API.

A custom API is a new operation you define on Dataverse. You name it, declare what inputs it accepts and what outputs it returns, and wire it to a plug-in that does the actual work. Then anyone β€” apps, flows, external systems β€” can call your API just like they call the built-in Create or Update.

Business events are the flip side: instead of something calling IN to Dataverse, business events let Dataverse push events OUT to other systems when something important happens.

Custom API anatomy

A custom API consists of three parts:

  1. The API definition β€” name, binding type, request parameters, response properties
  2. Request parameters β€” typed inputs the caller sends
  3. Response properties β€” typed outputs the API returns

Creating a custom API

SettingWhat It ControlsExample
Unique NameAPI identifier (used in SDK/Web API calls)nova_CalculateShipping
Display NameHuman-readable nameCalculate Shipping Cost
Binding TypeGlobal (no entity) or Entity-boundGlobal β€” not tied to a specific table
Is FunctionGET (read-only) or POST (action)No (POST β€” it performs a calculation)
Is PrivateHidden from external callersNo β€” ISVs and external systems can call it
Allowed Custom Processing Step TypeSync only, Async only, or BothSync only (caller waits for result)
Plugin TypeThe plug-in that implements the logicNovaSoft.ShippingCalculator

Defining parameters and response

Request Parameters:
  - Weight (Decimal, required)
  - DestinationCode (String, required)
  - Priority (Integer, optional)

Response Properties:
  - Cost (Decimal)
  - EstimatedDays (Integer)
  - TrackingPrefix (String)

Implementing the plug-in

public class CalculateShipping : IPlugin
{
    public void Execute(IServiceProvider serviceProvider)
    {
        var context = (IPluginExecutionContext)
            serviceProvider.GetService(typeof(IPluginExecutionContext));
        
        // Read custom API request parameters
        decimal weight = (decimal)context.InputParameters["Weight"];
        string destination = (string)context.InputParameters["DestinationCode"];
        int priority = context.InputParameters.Contains("Priority") 
            ? (int)context.InputParameters["Priority"] : 1;
        
        // Business logic
        decimal baseCost = weight * 2.5m;
        decimal priorityMultiplier = priority == 1 ? 1.0m : priority == 2 ? 1.5m : 2.0m;
        decimal cost = baseCost * priorityMultiplier;
        int estimatedDays = priority == 3 ? 1 : priority == 2 ? 3 : 5;
        
        // Set custom API response properties
        context.OutputParameters["Cost"] = cost;
        context.OutputParameters["EstimatedDays"] = estimatedDays;
        context.OutputParameters["TrackingPrefix"] = "TRK-" + destination;
    }
}

Calling the custom API

From the Web API (any HTTP client):

POST /api/data/v9.2/nova_CalculateShipping
Content-Type: application/json

{
    "Weight": 25.5,
    "DestinationCode": "NZ-AKL",
    "Priority": 2
}

From a cloud flow: Use the β€œPerform an unbound action” Dataverse connector action.

From C# SDK: service.Execute(new OrganizationRequest("nova_CalculateShipping") { ... });

Business events

Business events let Dataverse broadcast events to external systems when specific operations occur.

How they work

  1. Define a business event on a table (e.g., β€œOrder Approved” on the Order table)
  2. Configure the trigger β€” which message and stage fires the event
  3. Subscribe external systems β€” Azure Service Bus, Event Hub, webhooks
  4. Events publish automatically when the trigger condition is met

Business events vs plug-ins

Business events push outward; plug-ins process internally
FeatureBusiness EventPlug-in
PurposeNotify external systemsExecute custom logic in Dataverse
DirectionOutbound (Dataverse β†’ external)Internal (within Dataverse pipeline)
Custom codeNo code needed for basic eventsC# code required
SubscribersService Bus, Event Hub, webhooksN/A β€” plug-in runs internally
Solution-awareYesYes
Use whenExternal systems need to react to Dataverse changesYou need to validate, enrich, or process data within Dataverse
Question

What is a custom API in Dataverse?

Click or press Enter to reveal answer

Answer

A custom API defines a new message (endpoint) on Dataverse with typed request parameters and response properties. It is backed by a C# plug-in and can be called from apps, flows, Web API, or SDK. It is the modern replacement for custom process actions.

Click to flip back

Question

How do you read request parameters in a custom API plug-in?

Click or press Enter to reveal answer

Answer

Through context.InputParameters: decimal weight = (decimal)context.InputParameters['Weight']. Set response values through context.OutputParameters: context.OutputParameters['Cost'] = calculatedCost. The parameter names must match what you defined in the custom API configuration.

Click to flip back

Question

What is a Dataverse business event?

Click or press Enter to reveal answer

Answer

A business event broadcasts an event to external subscribers (Service Bus, Event Hub, webhooks) when a specific Dataverse operation occurs. No custom C# code is needed β€” you define the event trigger and subscribers. External systems react to the published event.

Click to flip back

Knowledge Check

Elena needs to create an operation that accepts an employee ID and returns their accrued leave balance. The operation must be callable from canvas apps, cloud flows, and an external HR system via REST API. What should she build?

Next up: Custom Connectors: OpenAPI & Authentication β€” wrapping external APIs for Power Platform consumption.