For the complete documentation index, see llms.txt. This page is also available as Markdown.

Overview

Connect your customers' accounting systems from your backend.

With headless onboarding, your application manages the connection screens for your customers. Your backend sends their authorization or credentials to the Consent API. Zwapgrid checks access, connects the accounting system and accepts the Consent.

This guide is for developers building that backend. In these guides, you means the client integrating with Zwapgrid; your customer means the company connecting its accounting system.

Your backend must complete three steps:

  1. Create a Consent for your customer.

  2. Obtain authorization or credentials for their accounting system.

  3. Send one connection request to Zwapgrid.

After a successful response, you can optionally check the connection and read accounting data.

For OAuth systems, your customer still signs in and approves access at the provider. Zwapgrid manages token refresh after the connection is complete. You can also use the guided Onboarding Flow to let Zwapgrid host the connection screens.

Preview

Headless Onboarding is in Preview. The feature and its API may change or improve with short notice. Check the documentation when updating your integration.

Before you start

You need:

  • The accounting system enabled for your client in the Client Portal.

  • A published System Setting for the application or provider environment you will use. Your system's guide explains the requirements and any supported defaults.

Security

Keep each onboarding attempt bound to the correct customer session and Consent, and confirm that the selected company is the one your customer intends to connect. For OAuth, validate state at your backend callback before using the code. Keep credentials on your backend and never share them between customer sessions. Mixing sessions or credentials can connect the wrong company and expose its data.

Choose your system

Each system has a different connection request. Open its guide for the exact steps and JSON body.

System and guide

source value

What you send

How the company is chosen

fortnox

Unused authorization code and redirect URI

Your customer authorizes the company in Fortnox

xero

Access token, refresh token and tenant ID

Your backend selects an accessible organization

businesscentral

Access token, refresh token, tenant, environment and company

Your backend selects an environment, then a company

procountor

Unused authorization code and redirect URI

Your customer selects the company in Procountor

bokio

Unused authorization code and redirect URI

Your customer selects the company in Bokio

vismaeaccounting

Unused authorization code and redirect URI; PKCE verifier if used

Your customer selects the company in Spiris

bjornlunden

Company public key

The key identifies the company

vismanetvisor

User identifier, customer key and business ID

The business ID identifies the company

Set up the examples

Run the cURL examples on your backend. Replace placeholders such as <consent-UUID> with your own values. Set these variables before running a request:

Variable
Value to use

CONSENTS_API_BASE_URL

The Consent API base URL from the API Reference, without a trailing slash or /api/v1. Keep any gateway prefix included in the base URL.

ZWAPGRID_API_KEY

Your backend API key for the selected client and environment.

CORRELATION_ID

A new non-empty UUID for each request. Also called a GUID; retain it to help trace requests with support.

CONSENT_ID

The Consent ID returned when you create a Consent in step 1.

Keep API keys, application secrets, codes and tokens on your backend. Exclude OAuth callback query parameters from logs and redirect to a clean URL after processing. Never include credentials in browser storage or support messages.

The examples read JSON from a file. Restrict the file to your backend user and delete it when finished. In your application, use protected memory or secret storage for credentials.

OAuth scopes

Use the scopes listed in your system's guide. Where scopes are configurable in your Published System Setting, use the same scopes in that setting and your backend authorization request.

Create one new Consent for the company you want to connect. Use the same client and API-key environment for Consent creation, connection creation and accounting reads.

Select your published setting in systemsSettings, using the source value from the table above. For example, save this Fortnox request as consent.json:

Then send it:

The response is HTTP 201. Take the Consent ID from the response's Location header and set CONSENT_ID to that ID.

The setting must be Published and belong to your client and accounting system. Fortnox, Xero, Business Central, Procountor, Spiris and Bokio require you to select your application's setting on the Consent. For Björn Lundén and Netvisor, follow the guide if you intend to use a default. Choose settings here, before creating the connection.

See Create Consent for more details. The Consent must still have status Created and no existing connection when you submit credentials.

2. Follow your system's authorization steps

Open your system guide and complete its authorization or credential-collection steps. It explains what you must do and what Zwapgrid handles.

For OAuth, your backend must check the callback's state value against a random, expiring value stored for that customer's session and Consent. This confirms that the callback belongs to the connection you started.

  • Fortnox, Procountor, Spiris and Bokio: send the unused code to Zwapgrid. Zwapgrid exchanges it for tokens.

  • Xero and Business Central: your backend exchanges the code and selects the company first, then sends tokens and the selected company details to Zwapgrid.

  • Björn Lundén and Netvisor: collect the company credentials described in the guide. There is no customer OAuth callback.

3. Send the connection request

Use the JSON body and cURL command in your system guide to call:

Use your x-api-key, a new UUID in x-correlation-id, and Content-Type: application/json. Send only the documented fields. The maximum body size is 16 KiB; query parameters and additional fields are rejected. Application secrets stay in System Settings.

Send the request once. Turn off automatic retries for this POST, including retries after timeouts. If you cannot tell whether it succeeded, check the connection as described below.

A successful response is HTTP 201 with this body and Cache-Control: no-store:

Zwapgrid has completed the connection and accepted the Consent. It does not return credentials or tokens. A connection request cannot replace an existing connection.

Optional: Verify the connection

After a successful HTTP 201 response, no additional request is needed to complete headless onboarding. You can use the GET below to check the connection. Use this same GET to recover the result if the POST response is lost.

Set a new CORRELATION_ID, then read the connection:

HTTP 200 returns the same id, source and state: completed. Check that they match the connection you created.

You can also read accounting data using that Consent to verify data access. This is optional and is not required to complete headless onboarding.

If the result is uncertain

If POST times out or you lose its response:

  1. Do not submit the credentials again. Run the connection GET above for the same Consent.

  2. If GET returns 200 with the expected completed connection, onboarding is complete.

  3. If it returns 404, confirm the Consent ID, client and API-key environment. A missing connection does not mean a code is unused or a refresh token is still valid.

  4. If you still cannot confirm the result, contact Zwapgrid support with the Consent ID, UTC timestamp and correlation IDs for both requests. For OAuth systems, authorize again if you cannot confirm whether the code or tokens are still usable.

For Xero and Business Central, stop any refresh running in your backend and wait for it to finish before submitting tokens. Keep it stopped while checking an uncertain result. After success, let Zwapgrid refresh this authorization; do not refresh it yourself or use the same refresh tokens for another connection.

Authorization codes can be used once, and a refresh can replace the submitted refresh token before a later step fails. This is why repeating a POST after a lost response is unsafe. The correlation ID helps trace requests; it does not make repeated requests safe. Send one connection request at a time for a Consent.

Common errors

HTTP status
What to do

400

Check the request fields, selected settings and access to the selected company. For a used or expired OAuth code, authorize again.

401 / 403

Check your API key and whether the system is enabled for your client.

404

Check the Consent ID, client and API-key environment. After an uncertain POST, follow the recovery steps above.

409

Check the Consent's current status and connection. It may already be linked, inactive or have another connection request in progress.

413

Keep the body within 16 KiB and use only the fields in your system's example.

429

Wait before reading again, following any retry guidance. Do not automatically repeat a connection POST.

502 / 503 / 504

Check the connection with GET and retain correlation IDs for support.

API reference

See the API Reference for Consent and Accounting operations, including connection creation and recovery. Use these guides for the complete onboarding workflow and system-specific examples.

Last updated

Was this helpful?