> ## 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.

# Payroll for AI agents

> Where the Flow Payroll API is heading: MCP for agentic workflows, a preview for every calculation, responses that explain how each figure was reached, and a reporting API an agent can query freely.

AI agents are good at understanding a request and bad at doing payroll maths. Flow Payroll is built to split that work cleanly. Your agent decides what to do, Flow Payroll does every calculation, and the API returns the result with enough context for the agent to explain it to a person.

This page describes that direction. Each section says what is **available now** and what is **on the roadmap**.

> [!WARNING]
>
> Roadmap items describe where the API is heading, not a commitment to a date or a final shape. Field names in roadmap examples are illustrative. Anything that ships is announced in [What's new](https://docs.flowpayroll.ai/api-reference/whats-new.md) and documented in the reference first.

| Capability | Status |
| - | - |
| Same response envelope on every endpoint | Available now |
| A preview for every calculation | Available now |
| Reports API with a self-describing field catalog | Available now |
| MCP servers for the docs and the sandbox API | Available now |
| Pay lines only their creator can change | Available now |
| An explanation of how each figure was reached, on the response | Roadmap |
| MCP for live organisations, limited by role | Roadmap |

## One response shape an agent can learn once

**Available now.** Every endpoint in every service wraps its answer in the same [envelope](https://docs.flowpayroll.ai/api-reference/response-format.md): `content.data` holds the result, `content.metadata` holds context about it, and `message.token` names the outcome in a form that never changes. An agent learns that shape once and can read any endpoint, and it can branch on `message.token` instead of reading error prose.

**On the roadmap: an explanation alongside the data.** The envelope gains a third item next to `data` and `metadata`, holding how Flow Payroll reached the figures it returned. On a payslip, that is the path from gross pay to net pay: which rules applied, with which thresholds, and why.

```json Illustrative — the shape isn't final theme={null}
{
  "message": { "text": "Operation completed successfully", "token": "operationCompletedSuccessfully" },
  "content": {
    "data": { "grossPay": 3000.00, "netPay": 2354.14 },
    "metadata": { "dateFormat": "yyyy-MM-dd" },
    "explanation": {
      "summary": "Net pay is £2,354.14: £3,000.00 gross, less £124.00 pension, £365.70 income tax and £156.16 National Insurance.",
      "steps": [
        { "step": "grossPay", "amount": 3000.00, "because": "Annual salary of £36,000.00, paid monthly." },
        { "step": "pension", "amount": -124.00, "because": "5% of qualifying earnings above the £520.00 monthly lower limit, taken before tax." },
        { "step": "incomeTax", "amount": -365.70, "because": "Tax code 1257L gives £1,047.50 tax-free this month. 20% of the remaining £1,828.50." },
        { "step": "nationalInsurance", "amount": -156.16, "because": "Category A. 8% of pay above the £1,048.00 monthly primary threshold." }
      ]
    }
  }
}
```

Your system keeps the explanation with the payslip. When an employee asks your assistant "why is my pay lower this month?", the agent answers from the explanation for that payslip. It doesn't recalculate anything or guess at tax rules, so its answer matches the payslip.

Pension contribution lines already work this way. Each one carries the basis it was calculated on (`basis`: `Pensionable` or `QualifyingEarnings`) in its line metadata.

## Previews for deterministic answers

An agent should never work out tax, NI, statutory pay or pension contributions itself. Every calculation in Flow Payroll can be previewed, so the agent asks Flow Payroll for the exact figure and shows it to a person before anything is final.

**Available now.** Paths are relative to each service's base path.

| Question an agent is asked | Preview to call |
| - | - |
| What will this person take home this period? | `GET /payslip/data/{employeeId}/{year}/{period}` (Pay API), the payslip as it stands |
| What would a salary of £X pay after tax? | `POST /calculator/grosstonet` (Pay API) |
| What will this salary change produce this period? | `POST /employees/{employeeId}/calculate` ([Salary](https://docs.flowpayroll.ai/api-reference/salary/overview.md)) |
| How much maternity, paternity or sick pay is due? | `POST /calculations/preview` and `POST /calculations/employees/{employeeId}` ([Statutory pay](https://docs.flowpayroll.ai/api-reference/statutory-pay/overview.md)) |
| Will this person be auto-enrolled? | `POST /auto-enrolment/assessments/preview` ([Pensions](https://docs.flowpayroll.ai/api-reference/pensions-v2/overview.md)) |
| What would their opt-out refund be? | `GET /employee-pension/{employeeId}/refund-preview` (Pensions) |
| What will we send HMRC? | `preview` on the FPS and EPS submission routes (Pay API) |
| What will their P45 say? | `GET /p45/{employeeId}/preview` ([HMRC P-forms](https://docs.flowpayroll.ai/api-reference/hmrc-p-forms/overview.md)) |
| What journal will this pay run post? | `POST /templates/{templateId}/preview` ([Payroll journals](https://docs.flowpayroll.ai/api-reference/journal/overview.md)) |

Nothing in a pay run is final until it locks. Until then, the payslip preview reflects every court order, holiday, recurring item and pay line sent, and you can replace or remove anything that isn't right. An agent can show a person exactly what pay day will look like and act only once they confirm. When explanations arrive on responses, previews carry them too.

## A reporting API an agent can query

**Available now.** The [Reports API](https://docs.flowpayroll.ai/api-reference/reports/overview.md) answers questions that no fixed report covers. An agent:

1. Lists the datasets with `GET /datasets`: payslips, payslip lines, pay runs, statutory pay, court orders, holiday, pensions, journals, invoices and more.
2. Reads a dataset's field catalog with `GET /datasets/{name}`. The catalog says which fields can be filtered, grouped and aggregated, so the agent writes a valid query on the first try.
3. Writes a report definition (a JSON document with columns, filters, grouping and sorting) and runs it. A run returns up to 10,000 rows straight away, or an export of up to 5,000,000 rows.

"Overtime by department for the last three months, compared with the same months last year" becomes one report definition, not a new endpoint. Every run is kept in the run history, and access to sensitive fields is recorded.

## MCP for agentic workflows

**Available now.** Flow Payroll publishes two [MCP servers](https://docs.flowpayroll.ai/api-reference/mcp-server.md):

* **Docs** searches and reads every page of this site, so an assistant answers from the current docs. It needs no credentials and changes nothing.
* **Sandbox API** finds, explains and calls every endpoint with your sandbox credentials, including the ones that change data. It can only reach the sandbox, so it never touches live data.

Together they let you build and test an integration in plain English. Ask an assistant to set up a scenario, such as five employees with a student loan, a leaver and a maternity leave starting this month, then check your integration handles it. [Build and test your integration](https://docs.flowpayroll.ai/api-reference/integration-patterns.md#build-and-test-your-integration) shows how.

**On the roadmap: MCP for live organisations.** The same tools against live data, acting under an [API token](https://docs.flowpayroll.ai/api-reference/administration/overview.md#api-tokens) whose [role](https://docs.flowpayroll.ai/api-reference/administration/users-roles-and-permissions.md) limits what the agent can do. For example:

* An assistant that answers employee pay questions holds **Viewer**, and reads payslips with their explanations but changes nothing.
* An agent that prepares the pay run holds **Payroll processor**. It posts lines and previews payslips but can't lock the run or submit to HMRC, so a person still approves.
* [Webhooks](https://docs.flowpayroll.ai/api-reference/webhooks/overview.md) start the agent when something happens, such as `payslip.finalised` or `rti.fps_rejected`, instead of having it poll.

## Modules partners can extend

Flow Payroll is modular. Pay, salary, statutory pay, pensions, court orders, holiday, payments, journals, reports and webhooks each have their own API, so an agent gets a small, focused set of tools for the job in hand instead of one large surface. Each module also takes your own data: pay elements you define, pay lines from your system, tags, roles and report definitions. New capabilities arrive as new modules or new fields alongside existing ones, and nothing you already call changes underneath you. Every deprecation gives at least 90 days' notice (see [Deprecations](https://docs.flowpayroll.ai/api-reference/deprecations.md)).

**Available now: pay lines only their creator can change.** Send a pay line with `canEdit: false` and only your integration can change it. Nobody else can, in the app or through the API. Your integration owns its data inside Flow Payroll, such as shifts, commissions or benefits, and can rely on it staying as it was sent. An agent working for someone else can read those lines but not change them.

## Partners bring the context to their own agents

Everything above reaches your systems, not just ours. A partner that keeps the explanation with each payslip, calls previews before acting and queries the Reports API can give its own agents accurate payroll answers, inside its own product and under its own brand. See [Integration patterns](https://docs.flowpayroll.ai/api-reference/integration-patterns.md) for how partners connect today.

## More to come

This is the start. More of the API will be shaped around agents as partners build with it, and each step is announced in [What's new](https://docs.flowpayroll.ai/api-reference/whats-new.md).

Building something like this? Email [hello@flowpayroll.ai](mailto:hello@flowpayroll.ai) to tell us what your agents need from the API.


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