SAP BUSINESS ONE AI
Connecting an AI Agent to the SAP Business One Service Layer

Service Layer, DI API and direct SQL are three different contracts. Only one of them is the right default.
- The Service Layer is the right primary interface: modern, REST, authenticates as a user, and drives the business objects on writes.
- The DI API shares object definitions with the Service Layer and suits deeper server side work, mainly for add ons.
- The Integration Framework is Java middleware for orchestrating flows between systems.
- Approved database views can serve heavy analytical reads, but writes must never go through the database.
- ChatFin uses the Service Layer as its primary interface, with reads optionally from approved views and writes always through the Service Layer.
This is a well informed question, because it recognises that SAP Business One has several interfaces and that choosing correctly matters. Each has a purpose, and using the wrong one for a given job is where problems start.
The short version: Service Layer for reading and writing, database views only for heavy analytical reads, and never a direct database write.
The Service Layer, the Primary Choice
The Service Layer is SAP Business One's modern REST interface, using OData, and it is the right primary choice for an AI agent.
It authenticates as a user through a session login, so the agent inherits authorisations, and it drives the business objects on writes, so documents stay valid. It works identically on SQL Server and SAP HANA.

The DI API
The DI API is a .NET library for deeper server side access, and it shares the majority of its object definitions with the Service Layer, so the two behave consistently.
It is mainly used by add ons running close to the SAP Business One client. For an AI agent it is a secondary option, useful where a specific operation is better served by it, with the Service Layer remaining primary.
The Integration Framework
The Integration Framework, B1if, is Java based middleware for orchestrating flows between SAP Business One and other systems.
It has a role where an agent's work genuinely involves several systems, or where your organisation has standardised on it for integration. It is not required to connect an agent to SAP Business One, because the Service Layer already provides that.
Approved Database Views for Reads
Heavy analytical reads over long histories against a busy production database are an operational risk. Approved, read only database views, or on HANA the analytical tools, can serve those.
The rule is strict: views may serve reads, never writes. A write must go through the Service Layer so the business object logic runs.
Why Writes Never Go Through the Database
A document created by direct database insert skips the validation, pricing, tax and journal logic the business object runs. It looks complete and behaves incorrectly.
This is the single most important rule in choosing interfaces: reads may have options, writes have exactly one correct path, the Service Layer or the DI API, both of which drive the object.
"Reads may have options. Writes have exactly one correct path, and it is never the database."

How to Choose
A simple rule covers almost every case.
Where ChatFin Fits
ChatFin uses the Service Layer as its primary interface, so it authenticates as a user and posts through the business objects. Where heavy analytical reads warrant it, they can come from approved views.
Writes always go through the Service Layer, and no direct database write exists anywhere in the design. Our page on the safest architecture covers how this fits together.

Service Layer for Everything, Views Only for Heavy Reads
ChatFin uses the SAP Business One Service Layer as its primary interface, optionally reads heavy analytics from approved views, and always writes through the Service Layer so documents are valid.
Reads may have options. Writes have one correct path, and it is never the database.
Where SAP Business One reporting runs out
SAP Business One handles transactions well. These five gaps are documented, and every one of them ends in a spreadsheet.
No native consolidation. Multi company consolidation means exporting each company's reports and combining them in Excel, which is why close week reruns the same pack repeatedly.
No transaction currency reporting. Native reports cannot produce statements in transaction currencies, which makes reconciliation harder and slows period end.
One accounting standard per company. B1 assumes a single reporting standard per managed company, so running US GAAP and IFRS in parallel means manual adjustment at consolidation.
Rigid report formats. A chart of accounts change forces manual restructuring of income statement rows rather than the report adapting.
Weak statutory mapping. You can hold an external code per GL account, but there is no mapping to multiple alternate charts and no way to run statements on them.
An agent connected over the Service Layer reads across companies and answers the consolidated question directly, which is the step that currently happens in Excel.
What a First Service Layer Connection Looks Like
An agent starts a Service Layer session by logging in with a B1 user name, password and the company database. That session carries the user's authorisations, so the agent can only reach what that user can reach. Sessions expire after a period of inactivity, so a well behaved agent logs in again when asked instead of holding one open indefinitely.
After login, each business object is an entity set with its own address, such as business partners or purchase invoices, and requests use standard OData options to filter, select fields and page through results. The first useful test is a plain read: fetch one business partner and compare it with what the B1 client shows. If the two match, the connection is sound.
Service Layer Calls an Agent Makes in Finance
These are the reads that come up first once the login works.
- Open items for one supplier. A clerk asks what is owed to a supplier. The agent filters purchase invoices by the supplier's business partner code and open status, then returns the list with due dates.
- A user defined field on the invoice. Your team added a field for the cost approver or a project code. The Service Layer returns user defined fields alongside the standard ones, so the agent can include them in a check once it has been told what the field means.
- A year of journal lines. An analyst wants every journal line for one account across a year. The agent pages through the results in batches and stops at the date range, instead of asking for the whole table at once.
- The session that timed out. A long reconciliation run outlives its login session. The agent logs in again and continues from the last record it handled, so the run does not stop halfway.
- A test company before production. The first calls go to a test company. The finance owner compares three or four documents on screen with what the agent returned before production access is considered.
Paul Barnhurst, known as The FP&A Guy, talks about data schema on the AgentCFO podcast.
“You need a good schema, a good understanding of your data. The better you can give that to AI, the better you can give it the context, the better answers it can give you.”
Quick Answers on the SAP B1 Service Layer
How does an AI agent log in to the SAP Business One Service Layer?
With a B1 user name, password and company database, which opens a session. Use a dedicated user for the agent so its authorisations are separate from any employee, and plan for the session to expire and be renewed.
Does the Service Layer return user defined fields?
Yes. User defined fields on a document or master record come back with the standard fields, so an agent can read and check them. It still needs a description of what each field means in your business.
How do I read a large amount of data through the Service Layer?
Filter by date or account and ask for results in pages instead of all at once. Select only the fields you need. Each call stays small and the load on the B1 server stays low.
What should I test first when connecting an agent to B1?
Read one business partner and one purchase invoice, then compare both with the B1 client. If the figures, dates and statuses match, move to a filtered list. Test writes last, and only in the test company.
Frequently Asked Questions
Which SAP Business One interface should an AI agent use?
The Service Layer as the primary choice, because it is a modern REST interface that authenticates as a user, so the agent inherits authorisations, and it drives the business objects on writes, so documents stay valid. It works identically on SQL Server and SAP HANA. The DI API is a secondary option for specific operations, and the Integration Framework has a role only where the work genuinely spans several systems.
Can an AI agent read SAP Business One through database views?
For heavy analytical reads over long histories, yes, approved read only database views or the HANA analytical tools can serve those without loading production. But the rule is strict: views may serve reads, never writes. A write must go through the Service Layer so the business object logic runs, or the document will look complete and behave incorrectly.
Why can writes never go through the database?
Because a document created by direct database insert skips the validation, pricing, tax and journal logic the business object runs. It looks structurally complete and behaves incorrectly, failing later in ways nobody connects back to the integration. Writes have exactly one correct path, through the Service Layer or DI API, both of which drive the business object.