Admin Center API: Automating Environment Chores Across Many Tenants
The Business Central Admin Center API is the programmatic route into the administration center, at https://api.businesscentral.dynamics.com. It lets administrators query and work with production and sandbox environments, set up administrative notifications, and view telemetry for tenant events. For a partner or an internal team looking after many tenants, that is the difference between a chore repeated by hand in every tenant and a script run once. This article stays on the admin API only — the surface for managing environments — and scopes which chores to automate first, which verbs need guardrails, and the version check to run before any published sample is trusted.
Authentication first: consent, AdminAgents, and the failure you will hit
Automating across tenants usually means delegated admin access, and delegated access has one documented precondition. For delegated admin access, the Microsoft Entra application must be added to the AdminAgents group. Skip that step and the consent flow fails with a “Need pre-consent” error. The error reads like a permissions mystery; it is a group-membership check.
So the first chore is not a call. It is a membership:
- Register the application that will act for the delegated admin work.
- Add the application to the AdminAgents group before running the consent flow.
- Run the consent flow once and confirm it completes without the “Need pre-consent” error.
- Make one read-only call — list environments for a single tenant — and confirm the response names the environments you expect.
What success looks like: consent completes with no pre-consent error, and the first list call returns the tenant’s production and sandbox environments — proof the identity, the group, and the endpoint agree before any chore depends on them.
The safe set: reporting and settings chores to automate first
The documented sample operations against environments split cleanly by risk. The read side is where automation should start:
| Chore | Documented operation | Why it is in the safe set |
|---|---|---|
| Environment inventory across tenants | List — GET on the environments endpoint | Read-only; the inventory is the input every other chore needs |
| Completion checks after a change | Per-environment operations and all-operations monitoring endpoints | Lets a script verify an operation finished instead of assuming it did |
| Capacity watch | Used-storage endpoint (database plus file storage) and tenant quotas | Read-only numbers that pair directly with a quota check |
| Update-window review | GET on an environment’s settings/upgrade, returning preferred start and end times and time zone | Reading the window before anyone proposes changing it |
| Telemetry review | Telemetry for tenant events, per the API’s documented capabilities | Read-only, and it is the audit trail the guardrails below rely on |
Settings sit one step up in risk. The environment settings API manages settings such as the Application Insights key and the update window, and the upgrade settings carry preferred start and end times with a time zone. Writing a setting is a change to a live tenant, so settings writes belong in the automate-with-confirmation tier: the script prepares the value, a person approves it, the script applies it and reads it back.
The dangerous verbs: restart, copy, rename
The sample inventory lists the environment operations in one breath: List (GET), Create (PUT), Copy (POST to the copy endpoint), Rename (POST to the rename endpoint), and Restart (POST to the restart endpoint), all against the environments path. In a console that flat list is accurate. In an automation plan it hides the blast radius. A restart interrupts a live environment. A copy creates a new environment from an existing one. A rename changes the identifier other work refers to.
Guardrails for these verbs are not spelled out in the retrieved sources — the samples present them as ordinary operations beside the reads. The guardrails below are therefore this article’s decision framework, stated as operating rules rather than documented behaviour:
| Tier | Operations | Rule |
|---|---|---|
| Automate | List, operations monitoring, used storage, quotas, settings reads | Run on a schedule; log the output per tenant |
| Automate with confirmation | Settings writes, including the update window; administrative notification setup | Script prepares, a named person approves, script applies and reads back |
| Keep manual, script-assisted | Create, Copy, Rename, Restart | Script may assemble the call; a person triggers it per tenant, after checking the target environment name twice |
Two habits make the third tier survivable. First, resolve the tenant and environment from a fresh List call immediately before the action, never from a cached spreadsheet — the cost of acting on the wrong tenant is paid by a store that did nothing wrong. Second, follow every action with the operations endpoints and record the outcome beside the tenant name, so an interrupted run shows which tenants completed and which did not.
Version drift: samples at v2.11, documentation at v2.29
One specification check belongs ahead of all the others. The published sample walkthroughs target /admin/v2.11 endpoints. The current documented Admin Center API version is v2.29. Sample code copied without that check carries an old version segment into production scripts, and a failure that follows will look like an endpoint problem when it is a version problem.
The environment-settings contract shows how versions accumulate: the local-time update-window fields are supported from API version 2.13. A script written against 2.11 samples cannot assume those fields exist in the form the current documentation describes. The check takes a minute: compare the version segment in any sample against the documented current version, and re-check the specific fields the script reads or writes against the current reference for that endpoint.
Automation checklist: before the first production run
- The Entra application is in the AdminAgents group, and consent has completed without a “Need pre-consent” error.
- Every endpoint version in the scripts has been checked against the documented current version, v2.29 — no v2.11 segments carried over unchecked.
- The first production run is read-only: List, used storage, quotas, and settings reads across the tenant set.
- Settings writes require a named approver, and the script reads the setting back after applying it.
- Create, Copy, Rename, and Restart are triggered manually per tenant, from a fresh List result, with the outcome recorded from the operations endpoints.
- Each run logs tenant, operation, and result in one place, so a partial failure is visible as a list of tenants, not discovered store by store.
What success looks like: the first scheduled run returns an inventory, storage figures, and quotas for every tenant in the set, with zero write operations performed — and the run log is complete enough that adding the confirmation-tier chores later is a policy change, not a rebuild.
, Dex Carter, Tech Writer
NextBusiness Central APIs and web services for retail data: which route to use →