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.
| Where | What you see | What it means |
|---|---|---|
| Token endpoint | A 400 or 401 whose body has error and error_description, and the description starts with AADSTS | Entra would not issue a token. Business Central has not been involved yet. |
| Business Central | A 401 with a JSON body whose error.code is something like Authentication_InvalidCredentials | You have a token, but Business Central will not accept it or the app behind it. |
| Business Central | A 401 with an empty body and a WWW-Authenticate: Bearer header | The request reached Business Central with no usable token at all. |
| Business Central | A 403, or a 400 whose message says you do not have permission | You 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:
- AADSTS7000215, invalid client secret. You pasted the secret's Secret ID instead of its Value, or the value has been rotated. Create a new secret and copy the Value column.
- AADSTS700016, application not found. The client ID is wrong, or you are asking a different tenant's token endpoint. The tenant ID in the URL must be the one the app is registered in.
- AADSTS500011 or AADSTS65001, the resource was not found or nobody has consented. The app has no Dynamics 365 Business Central permission yet, or an administrator has not granted consent.
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:
| Claim | Should be | If it is not |
|---|---|---|
aud | https://api.businesscentral.dynamics.com | You asked for the wrong scope. Business Central rejects a token meant for Microsoft Graph or any other API with a bare 401. |
exp | A time in the future | The token has expired. Tokens last about an hour; request a new one. |
tid | Your Business Central tenant's ID | You signed in to a different directory than the environment belongs to. |
roles or scp | API.ReadWrite.All in roles for an app; user_impersonation in scp for a signed-in user | The 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.
- In Business Central, search for Microsoft Entra applications.
- Check there is a row whose Client ID matches the
appidorazpclaim in your token. - Check its State is Enabled. A new row is created Disabled.
- 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.
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...
- The scheme is
Bearer, one space, then the token.bearerin lower case is accepted;TokenorBasicis not. - The value is the
access_tokenfield from the token response, not the whole JSON and not theid_token. - Nothing has wrapped or truncated it. A token pasted through a tool that inserted a line break is a common cause.
- Web service access keys, which used Basic authentication, no longer work for Business Central Online. If you have an old script that sends a username and key, it needs OAuth now.
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:
- For an app (client credentials): on its row in Microsoft Entra applications, add a permission set that includes that table and operation. Apps cannot be given SUPER. Microsoft points to D365 AUTOMATION and the EXTEN. MGT. - ADMIN permission sets as covering most of what automation needs, but the right answer is the smallest set that works.
- For a user (authorization code): the token acts as that user, so the user's own permission sets and licence apply. A user without a Business Central licence, or whose licence has no access to the environment, is refused even though Entra signed them in.
- For a company-limited set: a permission set assigned with a specific company applies only there. Calling another company's data fails with the same message.
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:
- The token expired. Request a new one for every run, or cache it and refresh before
exp. - The client secret expired. Secrets have an end date, often six months or a year. The error moves back to the token endpoint and becomes AADSTS7000222.
- Someone disabled the row on the Microsoft Entra applications page, or removed a permission set, perhaps while tidying up.
- The environment was renamed, copied or restored. A sandbox refreshed from production keeps the production app rows but may have different permission set assignments.
A checklist to keep
- Does the token endpoint return a token? If not, read the AADSTS code.
- Does the token's
audsayhttps://api.businesscentral.dynamics.com, and isexpin the future? - Is the app on the Microsoft Entra applications page in Business Central, Enabled, with a permission set?
- Is the header
Authorization: Bearer <access_token>, unbroken? - Is the environment name in the URL spelt as the admin center spells it?
- 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.
