> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowpayroll.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Build an integration

> Flow Payroll is built to sit behind other systems. Use your own IDs everywhere, send dated pay lines without tracking pay runs, and pick the pattern that fits: CSV, HR system of record, shift and agency platforms, or fully embedded payroll.

Flow Payroll is API-first. Every payroll action in the app (adding people, posting pay, locking a run, submitting to HMRC) is also available through the API. Flow Payroll is designed so that your system keeps its own records and never has to keep a copy of ours.

This page covers the design choices behind that, then four common integration patterns, from no code at all to a product where your customers never see Flow Payroll.

## Keep your own records, not ours

Most payroll APIs make you store their IDs, track their pay periods, and remember which run is open before you can send anything. Flow Payroll does that work for you.

### Use your own IDs

Send the identifier your system already uses. You never need a lookup table from your IDs to ours.

| Record | Where your ID goes | How you find it again |
| - | - | - |
| Employee | `id` on `POST /employees`. Leave it out and Flow Payroll generates one. | Use it as `{employeeId}` on every employee, pay line and payslip route. |
| Pay line | `id` on each line in `POST /payroll/line/{employeeId}`, such as your shift or timesheet ID. | Send the same `id` again to replace the line. `DELETE /payroll/line/{employeeId}/{lineId}` removes it. |
| Organisation | `externalId` on `POST /organisations`, such as the customer's ID in your platform. | `GET /organisations?externalId=` |
| Person who signs in | `externalId` on `POST /users`, or through [SCIM](https://docs.flowpayroll.ai/api-reference/administration/scim-provisioning.md). | `GET /users?externalId=` |
| Payroll ID reported to HMRC | `payrollId` on the employee. | `GET /employees/by-payroll-id/{payrollId}` |

The only Flow Payroll ID you send on every request is the organisation ID in `X-Org-Id` (see [Authentication](https://docs.flowpayroll.ai/api-reference/authentication.md)). Look it up from your own `externalId` when you need it. Pay elements are the only other set-up you map once: each line names the pay element it pays through.

### Send a date, not a pay run

A pay line carries a `date`, not a pay run, period number or tax year. Flow Payroll works out which pay run the line belongs to:

* A date in an open period lands in that period's pay run.
* A date in a period that is already locked lands on the day after the last locked period, so it is paid in the next open run instead of being rejected.
* The response gives the date Flow Payroll used as `payrollDate`, so you can see where each line went.

```json POST /payroll/line/{employeeId} theme={null}
[
  {
    "id": "shift-88213",
    "payElementId": "01JPAYELEMENT0000000BASIC",
    "date": "2026-11-27",
    "description": "Night shift, Leeds depot",
    "unitName": "Hour",
    "units": 8,
    "payRate": 14.5,
    "canEdit": false
  }
]
```

Your system never has to know the payroll calendar, and a late timesheet still gets paid.

`canEdit: false` makes a line yours. Only the integration that created it can change it. Nobody else can, in the app or through the API.

### Open the next pay run in one call

`POST /payroll/{payrollConfigId}/next` opens the next pay run for a pay schedule, picking the period that follows the last one. Send `paymentDateOverride` to move the pay day for that run. Subscribe to `payroll_run.opened` to hear when a run opens, whoever opened it.

### Send it again safely

Integrations retry, so the API is built for it:

* A pay line sent again with the same `id` replaces the earlier version. If its period is already locked, the request answers `409` and nothing is written.
* `PUT /employees/{employeeId}/working-schedule` merges rota weeks by week-commencing date, so sending the same week twice does not duplicate it.
* `POST /organisations` and `POST /organisations/bulk` accept an `Idempotency-Key` header, so a retry after a lost response cannot create a second organisation.

### Listen instead of polling

[Webhooks](https://docs.flowpayroll.ai/api-reference/webhooks/overview.md) tell your system the moment a payslip is created or finalised, an employee changes, a pay run locks, or HMRC accepts an FPS. One [account-wide endpoint](https://docs.flowpayroll.ai/api-reference/webhooks/account-wide-endpoints.md) covers every organisation you manage.

### Use only the modules you need

Flow Payroll is modular. Pay, salary, statutory pay, pensions, court orders, holiday, payments, journals, reports and webhooks each have their own API, listed in the [introduction](https://docs.flowpayroll.ai/api-reference/introduction.md#api-families). Start with one and add others later, or keep doing some of the work in your own system and send the result as pay lines.

Each module takes your own data and settings:

* [Pay elements](https://docs.flowpayroll.ai/guides/setup/pay-elements.md) you define, for any pay or deduction your business has.
* Pay lines your system owns, with tags carried onto the payslip.
* [Roles of your own](https://docs.flowpayroll.ai/api-reference/administration/users-roles-and-permissions.md#roles-of-your-own) for each person and token.
* [Report definitions](https://docs.flowpayroll.ai/api-reference/reports/overview.md) for any question about your data.
* Your brand, email wording and support desk.

New capabilities arrive as new modules or new fields alongside existing ones, so nothing you already call changes underneath you. A field is only ever deprecated with at least 90 days' notice (see [Deprecations](https://docs.flowpayroll.ai/api-reference/deprecations.md)).

## Integration patterns

Pick the pattern closest to your product. You can combine them, for example an HR system that owns employee records alongside a rota tool that sends hours.

> [card] [1. CSV with saved mappings](#1-csv-with-saved-mappings)
>
> No code. Export from any system as-is and import in one click.

> [card] [2. HR system of record](#2-hr-system-of-record)
>
> Your HR platform owns people and salaries. Payroll can't overwrite them.

> [card] [3. Shifts, agencies and workforce management](#3-shifts-agencies-and-workforce-management)
>
> Send each shift as it happens and see pay update throughout the period.

> [card] [4. Embedded payroll](#4-embedded-payroll)
>
> You own the interface. Flow Payroll runs underneath, under your brand.

### 1. CSV with saved mappings

**For:** teams without developers, systems without an API, and moving from another payroll provider.

Export a file from your HR platform, rota tool or old payroll software exactly as it comes out. The [CSV importer](https://docs.flowpayroll.ai/guides/setup/csv-imports.md) maps your columns to Flow Payroll's fields. Save the mapping once and every later export from the same system is recognised automatically.

![The Map Columns step of the CSV importer, matching a file's columns to Flow Payroll employee fields](https://mintcdn.com/flowpayroll-1ca487e0/sdWnuVlMeo8I5hB7/images/screenshots/csv-import-employee-mapping.png?fit=max\&auto=format\&n=sdWnuVlMeo8I5hB7\&q=85\&s=f670dec3139ad0713082c71aee953bab)

* Import employees, payments, pay elements, journal templates and statutory payments with the same wizard.
* Moving payroll provider? The [onboarding data templates](https://docs.flowpayroll.ai/onboarding/data-templates.md) and a [parallel run](https://docs.flowpayroll.ai/onboarding/parallel-run.md) take you through it.
* Move to the API one area at a time later. CSV and API data live side by side.

### 2. HR system of record

**For:** HR and people platforms that want payroll to follow their data, never the other way round.

Your platform stays the single source of truth for people, salaries and working patterns. Flow Payroll runs payroll from what you send, and payroll staff can't change the details you own.

**1. Create organisations and people from your platform**

Add each customer with `POST /organisations`, setting your own `externalId` and an `Idempotency-Key`. Give people access with `POST /users` or provision them from your identity provider through [SCIM](https://docs.flowpayroll.ai/api-reference/administration/scim-provisioning.md), each with your `externalId`. If your account signs people in through your identity provider, they sign in with single sign-on.

**2. Connect with an HR integration token**

Issue an [API token](https://docs.flowpayroll.ai/api-reference/administration/overview.md#api-tokens) with the **HR integration** role. It adds new starters and keeps employee details, payroll details, working patterns, organisation details and people up to date. Use **HR sync** for a token that shouldn't manage people.

**3. Send employees under your own IDs**

Create each employee with `POST /employees`, using your employee ID as `id`. Record pay changes with `PUT /employees/{employeeId}/salary`, effective-dated so mid-period changes are pro-rated. Record leavers with `PUT /employees/{employeeId}/leaver`. If you only hold HR details, save the employee without a `payrollConfigId`. They wait until the payroll team adds the payroll details.

**4. Stop details being changed in Flow Payroll**

Give payroll staff a [role of your own](https://docs.flowpayroll.ai/api-reference/administration/users-roles-and-permissions.md#roles-of-your-own) that has `employee:read` but not `employee:write`. They still run payroll and keep tax codes and NI up to date, but names, salaries, bank details and other employee details can only change from your platform. Send pay lines with `canEdit: false` so only your integration can change them.

**5. Get payroll results back**

Subscribe to `payslip.finalised` to put payslips in your employee portal. Each event links the payslip PDF in `metadata.documentUrl`.

### 3. Shifts, agencies and workforce management

**For:** rota and time-and-attendance tools, staffing agencies, and gig or shift platforms.

Hours change daily, so this pattern sends pay as it happens rather than as one batch at the end of the period.

* **Send each shift as a pay line** with its own `id` and the date it was worked. Flow Payroll puts it in the right pay run. Fix a shift by sending it again with the same `id`, or remove it with `DELETE`.
* **Bill clients from the same line.** Agencies set `clientId`, `chargeRate` and `chargeUnits` on the line, and Flow Payroll invoices the client at the charge rate, separately from what the worker is paid. See [clients](https://docs.flowpayroll.ai/guides/bureau/clients.md) and [invoices](https://docs.flowpayroll.ai/guides/bureau/invoices-and-billing.md).
* **Push the rota** with `PUT /employees/{employeeId}/working-schedule`, one week or many. Holiday and statutory pay then work from the hours you rostered.
* **See pay before pay day.** `GET /payslip/data/{employeeId}/{year}/{period}` returns the payslip as it stands at any point in the period, with tax, NI and pension worked out. Subscribe to `payslip.created` and `payslip.updated` to hear when it changes. For a quote before any shift is worked, use the gross-to-net calculator, `POST /calculator/grosstonet`.

### 4. Embedded payroll

**For:** software platforms that sell payroll as part of their own product.

You build the interface. Flow Payroll does the calculations, HMRC filing, pensions and payslips through the API, so your customers stay in your product.

* **Run the whole cycle by API.** Add employees, post pay lines, preview payslips, lock with `POST /payroll/{payrollConfigId}/{year}/{period}/lock`, and submit the FPS with `POST /rti/fps/{payrollConfigId}/{taxYear}/{period}`. [A typical payroll run](https://docs.flowpayroll.ai/api-reference/introduction.md#a-typical-payroll-run) walks through it.
* **One account, many customers.** Each of your customers is an organisation with your `externalId`. One API token can reach all of them, and you pick the organisation per request with `X-Org-Id`.
* **Your brand everywhere Flow Payroll shows.** [White label](https://docs.flowpayroll.ai/api-reference/administration/overview.md#branding) puts your name, logo, colours, fonts, web address and sending domain on the app, emails and payslips. Customers who open the app see your product, and the [support panel](https://docs.flowpayroll.ai/api-reference/administration/partner-support-panel.md) shows your own help desk there too.
* **Single sign-on and provisioning.** People sign in through your identity provider, and SCIM keeps their access in step with your directory.
* **Build safely.** Build against the sandbox, which is isolated from live data. See [Build and test your integration](#build-and-test-your-integration).

## Build and test your integration

Whichever pattern you choose, build it against the sandbox first. Sandbox data is isolated from live, so you can create, change and delete anything.

The slow part of testing payroll is setting up the scenario: an organisation, employees with the right tax codes and pay elements, a pay run in the right period. Flow Payroll publishes two [MCP servers](https://docs.flowpayroll.ai/api-reference/mcp-server.md) so an AI assistant such as Claude Code or Cursor can do that for you.

| Server | What your assistant can do | Changes data |
| - | - | - |
| Docs | Search and read every page of this site, so it answers from the current docs. | No |
| Sandbox API | Find, explain and call every endpoint, using your sandbox credentials. | Yes, in your sandbox organisation only |

Connect both and describe the scenario you want in plain English:

* "Add five monthly employees, one with a student loan and one starting maternity leave this month."
* "Post a week of night shifts for each of them, then show me their payslips."
* "Make one of them a leaver and show me what changes on the FPS preview."

Then point your own integration at the same sandbox and check it handles what the assistant set up. The sandbox API server can only reach `api.sandbox.flowpayroll.ai` and rejects any other host, so it can never touch live data, whatever credentials it is given.

To import the whole API into a client instead, use [Use in Postman](https://docs.flowpayroll.ai/api-reference/use-in-postman.md).

> [!TIP]
>
> Building payroll into your own product? [Embedded payroll for software platforms](https://flowpayroll.ai/solutions/software-platforms) covers commercial terms and white-label pricing. To talk through your integration, email [hello@flowpayroll.ai](mailto:hello@flowpayroll.ai).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.