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

# Connect SAP S/4HANA Cloud to Watchdog

> Connect SAP S/4HANA Cloud to Watchdog and grant access to invoices and documents.

Connect SAP S/4HANA to retrieve supplier invoices and attachments in Watchdog. Watchdog does not change, post, or pay invoices in SAP.

## Before you begin

Ask your SAP administrator to confirm that the environment supports the authentication and APIs below. Setup depends on the SAP edition and configuration.

<Warning>
  Watchdog's connection requires OAuth2 with a client ID and client secret. If your SAP environment
  uses another method, contact Watchdog before setting up the connection.
</Warning>

You will need:

* `Base URL`: the API address supplied by your SAP administrator. It may differ from the Fiori address.
* `Client ID` and `Client Secret` for API access.
* optionally, `SAP Client` if your administrator specifies a client number.

## Connect in Watchdog

1. Open **Integrations → SAP S/4HANA Cloud** and add a connection.
2. Enter the details from your SAP administrator.
3. Select **Test Connection**, then save once access has been checked.

## For the SAP administrator

Watchdog needs read access to:

| API                               | Purpose                                                               |
| --------------------------------- | --------------------------------------------------------------------- |
| `API_SUPPLIERINVOICE_PROCESS_SRV` | Retrieve supplier invoices                                            |
| `API_CV_ATTACHMENT_SRV`           | Retrieve supplier-invoice attachments using business object `BUS2081` |

For SAP S/4HANA Cloud, `SAP_COM_0057` is the relevant communication scenario for supplier invoices and their attachments. Set up communication access using the instructions for your SAP edition and check that both APIs are available.

Watchdog's current connection requests a token using `grant_type=client_credentials` at `/sap/bc/sec/oauth2/token` under the supplied Base URL. The client ID and client secret are sent using HTTP Basic authentication in the token request. Confirm that your environment supports this; the connection form does not offer a different OAuth flow or token address.

See SAP's documentation for [supplier invoices](https://api.sap.com/api/API_SUPPLIERINVOICE_PROCESS_SRV/overview) and [attachments in SAP\_COM\_0057](https://help.sap.com/docs/SAP_S4HANA_CLOUD/bb9f1469daf04bd894ab2167f8132a1a/2cde2af8b58b48d5b929ee75c0a4162a.html).

## If the connection does not work

For sign-in failures, ask your administrator to check the API address and OAuth setup. If invoices can be read but attachments are missing, check access to the attachment service and the documents linked to the invoices.
