Bokio
Complete Bokio onboarding from your client backend.
Preview · What this means for your integration
Your customer authorizes a company in Bokio. Your backend sends the unused authorization code and exact callback URL to Zwapgrid. Zwapgrid exchanges the code, checks company access and manages token refresh.
First, complete the shared prerequisites and example setup.
What you need
Your own Bokio public integration, with your backend callback registered and the resource scopes your integration needs approved. See the Bokio setup guide.
A Published Bokio System Setting belonging to your Zwapgrid client and containing that application's ID and secret.
A company subscription that includes Company API access for public integrations: Plus or Business, or Premium with the Integrations (API) add-on. Basic does not include it. All API features are available during the 14-day Bokio trial, regardless of plan. See Bokio price plan requirements.
The OAuth scopes below, approved for your application and selected in its Published System Setting.
This flow connects one company per Consent through the Company API. Agency API access, General API tokens and Bokio marketplace entry are outside this flow. Your customer chooses the company during Bokio authorization; there is no further company-selection request in Zwapgrid.
OAuth scopes
Use the scopes selected in your Published Bokio System Setting so Zwapgrid can access your customer's accounting data. Include invoices:read.
1. Prepare the connection
Use the Consent created in the shared workflow. Set
systemsSettings.bokioto your Published System Setting ID before starting authorization.Start authorization at
https://api.bokio.se/v1/authorizewithresponse_type=code, yourclient_id, the exact registeredredirect_uri, approved resourcescopevalues includinginvoices:read, and a random, expiringstatebound to the customer's session and Consent. Separate scope values with spaces.Your customer signs in, selects the intended company and approves access.
At your backend callback, validate
stateagainst the stored value and consume it once. Retain the unused code securely without exchanging it.Send the connection request once within five minutes. Zwapgrid exchanges the code using the selected application and exact redirect URI, then verifies access to the company returned by Bokio before completing the connection.
Keep any callback used by guided onboarding registered. Confirm Bokio's callback registration limits or use a separate application for headless onboarding. This connection request does not accept a PKCE verifier. Confirm your application's requirements with Bokio before using this flow if its registration requires PKCE.
Use the scopes from your Published System Setting in the authorization parameters:
URL-encode these parameters when building the authorization URL. See Bokio OAuth and resource scopes for provider requirements. Your Zwapgrid API-key environment does not select a Bokio test company or application; choose those in Bokio.
2. Send the request
Save this body as a protected connection.json on your backend:
Both fields are required, nonblank and limited to 2048 characters each. Use the exact redirect URI from authorization: HTTPS, without fragments or user information. For local development, register an HTTPS callback; see Bokio callback requirements. Send only these fields; do not supply tokens, a company or tenant ID, an application secret or codeVerifier.
Set the example variables, including a new UUID in CORRELATION_ID, then send the request once:
Your application secret stays in System Settings. The selected setting must match the Bokio application used for authorization.
3. Check the result
Expect HTTP 201 with:
The connection is complete and the Consent is accepted. Zwapgrid uses the company identity returned by Bokio and the selected application for subsequent refresh. You can optionally verify the connection and read accounting data.
OAuth authorization and code exchange can succeed even when the company subscription lacks API access. If company verification fails, check invoices:read, the authorized company and its subscription before starting fresh authorization. The connection is completed only after company access is verified.
Codes are single-use. If the POST response is lost or uncertain, read the authoritative connection with GET. A GET 404 does not prove the code is unused. Do not automatically repeat POST; authorize again with a fresh code if you cannot confirm the result or if company validation failed after exchange.
Bokio rotates refresh tokens when used and expires unused refresh tokens after 30 days. Let Zwapgrid manage refresh after connection creation. If refresh can no longer succeed, your customer must authorize again through a new onboarding attempt; a connection request cannot replace an existing connection.
Last updated
Was this helpful?
