> ## Documentation Index
> Fetch the complete documentation index at: https://support.stuut.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Dynamics 365 Finance & Operations

> How to configure the Microsoft Dynamics 365 Finance & Operations integration for Stuut.

This guide explains how to configure Stuut's Microsoft Dynamics 365 Finance & Operations integration using OAuth 2.0 against the OData data entities. Once finished, Stuut imports historical data and performs hourly incremental syncs.

This covers Finance & Operations only. Business Central is a different product with a different Stuut connector, and these settings do not apply to it.

## Dynamics 365 Finance & Operations setup for Stuut

### 1. Grant admin consent to the Stuut application

Stuut is a multi-tenant Microsoft Entra ID application, and a Global Administrator grants admin consent to it once. Stuut then signs in as a user and calls the OData data entities only. It does not call Microsoft Graph.

<Tip>
  The consent screen is shared across Stuut's Microsoft integrations, so it may list mail permissions this connector never uses.
</Tip>

### 2. Create a dedicated Dynamics user

Create or identify a dedicated Finance & Operations user for Stuut, for example `collections@yourcompany.com`, rather than an individual administrator's everyday account. Stuut signs in as this user, so the data it can read is exactly the data this user can read.

### 3. Assign a security role with read on the required entities

Create a security role for Stuut and give it **read** on the entities below. A denied entity fails the whole model rather than degrading it, so grant all of them.

How much of this you need depends on the account. A broad role reaches all of these already. The dedicated account recommended in step 2 needs each entity granted explicitly, and a single 403 means one missing grant rather than a broken connection.

| Data entity                             | What Stuut reads                                             |
| --------------------------------------- | ------------------------------------------------------------ |
| `Companies`                             | Validates the legal entity at connect time                   |
| `CustomersV3`                           | Customer master: name, currency, payment terms, credit limit |
| `ContactPersons`                        | Customer contact people                                      |
| `CustInvoiceJourBiEntities`             | Posted invoices and credit notes                             |
| `CustomerPaymentJournalLines`           | Customer payments                                            |
| `CustTransactions`                      | Open balance and due date per transaction                    |
| `CustSettlementBiEntities`              | Settlement history, so Stuut can tell what a payment paid    |
| `SalesOrderHeaderDocumentAttachmentsV2` | The invoice PDF attached to the sales order                  |

### 4. Two entities that are easy to miss

Grant these as well. Without them the affected models still report **Done**, so the gap does not show up in the sync status.

**`CustomerElectronicAddresses`** — needed if your customer email addresses live on the customer **Contact information** grid.

Without it Stuut reads only `CustomersV3.PrimaryContactEmail`, which Dynamics fills only when an email row is marked **Primary** on that grid. A customer with three email addresses and the Primary marker on a phone number reaches Stuut with no address at all, and cannot be emailed.

**`Employees`** — needed if you want Stuut to assign a collector to each customer.

`CustomersV3.EmployeeResponsibleNumber` holds a personnel number, not a name or address, so Stuut cannot match it to a user on its own. Without this entity, supply a list mapping each personnel number to a name and email instead.

### 5. Collect the connection settings

| Setting      | Where it comes from                            | Example                                       |
| ------------ | ---------------------------------------------- | --------------------------------------------- |
| API URL      | Base URL of your environment, no trailing path | `https://yourcompany.operations.dynamics.com` |
| Legal entity | The `dataAreaId` of the legal entity in scope  | `usmf`                                        |

Sandboxes use their own host name, and a security role granted in a sandbox does not carry over, so apply the role in both environments.

<Tip>
  The legal entity is fixed once the connection is created. Changing it means removing the connection and building it again, so confirm which one is in scope first.
</Tip>

### 6. Connect Dynamics 365 to Stuut

Log in to Stuut and navigate to **General Settings → Connectors → All Connectors**. Choose **Microsoft Dynamics 365 Finance & Operations** from the list.

Click **Add** and follow the instructions in the window. You will enter the API URL and legal entity, then sign in as the dedicated Dynamics user.

### 7. Validate the connection

Click **Check Health** in the top right. If everything was set up correctly the connection shows as **Linked**.

The **Overview** tab reports each model separately, so Customers, Contacts, Invoices, Credit Memos and Payments each show **Done** once the import finishes. The **Logs** tab lists every request including failures, which is the fastest way to find an entity the role is still missing.

### 8. Optional: invoice PDFs

Stuut attaches the invoice PDF to collections email when it can find one. It reads the attachment on the **sales order** named `Customer invoice`, which is what Print Management writes when **Save to Attachments** is enabled for the customer invoice report.

<Tip>
  If your process files a scanned or signed copy somewhere else instead, tell your Stuut contact where it lives. Attachments held against the customer invoice journal are not exposed by the standard data entities and need a different approach.
</Tip>
