# Connect SAP Business One

A SAP Business One that runs on your own servers, behind a firewall, can be connected to Peaky through a [Peaky Connector](/doc/peaky-connector-on-premise-systems-tSV5gikiVC). The connector reaches your **Service Layer** from inside your network and lets Peaky sign in and read, and nothing else. A Service Layer reachable from the internet needs no connector — see [Accounting & ERP](/doc/accounting-fSYP3czo81#sap-business-one).


---

## Before You Start

* A connector installed and **Connected** — see [Peaky Connector (On-premise Systems)](/doc/peaky-connector-on-premise-systems-tSV5gikiVC), and [Run on Docker](/doc/run-on-docker-o5CZCzqkk4), [Run on Linux](/doc/run-on-linux-h1rOBYadEK), [Run on Windows](/doc/run-on-windows-Q0AucWclz0) or [Run on Kubernetes](/doc/run-on-kubernetes-scvf7JLIud). The connector's machine must be able to reach your Service Layer (port 50000 unless you changed it).
* A SAP Business One user Peaky signs in with, and the name of the **company database** to sync. Through a connector, Peaky signs in with a **username and password**. Signing in with **OAuth** is not available this way: it goes to your identity provider, which the connector does not reach.


---

## Add SAP Business One to the Connector

Add a target for the Service Layer to the connector's configuration file, `/etc/peaky-connector/connector.toml`, with the address the connector's machine reaches it at — the Service Layer's address only, without `/b1s/v2`:

```toml
[[target]]
name = "sap-b1"
url = "https://b1.mycompany.internal:50000"
profile = "sap-b1-readonly"
```

### Certificates

A Service Layer usually comes with a **self-signed certificate**, which the connector does not trust on its own. Export that certificate (or the certificate of the authority that issued it) as a PEM file, put it on the connector's machine, and point the target at it with `ca_file`:

```toml
[[target]]
name = "sap-b1"
url = "https://b1.mycompany.internal:50000"
profile = "sap-b1-readonly"
ca_file = "/etc/peaky-connector/b1-service-layer.pem"
```

With Docker, mount the file into the container next to the configuration, as above (see [Run on Docker](/doc/run-on-docker-o5CZCzqkk4#proxies-and-certificates)). As a Linux service, keep it next to the configuration, in `/etc/peaky-connector/certs`; as a Windows service, in `C:\ProgramData\Peaky Connector`, with the path in single quotes (`ca_file = 'C:\ProgramData\Peaky Connector\b1-service-layer.pem'`). On Kubernetes, certificates are mounted in `/etc/peaky-connector/certs`: put the file in a Secret under the key `b1-service-layer.pem`, set `ca_file = "/etc/peaky-connector/certs/b1-service-layer.pem"`, and give the Secret's name in `certificates.secretName` with Helm (see [Chart settings](/doc/run-on-kubernetes-scvf7JLIud#chart-settings)), or in the manifest's commented-out `certs` volume. The connector never skips the certificate check; the address in `url` must match a name on the certificate. See [The configuration file](/doc/peaky-connector-on-premise-systems-tSV5gikiVC#the-configuration-file).

Restart the connector to load the new target, and check that it reaches the Service Layer:

* **Docker:** `docker restart peaky-connector`, then `docker exec peaky-connector peaky-connector check`. See [Run on Docker](/doc/run-on-docker-o5CZCzqkk4#change-the-configuration).
* **Linux service:** `sudo systemctl restart peaky-connector`, then `sudo systemd-run --wait --pipe --quiet --collect -p EnvironmentFile=-/etc/peaky-connector/connector.env /usr/local/bin/peaky-connector check`. See [Run on Linux](/doc/run-on-linux-h1rOBYadEK#change-the-configuration).
* **Windows service:** `Restart-Service PeakyConnector`, then `& 'C:\Program Files\Peaky Connector\peaky-connector.exe' check`, in PowerShell as administrator. See [Run on Windows](/doc/run-on-windows-Q0AucWclz0#change-the-configuration).
* **Kubernetes:** see [Run on Kubernetes](/doc/run-on-kubernetes-scvf7JLIud#change-the-configuration), then `kubectl -n peaky-connector exec peaky-connector-0 -- peaky-connector check`.

Within a minute, the **Connectors** tab lists **sap-b1** under the connector's **Targets**.

### The sap-b1-readonly profile

With `profile = "sap-b1-readonly"`, the connector lets through only:

* signing in to the Service Layer and signing out again,
* reading records, and
* reading the posting periods, which Peaky uses to know how far your books are closed.

Everything else is refused at the connector, whatever rights the SAP Business One user has: creating, changing, closing or cancelling documents, any other action, and batches of requests. Peaky's sync only ever reads, so it needs nothing more.

The profile decides what kind of request is allowed, not which records can be read: that is still up to the user's authorizations in SAP Business One.


---

## Connect SAP Business One Through It


1. Find **SAP Business One** under the **Accounting & ERP** tab on the **Integrations** page and click **Connect**.
2. Under **Where does your SAP Business One run?**, choose **On your own network, through a Peaky Connector**.
3. Choose the **Connector**. The **Target** is filled in from what the connector reported — `sap-b1` unless you named it differently. Only targets with the **sap-b1-readonly** profile are offered, and the connector has to have connected once since you added it.
4. Fill in the **Company database**, **Username** and **Password**, and click **Connect**.

Peaky signs in through the connector to check the details before saving them, and queues the first sync. From here, SAP Business One works as it does without a connector. The password is stored in Peaky like any other integration's credentials, not on the connector.


---

## Troubleshooting

| Connecting SAP Business One says | Likely cause | What to do |
|----------------------------------|--------------|------------|
| *The connector is not connected to Peaky* | The connector is stopped, or its machine or network is down | Start it again (see [Run on Docker](/doc/run-on-docker-o5CZCzqkk4#troubleshooting), [Run on Linux](/doc/run-on-linux-h1rOBYadEK#troubleshooting), [Run on Windows](/doc/run-on-windows-Q0AucWclz0#troubleshooting) or [Run on Kubernetes](/doc/run-on-kubernetes-scvf7JLIud#troubleshooting)), wait until it shows **Connected**, then try again |
| *The connector refused the request* | The configuration has no target of that name, or it lacks `profile = "sap-b1-readonly"` | Check the target's `name` and `profile`, restart the connector, and use the same name as **Target** |
| *The connector has not reported a target of this name with the sap-b1-readonly profile* | The target is missing, has another profile, or was added after the connector last connected | Add `profile = "sap-b1-readonly"` to the target, restart the connector, and wait until it shows **Connected** |
| *Could not reach the Service Layer at this address* | The connector cannot reach the Service Layer, or does not trust its certificate | Run `peaky-connector check` in the connector (see [Run on Docker](/doc/run-on-docker-o5CZCzqkk4#check-it), [Run on Linux](/doc/run-on-linux-h1rOBYadEK#check-it), [Run on Windows](/doc/run-on-windows-Q0AucWclz0#check-it) or [Run on Kubernetes](/doc/run-on-kubernetes-scvf7JLIud#check-it)); check the target's `url` and port, and add its certificate as `ca_file` |
| *The Service Layer refused these details* | The company database, username or password is wrong | Check them by signing in to SAP Business One with the same user |
| *Signed in, but this user cannot read the chart of accounts* | The user lacks authorizations for the financials | Give the user read access to the chart of accounts and journal entries |

For problems with the connector itself, see [Troubleshooting](/doc/peaky-connector-on-premise-systems-tSV5gikiVC#troubleshooting) on the connector's page.