# SAP Business One — Accounting API: connection

> Canonical URL: https://developers.apideck.com/apis/accounting/sap-business-one/connection

# How to connect to SAP Business One

Apideck connects to SAP Business One through the **Service Layer**, the REST API that ships with SAP Business One. You make your Service Layer reachable from Apideck over HTTPS, create a dedicated SAP Business One user for the integration, and enter four details in Vault: the Service Layer address, the company database, and that user's name and password. There is no app to install and nothing to request from SAP.

## Before you start

You need:

- **SAP Business One 10.0 or later**, in the version for SAP HANA or for Microsoft SQL Server, with the **Service Layer** installed. The connector uses Service Layer v2 (`/b1s/v2`), which is available from SAP Business One 10.0. On Microsoft SQL Server, the Service Layer is supported from 10.0 PL01.
- **Someone who can change your network setup**: publish the Service Layer on a public HTTPS address and open your firewall to Apideck (see step 1). This is usually your IT team or your SAP partner.
- **An SAP Business One administrator** who can create a user and assign authorizations (see step 2).

Steps 1 and 2 are a one-time setup on your side; step 3 is where you connect in Vault. If you only want to try the integration first, you can skip steps 1 and 2 and use Apideck's shared demo company instead (see step 4).

For SAP's own reference on installing and configuring the Service Layer, see [Working with SAP Business One Service Layer](https://help.sap.com/doc/fc2f5477516c404c8bf9ad1315a17238/10.0/en-US/Working_with_SAP_Business_One_Service_Layer.pdf).

## Steps

### 1. Make the Service Layer reachable from Apideck

Apideck calls your Service Layer from the internet, so it must be published like any other public HTTPS service:

1. **Use a public hostname.** Give the Service Layer an address that resolves on the public internet, for example `https://sap.example.com` or `https://sap.example.com:50000` (50000 is the Service Layer's default port).
2. **Use a CA-signed HTTPS certificate.** Apideck rejects self-signed certificates. Install a certificate issued by a public certificate authority for the hostname you use in Vault.
3. **Put a reverse proxy in front of an on-premise Service Layer.** SAP's recommended pattern is a reverse proxy (for example NGINX) in a DMZ that forwards requests to the Service Layer. The proxy is also a convenient place to terminate HTTPS with your CA-signed certificate. Configure it so that it **passes the `Set-Cookie` headers on the `/Login` response through unchanged**: Apideck keeps the session with the `B1SESSION` cookie (and the `ROUTEID` cookie on load-balanced setups), and the connection cannot log in if the proxy strips them.
4. **Allow Apideck's egress IPs through your firewall** on the port the Service Layer (or your proxy) listens on:
   - `18.197.244.247`
   - `18.156.9.3`
   - `3.65.139.215`

   These are Apideck's current EU (`eu-central-1`) egress IPs; support for other regions is upcoming. If you need to confirm the latest list for your region, contact [Apideck Support](https://help.apideck.com/en/articles/7774658).

### 2. Create a dedicated integration user

Create an SAP Business One user just for the integration rather than using a person's login. The connection runs as this one user, so a dedicated user keeps it independent of staff changes and password policies for named users.

1. In SAP Business One, create the user and set its password.
2. Give the user authorizations for the modules you plan to sync, for example business partners, sales, purchasing and financials. A superuser is not required. Set authorizations under **Administration > System Initialization > Authorizations > General Authorizations**.

   The user also needs **read** access to the company setup data that Apideck looks up during a call: currencies, company details, the chart of accounts, tax codes and, if you sync bank accounts, banks. Module authorizations do not always include this setup data. Currencies are important: SAP Business One uses currency codes that your company defines (for example `$` for the US dollar). Apideck uses your currency table to change these codes to ISO codes (`USD`) and back. If the user cannot read currencies and a code differs from its ISO code (for example `$`), SAP Business One rejects documents in that currency, and documents, customers and accounts in that currency come back without a currency. Codes that already are ISO codes (for example `EUR`) keep working.
3. Make sure the user can at least **read business partners**. Apideck reads your customers when you save the connection to check that it works.
4. License the user according to your SAP Business One agreement. Your SAP partner can confirm which licence type applies to an external integration.

Data that Apideck can read and write follows this user's authorizations. If the user lacks an authorization for an object, the Service Layer returns an error for that object (see [Troubleshooting](#troubleshooting)).

If the application you are connecting needs to work across several of your company databases with one connection, create the same user, with the same password and the authorizations it needs, in each of those companies.

### 3. Connect in Vault

Open the SAP Business One connection in Vault and fill in the four fields. All four are required.

| Field | What to enter |
|-------|---------------|
| **Instance URL** | The public base address of your Service Layer: scheme, host and optional port, **without** `/b1s/v2` and without a trailing slash. For example `https://sap.example.com:50000`. Apideck adds `/b1s/v2` itself. |
| **Company Database** | The name of the company database to connect to, for example `SBODEMOUS`. This is the database name, which can differ from the company name shown in SAP Business One. |
| **Username** | The integration user from step 2. |
| **Password** | That user's password. |

Save the connection. Apideck then logs in to your Service Layer with these details and lists your customers (business partners). When both succeed, Vault shows the connection as **connected**.

Apideck renews the Service Layer session automatically before the idle timeout set on your Service Layer runs out, so there is nothing to refresh on your side. This applies to unified API calls and to calls that you send through the Apideck Proxy API.

### 4. Optional: test before you connect a live company

Once connected, the integration creates, updates and cancels documents in the company database you entered. If you would rather not start on your live company, you have two options:

- **Apideck's shared demo company.** Ask [Apideck Support](https://help.apideck.com/en/articles/7774658) for access; you receive the connection details to enter in Vault.
- **A test company database on your own server**, for example a copy of production or an SAP demo database. Connect it the same way as above, entering the test database's name in **Company Database**.

## Troubleshooting

### Every call returns 404

- **Your SAP Business One version is older than 10.0.** Version 9.x only has Service Layer v1 (`/b1s/v1`), and the connector needs v2 (`/b1s/v2`). Upgrade to SAP Business One 10.0 or later.
- **The Instance URL already contains `/b1s/v2`.** Remove it; Apideck adds it, and a doubled path does not exist.
- **Your reverse proxy does not forward the `/b1s/v2` path** to the Service Layer. Check the proxy's routing rules.

### Certificate or TLS errors

The Service Layer, or the proxy in front of it, is presenting a self-signed certificate or a certificate that does not match the hostname in **Instance URL**. Install a CA-signed certificate for that exact hostname (see step 1).

### The connection times out

Apideck cannot reach your Service Layer. Check that:

- the hostname in **Instance URL** resolves on the public internet, not only inside your network;
- your firewall allows Apideck's egress IPs (listed in step 1) on the port in **Instance URL**;
- the Service Layer (and your proxy, if you use one) is running.

### Login fails although the user name and password are correct

- Check **Company Database**: it must be the database name, not the company's display name.
- Check that the user exists in that company database and is not locked.
- If you use a reverse proxy, check that it passes the `Set-Cookie` headers on the `/Login` response through unchanged (see step 1).

### Error -5002: "Enter valid currency code"

SAP Business One rejected the currency of a document that you created or updated. There are two causes:

- **The integration user cannot read currencies.** Apideck cannot then change the ISO code you sent (for example `USD`) to your company's own currency code (for example `$`), so SAP Business One gets a code that it does not know. Give the user read access to currencies under **Administration > System Initialization > Authorizations > General Authorizations**, then retry.
- **The currency does not agree with the business partner.** A document must use the business partner's currency, or the business partner must accept all currencies. Use the business partner's currency, or change the business partner in SAP Business One.

### Error: "Row without tax was found"

Your company uses sales tax, so every line of an invoice or credit note needs a tax code. When the application sends a line without one, SAP Business One uses the tax code set on the customer's default ship-to address. This customer's ship-to address has no tax code, so SAP Business One rejected the document. Do one of these:

- Set a tax code on the customer's ship-to address in SAP Business One, then retry.
- Have the application send a tax code on each line, using one of your company's tax codes. The integration user needs read access to tax codes (see step 2), so the application can list them.

### Documents, customers or accounts come back without a currency

The integration user cannot read currencies, so Apideck cannot change your company's currency codes that differ from ISO codes (for example `$`) to ISO codes. Give the user read access to currencies under **Administration > System Initialization > Authorizations > General Authorizations**. The currency is then included the next time you read the record.

### Error -3000: "The current user is not permitted to query the object"

Depending on the call and the SAP Business One version, the message can also read "The logged-on user does not have permission to use this object". The integration user does not have an authorization for the object that Apideck tried to read or write. The end of the message gives the object name, for example `Currencies`. The object can be setup data, such as currencies, banks or tax codes, and not only a document or master record of a module that you sync. Grant the authorization under **Administration > System Initialization > Authorizations > General Authorizations** in SAP Business One, then retry. If this error occurs when you save the connection, give the user read access to business partners.

### The connection stopped working after a change in SAP

Changing the integration user's password, locking the user or removing its authorizations breaks the connection. Update the password in Vault, or restore the user's access in SAP Business One, and save the connection again.


[API reference](https://developers.apideck.com/apis/accounting/reference.md) · [Coverage matrix](https://developers.apideck.com/apis/accounting/coverage)
