All posts

Embedded Accounting for SaaS

What it takes to put Swedish bookkeeping inside your SaaS today: company provisioning in one POST, scoped keys, webhooks, and the parts still on you.

If your SaaS serves Swedish small businesses or freelancers, accounting is about the stickiest feature you can add. Customers don't churn out of the system that holds their verifikat. This is what the integration looks like against the product as it is today, including the part that isn't built yet.

What you can build on now

  1. A REST API with 280+ endpoints, OpenAPI 3.1, at https://app.accounted.se/api/v1, with structured errors and recovery hints.
  2. Company provisioning. POST /api/v1/companies creates a company ready for bookkeeping in one call.
  3. Scoped API keys, created at /settings/api. They act as the user who created them, writes take an Idempotency-Key, and most support dry-run.
  4. An MCP server with 200+ tools over OAuth 2.1, if you want your customers' books reachable by an agent too.

The core is AGPL-3.0 on GitHub, so you can read exactly what you're integrating against, or self-host it.

The seam in onboarding

The API can't do the parts that are legally tied to a person. BankID identification, the Skatteverket connection and the bank consent all need your customer, and inviting a user to a company happens in the app. So the shape is:

  • Your platform creates the company over the API.
  • Your customer is invited and connects bank and Skatteverket once, with their own BankID.
  • Your product then works in their books through your key, or the customer authorises your platform over OAuth 2.1.

That's fine for a platform with a few hundred high-value customers. For a self-serve product with thousands of signups, design your activation around it.

The integration shape

Create a company, or list the ones a key reaches

curl -X POST https://app.accounted.se/api/v1/companies \
  -H "Authorization: Bearer gnubok_sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"name":"Acme AB","entity_type":"aktiebolag","org_number":"5566778899","vat_registered":true,"moms_period":"quarterly","f_skatt":true}'

curl https://app.accounted.se/api/v1/companies \
  -H "Authorization: Bearer gnubok_sk_live_..."

With a live key the POST creates a real company, and bookkeeping duty starts with it. A test key returns a dry-run preview instead.

Work in one company's books

Everything is nested under a company ID, so it's never ambiguous which ledger you're writing to.

curl https://app.accounted.se/api/v1/companies/{companyId}/transactions \
  -H "Authorization: Bearer gnubok_sk_live_..."

Reports, invoices, suppliers, journal entries, employees and SIE export all follow the same shape.

React to changes

There are 28 webhook event types, among them invoice.paid, journal_entry.committed, period.locked and transaction.categorized. Subscribe with webhooks:manage, inspect deliveries per subscription and retry with POST /api/v1/webhook-deliveries/{id}/retry. Payloads are signed with HMAC-SHA256 in X-Gnubok-Signature. If you'd rather poll, events:read exposes the same event log.

Scopes are the security model

There's no partner-level credential. A key reaches the companies its user belongs to and nothing else, with only the scopes it carries. If your platform's user owns every company it creates, one key reaches all of them, so guard it accordingly.

ScopeWhat it unlocks
transactions:readList transactions, category suggestions
transactions:writeCategorise, match against invoices, receipt matching
invoices:read/writeCustomer ledger, create, send, mark paid, credit
reports:readTrial balance, general ledger, VAT, KPI, SIE export
webhooks:manageCreate and manage webhook subscriptions
companies:writeCreate companies, update company settings

A key that can both stage a write and approve it is blocked unless the user explicitly acknowledges the combination, because it would let an agent post to the books with nobody reviewing. A key can also carry an unattended commit limit in SEK, above which a human approves.

You build the UI

There is no embeddable component library. You get the API, the OpenAPI spec and llms.txt to point a coding agent at. The categorisation flow, the reports view and the invoice form are yours, in your design system, on your domain.

For a team with a competent frontend, a usable surface for categorisation, invoices and the three core reports is weeks of work. The compliance-heavy parts, like VAT rules, period locking, SIE and BAS validation, are the ones you don't build.

Who owns what

Your end customer is the obligated party under Bokföringslagen and the data controller under GDPR. Your platform is a processor and Accounted a sub-processor. Your customer can export complete SIE4 at any time and you can't delete their books on your own, so design offboarding assuming they leave with everything.

Every state change is an event attributed to a user and a session, and a revisor can read it directly. Filings stay between your customer and Skatteverket, signed with BankID by a person. You can surface "file your VAT return" in your product, but you can't file from your backend.

Before you commit

Check that your customers are Swedish-registered companies, since the value is doing one country properly. Check that your activation funnel survives the one-time BankID step. And have a monetisation story, because accounting given away for free tends to be treated as a low-value feature.

Then create a gnubok_sk_test_* key and call /api/v1/companies before you plan anything. For the bigger picture read The Accounting API for the AI Era and Building on an Open Source Swedish Ledger, and for platform terms contact us via /byraer.

Frequently asked

Why would a SaaS want to embed accounting?
Stickiness and revenue. Customers rarely leave when their books live inside your product, and a per-customer accounting subscription stacks on top of your existing price. For vertical SaaS in e-commerce, freelance platforms or agency tooling it's often the obvious upsell.
Can I provision a new customer's books via API?
Yes. POST /api/v1/companies (scope companies:write) creates the company with its BAS chart, first fiscal period and tax deadlines in one call. It isn't idempotent, so list companies before retrying after a network error. Inviting your customer as a user happens in the app.
How is one customer's data isolated from another's?
Every company is a separate ledger with its own accounts, periods and audit log. An API key acts as the user who created it, reaches only the companies that user belongs to, and only with the scopes it carries. A viewer membership is refused for every write.
What's the commercial model?
There's no published embedded price list. Hosted companies are priced per company (see /priser), and platform terms are set after a review of your volume and use case. Start at /byraer.
Next

Start building.

REST + MCP. Open source under AGPL. SIE4 in, SIE4 out. Self-host or use the managed version.