Skip to main content

Give Claude Code access to your flows

With the AutoFlow Flow API, a coding agent such as Claude Code can work on your flows directly in Business Central: find a flow, export it, change it, and import the result. You no longer need to download and upload files by hand.

Claude works as you. It signs in with your Business Central account and can do exactly what your AutoFlow role allows, nothing more. Every change shows up in the flow's version history under your name.

What Claude can and can't do​

Claude canClaude can't
List the flows in a company, and filter them by code, name, status or folderPublish or unpublish a flow
Export any version of a flow – the same file as Export current versionDelete a flow or a version
Import a changed or new flowChange AutoFlow Setup, credentials or licensing

An import always arrives as a draft, just like Create from file. If the file's code belongs to an existing flow, the import becomes that flow's next draft version. An open draft stays available in the version history. Otherwise, a new flow is created. The published version keeps running until you review the draft in the flow editor and choose Publish changes yourself.

After each import, AutoFlow runs the same checks as Publish changes and tells Claude what would stop or warn. Claude can then fix those issues before you even open the flow.

What you need​

  • A Business Central user with the AutoFlow permission set mse365 AF ALL (AutoFlow User) or mse365 AF ADMIN in the company you want to work in. See Installation.
  • The name of your Business Central environment (for example Production or Sandbox) and of the company.
  • Python 3 on your computer.
  • The AutoFlow agent docs, which contain the helper Claude uses to call the API:
    git clone https://github.com/mse365/autoflow-agent-docs.git

You don't need an app registration or anything from your IT administrator.

Step 1 – Tell the helper where to work​

Set two environment variables in the terminal you start Claude Code from:

export AF_ENVIRONMENT="Production"
export AF_COMPANY="CRONUS AG"

On Windows PowerShell, use $env:AF_ENVIRONMENT = "Production" and $env:AF_COMPANY = "CRONUS AG".

Neither value is a secret. You can also put them in your project's CLAUDE.md, so Claude knows them in every session.

Step 2 – Sign in​

python3 autoflow-agent-docs/tools/af_api.py login

The helper shows a code and a link. Open the link in your browser, enter the code, and sign in with the account you use for Business Central, including your usual multi-factor sign-in. Then check that everything works:

python3 autoflow-agent-docs/tools/af_api.py list

You'll see the flows of the company. The helper remembers your sign-in on this computer and renews it in the background, so you usually only sign in once a day. To remove the sign-in, run af_api.py logout.

Already using the Azure CLI?

If you're signed in with az login, you can skip the helper's sign-in and pass a token instead: export AF_TOKEN=$(az account get-access-token --resource https://api.businesscentral.dynamics.com --query accessToken -o tsv)

Step 3 – Ask Claude​

Tell Claude where the docs are and what you want, for example:

Read autoflow-agent-docs/AGENTS.md. Then use tools/af_api.py to export the flow ACME.INVOICE-MAIL, add a step that also sends the invoice to the sales person, and import it again.

Claude exports the flow, edits it, checks it with the validator from the agent docs, and imports it. The helper prints what the import created, for example New draft of flow FL0012, draft version 1.4.3 (not published), plus any issues. Open the flow in AutoFlow, look at the draft, and publish it when you're happy with it.

Good to know​

  • Try it in a sandbox first. The API works the same in every environment, so a sandbox copy of your company is the safest place to get used to it.
  • Imports are drafts, nothing more. A mistake in an import never reaches a running flow. To throw away a draft you don't want, choose Revert changes on the flow card – the flow goes back to its published version.
  • Claude can read every flow in the company you point it at, including the configuration of its steps. Stored credential secrets are not part of a flow and are never exported.
  • Someone else editing the same flow? An import creates a new draft beside theirs, exactly like Create from file. Their draft stays in the version history.

Troubleshooting​

MessageWhat to do
HTTP 403 … needs the AutoFlow permission setYour user lacks mse365 AF ALL in this company. Ask your AutoFlow administrator to assign it.
HTTP 401The sign-in has expired or belongs to another tenant. Run af_api.py login again.
No company named …Run af_api.py companies and copy the name exactly into AF_COMPANY.
HTTP 404 on every callCheck AF_ENVIRONMENT. The environment name is shown in the Business Central URL after your tenant. Also check that your AutoFlow is up to date: the Flow API needs the current version.
The sign-in page says your organisation blocks this sign-in methodSome organisations block sign-in with a code. Ask IT to allow it for you, or use the Azure CLI token described in step 2.

Business Central on-premises​

The same API is available on-premises on the server's API endpoint. Point the helper at it with AF_BASE_URL, for example https://bc.example.com:7048/BC/api. If your server uses user name and password authentication, also set AF_USERNAME and AF_PASSWORD. If it uses Microsoft Entra authentication, pass a token in AF_TOKEN instead. Windows authentication isn't supported by the helper.

For developers: the endpoints​

The helper is a thin wrapper around three Business Central API endpoints. If you want to call them yourself, they live under https://api.businesscentral.dynamics.com/v2.0/<environment>/api/mse365/autoflow/v1.0/companies(<company id>)/. Calling …/api/mse365/autoflow/v1.0/companies returns the company ids.

CallWhat it does
GET flowsLists flows. Each flow has publishedVersionId and draftVersionId (0 when there are no unpublished changes). Supports $filter, for example code eq 'ACME.INVOICE-MAIL'.
GET flows(<id>)/flowVersions?$filter=versionId eq <n>One version. Its definition field holds the exported flow as a JSON string.
POST flowImports with {"definition": "<flow JSON as a string>"}Imports a draft. The response has flowNumber, version, createdNewFlow and issues (a JSON array as a string). A definition that is not a flow returns HTTP 400 and changes nothing.

Authenticate with a delegated token for https://api.businesscentral.dynamics.com – the same kind of token the helper gets when you sign in.