Guide
How to call the Business Central API from Postman
Updated 21 November 2026
Postman works well with Business Central once it is set up, and most of that setup is the sign-in. This guide takes you from an empty workspace to a working collection: a token from Microsoft Entra, your first call, the company ID kept in a variable, a record created and updated with its ETag, and a test that checks the result.
Before you start
You need an app registered in Microsoft Entra with the Business Central API permission, and that app enabled on the Microsoft Entra applications page in Business Central. If you have not done that yet, follow How to connect to the Business Central API with OAuth 2.0 first, then come back. You will need four values from it:
| Value | Where it comes from |
|---|---|
| Tenant ID | The app registration's Overview page, as Directory (tenant) ID. |
| Environment | The environment's name in the Business Central admin center, such as Production or Sandbox. Case matters. |
| Client ID | The same Overview page, as Application (client) ID. |
| Client secret | The Value column under Certificates & secrets, not the Secret ID. |
1. Create an environment
In Postman, create an environment called, say, BC Sandbox, and add these variables:
| Variable | Value |
|---|---|
tenantId | Your tenant ID |
environment | Sandbox |
clientId | Your client ID |
clientSecret | Your client secret, with the variable type set to secret |
baseUrl | https://api.businesscentral.dynamics.com/v2.0/{{tenantId}}/{{environment}}/api/v2.0 |
companyId | Leave empty; step 4 fills it in. |
Postman resolves the variables inside baseUrl, so switching to production later means changing environment in one place, or duplicating the environment. If the workspace is shared, keep the secret in the local, current value only, so it is not synced to your teammates.
2. Set up OAuth 2.0 on the collection
Create a collection called Business Central. Put the sign-in on the collection rather than on each request: every request inside then inherits it, which is Postman's default for a new request. On the collection's Authorization tab, choose OAuth 2.0 and fill in Configure New Token:
| Field | Value |
|---|---|
| Grant type | Client Credentials |
| Access Token URL | https://login.microsoftonline.com/{{tenantId}}/oauth2/v2.0/token |
| Client ID | {{clientId}} |
| Client Secret | {{clientSecret}} |
| Scope | https://api.businesscentral.dynamics.com/.default |
| Client Authentication | Send client credentials in body |
Choose Get New Access Token, then Use Token. Postman adds it to every request as Authorization: Bearer …. If the token request fails, Postman shows Microsoft's answer, which starts with an AADSTS code; the table further down covers the usual ones.
3. Make your first call
Add a request to the collection, leave its Authorization tab on Inherit auth from parent, and send:
GET {{baseUrl}}/companies
A 200 OK with a value array of companies means the sign-in, the permission and the Business Central side are all in place. Each company has an id, a GUID, and nearly every other URL in the API goes through one.
4. Keep the company ID in a variable
Copying the GUID into the environment by hand works, but a short script does it for you every time. Open the request's Scripts tab and add this under Post-response (the Tests tab in older versions of Postman):
const companies = pm.response.json().value;
const company = companies.find(c => c.name === "CRONUS USA, Inc.") || companies[0];
pm.environment.set("companyId", company.id);
Change the name to the company you work in. From now on a URL such as this reaches that company's data:
GET {{baseUrl}}/companies({{companyId}})/customers?$top=5
The guide $filter, $select and $orderby examples has more queries to try here.
5. Create a record
Add a POST request, choose Body, raw and JSON, which makes Postman send Content-Type: application/json:
POST {{baseUrl}}/companies({{companyId}})/customers
{
"displayName": "Adatum Corporation",
"type": "Company",
"email": "accounts@adatum.example"
}
Business Central answers 201 Created with the whole record, including fields it filled in from setup. Keep the new record's ID for the next step, with a post-response script:
pm.environment.set("customerId", pm.response.json().id);
Field names are the camelCase names in the API, not the captions you see in the client. If you are not sure of a name, or a field is refused as read-only, look it up in the entity's $metadata, as explained in How to read Business Central $metadata.
6. Update it with the ETag
Business Central refuses a PATCH or DELETE without an If-Match header holding the record's current ETag. That ETag is in the @odata.etag field of every record you read. Get the record and keep it:
GET {{baseUrl}}/companies({{companyId}})/customers({{customerId}})
pm.environment.set("etag", pm.response.json()["@odata.etag"]);
Then send the change with the header:
PATCH {{baseUrl}}/companies({{companyId}})/customers({{customerId}})
If-Match: {{etag}}
{
"phoneNumber": "+1 425 555 0100"
}
Send only the fields you mean to change. A field you send empty is cleared. If someone changed the record after your GET, the answer is 412; read it again and repeat. If-Match: * skips the check and overwrites whatever is there, so keep it away from real data. The guide How to fix If-Match and ETag errors covers both errors in detail.
7. Check the result with a test
Postman tests are JavaScript in the same post-response script. For the create request:
pm.test("Customer created", () => {
pm.response.to.have.status(201);
pm.expect(pm.response.json().displayName).to.eql("Adatum Corporation");
});
Put the requests from steps 3 to 6 in a folder, in that order, and run it with the Collection Runner. Each request feeds the next through the variables, and the runner shows which tests passed. Run it against a sandbox: it creates a real customer every time.
When the token expires
Tokens from Microsoft Entra last about an hour. After that every call returns 401, and you choose Get New Access Token again. The client credentials flow has no refresh token, so there is nothing to refresh; a new token is simply a new request.
A run from the command line cannot press that button. For unattended runs, fetch the token in the collection's Pre-request script instead, and set the collection's Authorization to Bearer Token with the value {{accessToken}}:
const env = pm.environment;
const expires = Number(env.get("tokenExpires") || 0);
if (Date.now() > expires) {
pm.sendRequest({
url: "https://login.microsoftonline.com/" + env.get("tenantId") + "/oauth2/v2.0/token",
method: "POST",
body: {
mode: "urlencoded",
urlencoded: [
{ key: "grant_type", value: "client_credentials" },
{ key: "client_id", value: env.get("clientId") },
{ key: "client_secret", value: env.get("clientSecret") },
{ key: "scope", value: "https://api.businesscentral.dynamics.com/.default" }
]
}
}, (err, res) => {
if (err) { console.error(err); return; }
const token = res.json();
env.set("accessToken", token.access_token);
env.set("tokenExpires", Date.now() + (token.expires_in - 60) * 1000);
});
}
The script asks for a new token only when the old one is within a minute of expiring, so a long run does not request one per call.
Signing in as a user instead
Client credentials signs in as the app. To call the API as yourself, with your own permissions, use the authorization-code flow:
- In the app registration, add the delegated permission
user_impersonationfor Dynamics 365 Business Central. - In Postman, set the grant type to Authorization Code (With PKCE), the Auth URL to
https://login.microsoftonline.com/{{tenantId}}/oauth2/v2.0/authorize, and the scope tohttps://api.businesscentral.dynamics.com/user_impersonation offline_access. The token URL, client ID and secret stay as before. - Tick Authorize using browser. Copy the Callback URL Postman then shows, and add exactly that as a redirect URI on the Web platform under the app registration's Authentication page. Microsoft's own Postman instructions use
https://oauth.pstmn.io/v1/browser-callback. - Choose Get New Access Token and sign in in the browser window that opens.
When something fails
| What you see | What it usually means |
|---|---|
AADSTS7000215 | The client secret is wrong. Most often the Secret ID was copied instead of the Value. |
AADSTS70011 | The scope is wrong. It must be https://api.businesscentral.dynamics.com/.default for client credentials. |
AADSTS50011 | Authorization code only: the callback URL is not registered on the app, or differs by a character. |
401 on the first call | The token was issued, but Business Central refused it: the app is missing from the Microsoft Entra applications page, not Enabled, or admin consent was not granted. See How to fix 401 and 403 errors. |
404 on /companies | The environment name in the URL is wrong, often only its capital letter. |
412 on a PATCH | The ETag is out of date. Read the record again. |
| The request never leaves the browser | In Postman on the web, calls go through the Postman agent. Without it, the browser blocks them. |
Business Central's own error codes, such as BadRequest_ResourceNotFound or Application_DialogException, are listed in Business Central API errors explained.
The same steps in Ava
Ava is an API client built for Business Central, so most of the setup above is already in it. Connect Business Central takes the same four values and handles the token, including asking for a new one when it expires. You pick the company from a list rather than scripting it into a variable. Explore reads your tenant's $metadata and adds list, get, create, update and delete requests for any entity. If-Match: {{$etag}} sends the ETag from your last read of that record, with no script. Captures and tests are rows in a table rather than JavaScript.
You can bring this collection with you. Export it from Postman as v2.1 and import it: folders, auth settings and collection variables come across. Scripts and saved example responses do not, so their work moves to Capture and Test rows. Postman exports environments separately, as their own file, and Ava imports those too. The comparison with Postman says where Postman is still the better choice.
