> For the complete documentation index, see [llms.txt](https://docs.solutioo.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.solutioo.de/dpdconnector/verbindung-und-konfiguration/uberblick-and-anbindung-s2s-oauth.md).

# Überblick & Anbindung (S2S/OAuth)

{% hint style="warning" %}
**Premium.** Diese Funktion ist nur im Tarif Premium enthalten. Starter, Team, Business und Enterprise enthalten sie nicht.
{% endhint %}

## Überblick & Anbindung (S2S/OAuth)

Die Azure Function **`DpdTrackingPush`** verarbeitet DPD-Statusdaten und schreibt sie über die Business-Central-**OData-v4-API** zurück. Dazu ist eine einmalige **Service-to-Service-Anbindung (OAuth)** nötig.

### Architektur

```mermaid
flowchart LR
    DPD["DPD"] -->|HTTP GET Push| AF["Azure Function"]
    DPD -->|SFTP Pull| AF
    AF -->|OAuth2 S2S| API["BC API\nsolutioo/dpd/v1.0"]
    API --> BC["Paketstatus / POD in BC"]
```

### BC-API-Endpunkte

Diese Endpunkte hinterlegen Sie in der Azure Function (Platzhalter ersetzen):

```
https://<env>.api.businesscentral.dynamics.com/v2.0/<company>/api/solutioo/dpd/v1.0/companies(<companyId>)/trackingEvents
https://<env>.api.businesscentral.dynamics.com/v2.0/<company>/api/solutioo/dpd/v1.0/companies(<companyId>)/proofOfDeliveries
```

### Einmalige Anbindung

{% stepper %}
{% step %}

#### Entra App-Registrierung

Eine App-Registrierung anlegen (z. B. „DPD Tracking Push (BC S2S)") und ein **Client-Secret** erzeugen. Client-ID und Secret in die App-Settings der Function eintragen.
{% endstep %}

{% step %}

#### S2S in Business Central freischalten

In BC **Microsoft Entra-Anwendungen** öffnen, die **Client-ID** eintragen, Status = **Aktiviert** und den Berechtigungssatz **`SOUDPDConnector`** (oder `D365 AUTOMATION` + DPD) zuweisen.
{% endstep %}

{% step %}

#### Company-GUID ermitteln

`GET .../v2.0/<env>/api/v2.0/companies` → die `id` als `BC_COMPANY_ID` in der Function hinterlegen.
{% endstep %}

{% step %}

#### Push bei DPD registrieren

Beim DPD-Kundencenter die Push-URL hinterlegen (siehe Tracking-Push-Service).
{% endstep %}
{% endstepper %}

### App-Settings (Kern)

| Setting            | Beschreibung                                                      |
| ------------------ | ----------------------------------------------------------------- |
| `BC_TENANT_ID`     | Entra-Tenant-GUID                                                 |
| `BC_CLIENT_ID`     | Client-ID der App-Registrierung                                   |
| `BC_CLIENT_SECRET` | Client-Secret                                                     |
| `BC_ENVIRONMENT`   | z. B. `Production` oder `Sandbox`                                 |
| `BC_COMPANY_ID`    | GUID des BC-Mandanten                                             |
| `BC_API_BASE`      | optional, Default `https://api.businesscentral.dynamics.com/v2.0` |

{% hint style="info" %}
Deployment erfolgt über das mitgelieferte Skript `deploy.sh` (Resource Group, Storage Account und Function App werden idempotent angelegt). Runtime: Node auf Azure Functions v4, Windows Consumption Plan.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.solutioo.de/dpdconnector/verbindung-und-konfiguration/uberblick-and-anbindung-s2s-oauth.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
