Ava API Client

Guide

How to fix 401 Unauthorized and 403 Forbidden errors in the Business Central API

Updated 21 November 2026

A 401 from the Business Central API almost never means your password is wrong. It means one of four or five things in the chain between your app registration and your company's data is not lined up. This guide walks that chain in order, so you check the likely cause first and stop when the call works.

First: where did it fail?

A call to Business Central Online is really two calls. The first goes to Microsoft Entra ID at login.microsoftonline.com and asks for a token. The second goes to api.businesscentral.dynamics.com with that token attached. Each can refuse you, and they say so differently.

WhereWhat you seeWhat it means
Token endpointA 400 or 401 whose body has error and error_description, and the description starts with AADSTSEntra would not issue a token. Business Central has not been involved yet.
Business CentralA 401 with a JSON body whose error.code is something like Authentication_InvalidCredentialsYou have a token, but Business Central will not accept it or the app behind it.
Business CentralA 401 with an empty body and a WWW-Authenticate: Bearer headerThe request reached Business Central with no usable token at all.
Business CentralA 403, or a 400 whose message says you do not have permissionYou are signed in. The user or app lacks the permission set for that table or operation.

Find your row, then go to the matching section below. If you are not sure which place answered, look at the URL that was called. Anything under login.microsoftonline.com is Entra.

1. The token endpoint refused you (AADSTS)

Every AADSTS code is listed by Microsoft, and the common ones for Business Central are explained in Business Central API errors explained. The three that account for most failures are:

Once a token comes back, this step is done. Do not change the registration further until you have read the Business Central response.

2. Check the token before you blame Business Central

An access token is a JWT. Paste it into jwt.ms, Microsoft's own decoder, and read four claims:

ClaimShould beIf it is not
audhttps://api.businesscentral.dynamics.comYou asked for the wrong scope. Business Central rejects a token meant for Microsoft Graph or any other API with a bare 401.
expA time in the futureThe token has expired. Tokens last about an hour; request a new one.
tidYour Business Central tenant's IDYou signed in to a different directory than the environment belongs to.
roles or scpAPI.ReadWrite.All in roles for an app; user_impersonation in scp for a signed-in userThe permission was added to the registration but consent was not granted, or you granted a delegated permission and are using the client credentials flow, or the other way round.

The scope to request is exactly https://api.businesscentral.dynamics.com/.default. A trailing slash before .default is required; a different host, or Financials.ReadWrite.All from older samples, is not. Setting this up from the start is covered in connecting with OAuth 2.0.

3. Business Central says Authentication_InvalidCredentials

HTTP/1.1 401 Unauthorized

{
  "error": {
    "code": "Authentication_InvalidCredentials",
    "message": "The server has rejected the client credentials.  CorrelationId:  ..."
  }
}

This is the most common 401 of all, and it has one cause in nine cases out of ten: the app registration exists in Entra, but nobody has told Business Central about it. Registering an app lets it sign in. It does not let it in.

  1. In Business Central, search for Microsoft Entra applications.
  2. Check there is a row whose Client ID matches the appid or azp claim in your token.
  3. Check its State is Enabled. A new row is created Disabled.
  4. Check it has at least one permission set assigned, and that the permission set covers the company you are calling, or is not limited to a company at all.

If the row is missing, add it, and give it the permission sets the integration needs, then try again. There is no delay; the next call should work.

The same error also appears when the token is for the right app but the wrong tenant. If the row exists and is enabled, compare the tid claim with the tenant ID shown in the Business Central admin center.

4. The request never carried a token

An empty 401 with a WWW-Authenticate header means Business Central found no token it could read. Check the header itself:

Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIs...

5. A 404 that looks like a sign-in problem

Some "it will not sign in" reports are not 401s at all. If the environment name in the URL is wrong, Business Central cannot find anything to authenticate against and returns a 404 whose message names the environment. The URL has the shape:

https://api.businesscentral.dynamics.com/v2.0/<tenant-id>/<environment>/api/v2.0/companies

The environment name is case-sensitive and comes from the admin center, not from the display name of the company. Production and Sandbox are the defaults; a copied or renamed environment has whatever name it was given. The tenant ID here can be the directory ID GUID or the tenant's domain name.

6. Signed in, but refused: 403 and permission messages

Once authentication works, the remaining refusals are about permission, and the message is clearer than the status code. Depending on the version you may see a 403 Forbidden, or a 400 with the same text. The text is what matters:

You do not have the following permissions on TableData Customer: Insert.

Fix it where the identity is defined:

Two other restrictions can look like 403s. An administrator can limit who may sign in to an environment to a Microsoft Entra security group, and users outside the group are turned away. And if the API.ReadWrite.All permission has been granted but Automation.ReadWrite.All has not, calls to the automation API (/api/microsoft/automation/v2.0/) fail while the ordinary API works.

7. It worked an hour ago

If a call that worked starts failing without any change on your side, check these before anything else:

A checklist to keep

  1. Does the token endpoint return a token? If not, read the AADSTS code.
  2. Does the token's aud say https://api.businesscentral.dynamics.com, and is exp in the future?
  3. Is the app on the Microsoft Entra applications page in Business Central, Enabled, with a permission set?
  4. Is the header Authorization: Bearer <access_token>, unbroken?
  5. Is the environment name in the URL spelt as the admin center spells it?
  6. Does the permission set cover the table, the operation and the company?

The same thing in Ava

Ava's Connect Business Central takes the tenant ID, environment name, client ID and secret, and tests the sign-in. If the token endpoint refuses, you see the AADSTS code; if Business Central refuses, you see its own message. When it succeeds, Ava lists your companies, which proves both halves of the chain at once.

On any request, Business Central's error envelope is decoded into plain English, with the code and the message shown first rather than buried in JSON. The token itself is handled for you and refreshed when it expires, so step 7 stops being a thing you do by hand. Secrets are encrypted on the server and never sent back to the browser.

Sources