# Connecting an AI Agent to SAP Business One

> An AI agent talks to SAP Business One through the Service Layer, an OData-based REST API available for both SAP HANA and Microsoft SQL Server. The agent logs in as its own B1 user, reads documents, creates drafts and, from FP 2602, can be triggered by webhooks.

Canonical URL: https://www.ruebstudio.de/en/guides/ai-agent-integrations/connect-ai-agent-sap-business-one  
Author: Dr.-Ing. Marcus Rüb, CEO  
Published: 2026-11-08

SAP Business One is an ERP system built for small and mid-sized companies. Sales orders, deliveries, invoices, stock and business partners sit in one database, running on either SAP HANA or Microsoft SQL Server. If you want an AI agent to answer delivery questions, prepare quotes or pre-enter supplier invoices, it needs a clean, supported route into that system. This guide covers how the Service Layer provides that route, how the HANA and SQL Server editions differ, and where the limits are. It is based on SAP's Service Layer guide, document version 1.29 dated 27 July 2026, and reflects the situation in November 2026.

## What does connecting an AI agent to SAP Business One involve?

An agent is connected to SAP Business One when it can read data and trigger actions through an official interface rather than relying on exports or screen scraping. For Business One that interface is the Service Layer. The agent gets its own user account, a short list of tools, and works within the permissions Business One assigns to that user.

Common jobs that need Business One access:

- **Answering questions:** "Has order 4711 shipped?", "What is still open on this customer's account?", "How many units of this item are in stock?"
- **Pre-entry:** turning an emailed request for quotation into a draft quote with line items, or a supplier's PDF invoice into a draft document.
- **Reacting to events:** when a sales order is created or changed, checking delivery dates, preparing follow-up questions or alerting the sales team.
- **Reconciliation:** comparing master data between Business One and a CRM, web shop or warehouse system and flagging mismatches.

The general principles of connecting agents to business systems, such as designing narrow tools, restricting rights and guarding write access, are covered in [Connecting AI Agents to Business Systems](https://www.ruebstudio.de/en/guides/ai-agent-integrations/connect-ai-agents-to-business-systems). This guide focuses on what is specific to Business One.

### How is this different from SAP S/4HANA?

Business One has no catalogue of individually activated OData services. Instead, one Service Layer exposes all business objects under a single address. You need a Business One user with the right permissions rather than communication arrangements and a Cloud Connector. That makes the start simpler but puts more of the security burden on your own configuration.

With [SAP S/4HANA](https://www.ruebstudio.de/en/guides/ai-agent-integrations/connect-ai-agent-sap-s4hana) you activate specific APIs, bind them to technical users through communication arrangements and usually link on-premise systems to SAP BTP via the Cloud Connector. None of these layers exist in Business One: the agent talks directly to the Service Layer on the Business One server. The setting is also smaller. There is typically one server, or a system hosted by an SAP partner, a modest number of users and no in-house SAP Basis team. Where an S/4HANA project has an integration department to talk to, a Business One project usually goes through the partner that looks after the system.

## How does the Service Layer work?

SAP describes the Service Layer as an extension API built on HTTP and OData that exposes full business objects through a web server. It supports OData version 3 at `/b1s/v1` and version 4 at `/b1s/v2`. A client logs in, receives a session cookie and then calls business objects such as `Orders`, `Items` or `BusinessPartners`.

[SAP's Service Layer guide](https://help.sap.com/doc/fc2f5477516c404c8bf9ad1315a17238/10.0/en-US/Working_with_SAP_Business_One_Service_Layer.pdf) describes a three-tier design. Clients send HTTP/OData requests to an Apache-based web server, which reads and writes the Business One database. By default it is set up as a load-balanced cluster. Five building blocks matter for an agent.

### Login and sessions

Login is a POST to `/Login` with the company database, user name and password. The response sets a `B1SESSION` cookie that every following request must carry, plus an optional `ROUTEID` cookie that keeps the session on the same node.

```http
POST https://<server>:50000/b1s/v2/Login
Content-Type: application/json

{"CompanyDB": "<company-db>", "UserName": "<agent-user>", "Password": "<from secret store>"}
```

The guide gives a default idle timeout of 30 minutes, configurable in `conf/b1s.conf`. Your tool server should keep and reuse the session rather than logging in for every call, because SAP's guide describes login as a heavy operation in Business One. Since SAP Business One 10.0 FP 2305, users can also log in with a Windows domain account once Active Directory is connected.

### Business objects and metadata

`$metadata` describes every entity, property and action. That is the raw material for your agent's tools. From FP 2608, according to the guide, the OData V4 metadata carries annotations such as `Common.Label` with readable names, and supports targeted partial queries, because full metadata becomes very large once user-defined tables and objects are added.

In practice, do not let the agent wander through the metadata. Pick the handful of objects the use case needs, for example `Orders`, `DeliveryNotes`, `Items` and `BusinessPartners`, and describe their fields to the model in your own words.

### Queries with OData and SQL queries

For most reads, OData queries with `$filter`, `$select` and `$expand` are enough. Since FP 2011 there is also the `SQLQueries` entity: stored, parameterised SQL statements that can only touch tables on an allowlist. Regular users need an explicit permission to run them.

Stored SQL queries are useful for agents because they allow reports across several tables without handing the model open database access. The allowlist lives in `conf/b1s_sqltable.conf`. You may remove tables from it, but the guide states that adding tables is outside the scope of support. The Service Layer also normalises SQL syntax, so one stored query is meant to run on both HANA and SQL Server. Results are paged: the default is 20 entries per page, adjustable with the `Prefer: odata.maxpagesize` header.

### Writes and batches

Writes are ordinary POST, PATCH and action calls on business objects. Several changes can be grouped into one `$batch` request. According to the guide, transactions apply within a single request, including a batch, but never across separate requests.

This matters for agents. A chain of "create order, then delivery, then invoice" in three separate calls is not atomic. If the agent stops after step two, a half-finished process remains in the system. Related changes therefore belong in one batch, or in a workflow that detects partial states and resumes cleanly.

### Webhooks

From SAP Business One 10.0 FP 2602, the Service Layer supports webhooks. A new Webhook Messenger Service delivers notifications when, for instance, a sales order is created, updated or cancelled. Subscriptions are created through the `EventSubscriptions` entity.

The agent no longer has to poll for changes. It is triggered, fetches the affected data and handles the case. From FP 2608 the guide adds extra properties in the notification payload (`BizObjProps`) and formula-based event filters (`FilterExpr`). On earlier feature packages, scheduled polling, for example on document update dates, is the only option.

## Which variants are there: HANA, SQL Server, Service Layer or DI API?

The key distinction in Business One is the database. The Service Layer exists for the HANA edition and, according to the guide, for Microsoft SQL Server since 10.0 PL01. The core is the same, but some extras differ. There is also the older DI API, which is rarely a good fit for agents.

### SAP Business One, version for SAP HANA

On HANA the Service Layer has long been the standard route. It also exposes Semantic Layer views under `/b1s/v1/sml.svc`: prebuilt analytical views from the HANA analytics model, for example on purchasing prices or balance sheet data. These are handy for question-answering agents because the figures are already aggregated. Regular users still need explicit permission per view. In this edition the Service Layer typically runs on SUSE Linux Enterprise.

### SAP Business One, version for Microsoft SQL Server

On SQL Server the Service Layer typically runs on Microsoft Windows. Instead of Semantic Layer views, since 10.0 PL02 it can discover custom SQL views in the company database and expose them via OData; the guide says this applies to the SQL Server edition only. Attachments are worth checking: the attachment folder is usually a Windows share. A Windows-based Service Layer reads it directly, while on Linux the guide requires the share to be mounted first. That matters if your agent should attach documents to records.

Many older SQL Server installations were built around the DI API. Before starting, confirm that the Service Layer is installed at all and which feature package you run. Webhooks need FP 2602; the metadata annotations need FP 2608.

### Service Layer or DI API?

According to SAP's FAQ, the DI API derives from Microsoft COM and fits best in a native Windows environment, such as add-ons inside the Business One client. For an agent running as a service on a separate machine, the Service Layer is the right route. The DI API does offer a few things the Service Layer lacks.

The guide lists these Service Layer limitations compared with the DI API:

| Capability | DI API | Service Layer |
|---|---|---|
| Direct SQL (RecordSet) | yes | no, stored SQL queries only |
| Transactions across calls | yes | no, within one request only |
| XML import/export | yes | no |
| New UDFs/UDTs/UDOs usable at once | yes | only after a Service Layer restart |

For agents, the missing cross-call transactions and the lack of free SQL are more of a safeguard than a drawback. These are capabilities you would not want to hand to a model anyway.

### Business One hosted by a partner

Many companies do not run Business One themselves but have it hosted by their SAP partner. The Service Layer is then often not reachable from outside, and its address may change with an upgrade. Agree with the partner how the agent will reach it, for example through a VPN or a reverse proxy, and who checks after each upgrade that the integration still works.

## What do you need before you start?

Technically you need a reachable Service Layer on a known feature package, a dedicated Business One user for the agent and reasonably clean master data. Organisationally you need a decision on which steps the agent only prepares and which it may complete, plus clarity from your SAP partner on licensing and API use.

**Systems:**

- Service Layer installed and reachable over HTTPS with a valid certificate.
- Feature package known; webhooks need at least 10.0 FP 2602.
- A test company, ideally a copy of the live database, where the agent can work before it touches production.

**Users and permissions:**

- A dedicated user for the agent, never `manager` or a personal account. Whether it needs its own licence is something your partner can confirm against your contract.
- Permissions set as tightly as possible under Administration › System Initialization › Authorizations: read where the agent reads, full access only for objects it is meant to create.
- For stored SQL queries, a permission per query under the Service Layer SQL Query subject. Creating new queries stays with people.

**Data:**

- An item master with clear descriptions and units. An agent that drafts quotes is only as good as the item texts.
- Business partners without duplicates and with current contact persons.
- Documented user-defined fields. What sits in a `U_` field is often known only to whoever created it.

## How do you roll it out step by step?

The approach that holds up starts with a read-only agent on a test company and one well-defined process. Writing comes once the answers are reliable, and then as drafts first. Webhooks and further processes follow once the setup runs smoothly.

1. **Choose a process.** Something frequent and rule-based, such as delivery status questions or pre-entering requests for quotation.
2. **Define objects and fields.** Which Service Layer entities does the agent need, and which fields within them? Leave out everything else.
3. **Build narrow tools.** Each capability becomes its own tightly described tool, such as "delivery status for order number", not "run any OData query". The Model Context Protocol (MCP) is a practical way to offer these tools to different agents.
4. **Manage the session.** A tool server logs in once, holds `B1SESSION` and logs in again when the session expires. Credentials live in a secret store, never in the prompt.
5. **Test read-only.** Put real questions from daily work to the agent on the test company and check the answers against the Business One client.
6. **Drafts before postings.** Write tools first create draft documents (table ODRF, `Drafts` in the Service Layer), which a person reviews and converts into real documents.
7. **Wire up events.** On FP 2602 or later, subscribe to webhooks for the relevant objects so the agent is triggered by new or changed orders.
8. **Log everything.** Record every agent call with time, tool, parameters and result. That is what you need for troubleshooting and for deciding whether a step may one day run without approval.

Ready-made agents for recurring processes, such as [quotation](https://www.ruebstudio.de/en/ai-agents/quotation) or [technical service](https://www.ruebstudio.de/en/ai-agents/technical-service), build on exactly these steps. For an overview of such agents, see [AI agents](https://www.ruebstudio.de/en/ai-agents).

## What are the limits and risks?

The main risks are not in the Service Layer's technology but in permissions, half-finished processes and contractual questions. On top of that, the SAP API Policy only allows AI systems that plan or execute API calls through routes SAP has endorsed. How that applies to Business One is worth clarifying before you build.

**SAP API Policy.** [SAP API Policy v.4.2026a](https://help.sap.com/doc/sap-api-policy/latest/en-US/API_Policy_latest.pdf) limits use to published APIs for documented purposes. It also prohibits API use for interaction with (semi-)autonomous or generative AI systems that plan, select or execute sequences of API calls, except through architectures and pathways SAP has expressly identified for that purpose. The policy describes itself as part of the documentation of the SAP solution it is provided with; Business One is not named separately in its text. Whether and how it applies to your Business One installation depends on your contract and its documentation. Clarify this with your SAP partner and, where needed, a lawyer; this section is not legal advice.

**Half-finished processes.** Because transactions do not span requests, an agent that stops mid-chain can leave inconsistent data. Countermeasures: batches for related changes, drafts instead of postings, and a tool server that checks before each write whether the record already exists.

**Overly broad rights.** An agent with superuser rights can do anything the client can. A flawed prompt or a manipulated email is then enough to create wrong postings. A dedicated user, tight permissions and a short tool list limit the damage.

**Prompt injection via document text.** Free text in documents, remarks or attachments ends up in the model's context. Treat it as data, not instructions, and never let a write tool fire purely on the basis of such text.

**Upgrades.** Each feature package can change metadata, and according to the guide, new user-defined fields only appear after the Service Layer is restarted. Schedule a short test of the agent's tools after every upgrade.

**Load.** An agent stuck in a loop can flood the Service Layer with requests. Cap the number of calls per case in the tool server and use page sizes and `$select` rather than loading whole objects.

**When this is the wrong approach:** if master data in Business One is incomplete, or key information lives only in spreadsheets and people's heads, an agent will not fix that. Data cleanup comes first.

## How do I get started?

Start with an inventory: version and feature package, database, how the Service Layer is reached, and which partner supports the system. Then build a read-only agent for one process on a test company. After a few weeks of real use, decide from the logs whether drafts and further processes should follow.

A short checklist for the first conversation with your partner:

- Which version and feature package are you on, and when is the next upgrade?
- Is the Service Layer installed, and how can it be reached?
- Is there a test company, or can a copy be created?
- What licence does a technical user for the agent need?
- How does the partner read the SAP API Policy for your use case?

The general principles that apply to any system, including tool design, approvals and logging, are in [Connecting AI Agents to Business Systems](https://www.ruebstudio.de/en/guides/ai-agent-integrations/connect-ai-agents-to-business-systems). If you also run SAP S/4HANA, or plan to move to it, [Connecting an AI Agent to SAP S/4HANA](https://www.ruebstudio.de/en/guides/ai-agent-integrations/connect-ai-agent-sap-s4hana) shows the extra layers that come into play there.

## Frequently asked questions

### Do I need SAP BTP to connect an agent to SAP Business One?

Not technically: the Service Layer runs alongside the Business One server and is reachable over HTTPS. Whether an agent may use it outside a route SAP has endorsed depends on the SAP API Policy and your contract, so check with your SAP partner.

### Does the Service Layer work with the SQL Server edition?

Yes. According to SAP's guide, the Service Layer has supported Microsoft SQL Server since SAP Business One 10.0 PL01. Some extras differ: Semantic Layer views exist only on HANA, exposed SQL views only on SQL Server.

### Can the agent run arbitrary SQL against the database?

No. The Service Layer has no direct SQL access like the DI API's RecordSet object. Stored SQL queries are possible, but only against allowlisted tables and only for users who have been granted permission.

### Should the agent post documents directly?

It can, but starting with draft documents that a person reviews and posts in the client is the safer path. Direct posting makes sense only once the logs show the agent gets that process right.

### Is the DI API still an option for agents?

Rarely. The DI API is built on Microsoft COM and suits Windows add-ons inside the client, not an agent running as a service on another machine.

## Sources

- [SAP – Working with SAP Business One Service Layer, document version 1.29 (27 July 2026)](https://help.sap.com/doc/fc2f5477516c404c8bf9ad1315a17238/10.0/en-US/Working_with_SAP_Business_One_Service_Layer.pdf)
- [SAP API Policy v.4.2026a (SAP Help Portal)](https://help.sap.com/doc/sap-api-policy/latest/en-US/API_Policy_latest.pdf)
- [SAP Learning – Leveraging the SAP Business One Service Layer: API Terms and Documentation](https://learning.sap.com/courses/leveraging-the-sap-business-one-service-layer/introducing-service-layer-api-terms-and-documentation)
