Prerequisites
- A Dolfin API key (distributed during onboarding)
Overview
The integration follows three phases:1
Create an organisation and users
Your backend creates an organisation and provisions users into it using your API key.
2
Generate auth codes
When a user needs to access Dolfin, your backend generates a short-lived auth code for that user.
3
Exchange for a session token
The user’s browser exchanges the auth code for a session JWT, which is used for all subsequent API calls.
Step 1: Create an Organisation
First, create an organisation for the SMB business. You’ll need anindustryId - retrieve the list of available industries from GET /v1/industries.
Store the
id from the response - this is the organisationId you’ll use in all subsequent calls.Step 2: Create Users
Now create users within the organisation. Pass an optionalrole — Member, Admin, or Owner — to set what the user can do. Omit it and the user is created as a Member.
Provisioning with your API key acts with your client’s authority, so you can grant any role, including Owner. Most integrators make the person who signs up for the organisation its Owner, and add colleagues as Member or Admin.
A user acting with a session token can never grant a role above their own — an
Admin can add Members and Admins, but not an Owner. Attempting it returns 403 User.RoleAboveCaller.User 1: Alice
User 2: Bob
If a user with the same email already exists, they will be added to the organisation rather than duplicated. A
409 Conflict is returned if the user is already a member of that organisation.Step 3: Generate an Auth Code
When a user needs to access Dolfin (e.g. they click “Open Invoicing” in your app), generate a short-lived auth code from your backend.Step 4: Exchange the Auth Code for a Session Token
Pass the auth code to the user’s browser (e.g. as a URL parameter in a redirect). The browser then exchanges it for a session JWT. This call is made from the browser and does not require an API key.token is a JWT valid for 8 hours.