Microsoft Entra app registration (Azure App registration)

Prev Next

This article describes how to register an application in Microsoft Entra ID (formerly Azure Active Directory) and set it up in Business Central, so that an external system can call the Business Central APIs with OAuth 2.0 service-to-service (client credentials) authentication.

Prerequisites

  • To register the application – a Microsoft Entra user who is allowed to register applications (Application Developer, Application Administrator or Cloud Application Administrator role, unless all users are allowed to register applications in your tenant);

  • To grant admin consent – a Microsoft Entra user with the Global Administrator, Privileged Role Administrator, Cloud Application Administrator or Application Administrator role;

  • To set up the application in Business Central – a Business Central user who can manage users and permissions (e.g. with the SUPER or SECURITY permission set).

Create a separate application for each integrating system. Then access can be granted, limited and revoked for each integration separately.

1. Register the application in Microsoft Entra ID (Azure AD)

Sign in to the Microsoft Entra admin center (entra.microsoft.com) or the Azure portal (portal.azure.com) and search for App registrations:

Click New registration:

Fill in the fields:

  • Name – a descriptive name of the application, e.g. the name of the integrating system;

  • Supported account types – select Accounts in this organizational directory only (Single tenant);

  • Redirect URI – select the Web platform and enter https://businesscentral.dynamics.com/OAuthLanding.htm.

Redirect URI

Add the Web redirect URI below. Business Central needs it for the Grant Consent button on the Microsoft Entra Application Card (step 2). Without it, consent can only be granted in the Microsoft Entra admin center.

https://businesscentral.dynamics.com/OAuthLanding.htm

Click Register. Then open API permissions and click Add a permission:

There are two types of API permissions: Delegated permissions and Application permissions.

  • Delegated permissions – the application acts on behalf of a signed-in user. The user signs in with their Microsoft account, the application gets that user's permissions, and every action is recorded as the user's action;

  • Application permissions – the application acts as itself, without a signed-in user (service-to-service). They are used by integrations that run in the background. The application is not linked to any Microsoft user account and authenticates with its Application (client) ID and client secret.

Integrations that get the access token with the Client Credentials grant type (as in the Postman example below) use the Application permissions.

Add these permissions for API access:

API

Permission

Type

Dynamics 365 Business Central

API.ReadWrite.All

Application

Dynamics 365 Business Central

app_access

Application

Dynamics 365 Business Central

Automation.ReadWrite.All

Application

Dynamics 365 Business Central

Financials.ReadWrite.All

Delegated

Dynamics 365 Business Central

user_impersonation

Delegated

Microsoft Graph

User.Read

Delegated

If the Power BI integration is used, also add these permissions:

API

Permission

Type

Power BI Service

Report.Read.All

Delegated

Power BI Service

Workspace.Read.All

Delegated

Microsoft Graph

User.Read

Delegated

After adding the permissions, click Grant admin consent for <your organization>. If everything is set up correctly, the Status column shows a green icon in each permission row.

Next, open Certificates & secrets and click New client secret. Enter a description, select how long the secret is valid and click Add. Copy the Value and save it for later use. You will not be able to see the value again after you leave this page:

Client secret expiry

A client secret is valid only for the period you select when you create it. The longest allowed period is 24 months, and Microsoft recommends less than 12. When the secret expires, the integration stops working: no access token is issued and all API calls fail.

To renew the secret before it expires:

  1. In Certificates & secrets, create a new client secret.

  2. Replace the old value with the new one in every system that uses it.

  3. Delete the old secret.

The old and new secrets work at the same time, so renewing this way causes no downtime. The expiry date of each secret is shown in the Expires column. Note it down and set a reminder so you can renew the secret in time.

Next, open Overview and copy the Application (client) ID and the Directory (tenant) ID. Save these values for later use:

You now have all the values needed for OAuth authentication:

  • Tenant ID – Directory (tenant) ID from Overview (format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx);

  • Client ID – Application (client) ID from Overview (format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx);

  • Client secret – secret Value from Certificates & secrets.

2. Set up the application in Business Central

In Business Central, search for Microsoft Entra Applications, open the page and click New:

On the Microsoft Entra Application Card, fill in:

  • Client ID – the Application (client) ID from step 1;

  • Description – a name that identifies the integration, e.g. the integrating system or the partner that set it up;

  • State – change from Disabled to Enabled;

  • User Permission Sets – add the permission sets the integration needs. Leave Company blank to grant the permission set in all companies, or select a company to limit access to that company.

Assign the same permission sets as for a user with the corresponding role.

Explanation of available permission sets can be found in Teisių rinkiniai, Saugumo grupės.

The SUPER permission set cannot be assigned to Microsoft Entra applications. Assign only the permission sets the integration needs.

Finally, click Grant Consent to grant access to the application. This must be done by a user who can grant admin consent in Microsoft Entra ID (see Prerequisites). If admin consent was already granted in step 1, this step is optional.

3. Call the Business Central API using Postman

Create a new Postman collection. On the collection's Authorization tab, set Auth Type to OAuth 2.0 and fill in the settings below.

Authorization settings

Field

Value

Add auth data to

Request Headers

Header Prefix

Bearer

Configure New Token

Field

Value

Grant Type

Client Credentials

Access Token URL

https://login.microsoftonline.com/{{Tenant}}/oauth2/v2.0/token

Client ID

{{ClientID}}

Client Secret

{{ClientSecret}}

Scope

https://api.businesscentral.dynamics.com/.default

Client Authentication

Send client credentials in body

Variables

{{Tenant}}, {{ClientID}} and {{ClientSecret}} are Postman variables that hold the values from step 1. Store them in a Postman environment and set the type of {{ClientSecret}} to secret, so the secret is masked and is not shared when the collection is exported.

To check the values, click Get New Access Token. If the values are correct, a new access token is generated.

To test a request, add a GET request to the collection. On the request's Authorization tab, set Auth Type to Inherit auth from parent – the access token is then added automatically.

Use this URL to get the companies of the environment:

https://api.businesscentral.dynamics.com/v2.0/{{Tenant}}/{{EnvironmentName}}/api/{{APIVersion}}/companies/

URL structure

Part of URL

Explanation

https://api.businesscentral.dynamics.com/v2.0/

URL base

{{Tenant}}

Tenant ID

{{EnvironmentName}}

Name of the environment

{{APIVersion}}

API version, currently v2.0

companies

API endpoint name

4. Call other Business Central APIs

URL structure: https://api.businesscentral.dynamics.com/v2.0/{{Tenant}}/{{EnvironmentName}}/api/{{APIVersion}}/companies({{CompanyId}})/{{Endpoint}}

Part of URL

Explanation

https://api.businesscentral.dynamics.com/v2.0/

URL base

{{Tenant}}

Tenant ID

{{EnvironmentName}}

Name of the environment

{{APIVersion}}

API version, currently v2.0

companies({{CompanyId}})

ID of the company, returned by the companies endpoint

{{Endpoint}}

Endpoint name

All standard API endpoints and their fields are described in the Microsoft documentation:

Welcome to the API (v2.0) for Business Central

If you are using E-Invoice, see the product documentation:

E-Invoice Overview

If you are using Softera Payroll, see the Payroll API documentation:

Payroll API Overview

Troubleshooting

Error

Possible cause and solution

AADSTS90002 when getting a token

The tenant is not found. Check the Tenant ID in the Access Token URL.

AADSTS700016 when getting a token

The application is not found in the tenant. Check the Tenant ID and the Client ID.

AADSTS7000215 when getting a token

The client secret is invalid. Check that you copied the secret Value, not the Secret ID.

AADSTS7000222 when getting a token

The client secret has expired. Create a new client secret in Certificates & secrets and update it in the integration.

401 Unauthorized when calling the API

The application is not set up in Business Central, its State is Disabled, or consent has not been granted. Check step 2.

Permission error when calling the API (e.g. You do not have the following permissions on TableData …)

A permission set is missing. Add it to User Permission Sets on the Microsoft Entra Application Card.

404 Not Found when calling the API

Wrong environment name, company ID, API version or endpoint name. Endpoint names are case-sensitive, e.g. companies, not Companies.