/v1/payment, appended to the gateway base URLs listed in the API reference introduction.
Key concepts
- Payment file — the generated BACS file for one completed pay run, identified by its payroll configuration, tax year, pay frequency, and period. It carries a
status, summary totals (records, employees, total amount), and a downloadable artefact with a time-limiteddownloadUrl. - Payment file status — the canonical outcome of generation:
GENERATED(file produced for every employee),PARTIAL_SUCCESS(file produced for some, others need attention),FAILED(no file produced),RETRYING(a retry is in progress),REBUILDING(a rebuild with the current payment settings is in progress),GENERATING(the first file of a pay run that locked without payment settings is being created),SUBMITTEDorQUEUED(the payments went to a provider instead of a file), orUNKNOWN(the outcome was not recognised). Always branch on this field, never on the HTTP status code. - Affected employees — when the status is
FAILEDorPARTIAL_SUCCESS,failure.affectedEmployeeslists each employee blocking the file, with one validation issue per failed field. - Payment format — a (method, format, file format) combination such as BACS Standard 18 as
txtor BACS Barclays astxtorcsv. Each format advertises itssupportedFileFormats;fileFormatdefaults totxtwhen omitted. - Payment configuration — the per-organisation settings that drive file generation: the chosen method, format, and file format, plus the BACS source bank account (sort code, account number) and service user number.
- File layout — for the
Customformat, the bank file described as data: its columns in order, how each value is written, and whether it is delimited or fixed width. See Custom file layouts. - Payment reference — an optional expression on the configuration that builds each file’s reference from static text and tokens such as
{payDate},{year},{period},{frequency}, and separators. AreferenceDateFormatenum (defaultDMY_SLASH) controls how date tokens render.
API structure
Payment files
Fetch the file for a pay run withGET /file/run/{payrollConfigId}/year/{year}/frequency/{frequency}/period/{period}. The response’s file block is non-null when a downloadable artefact exists (GENERATED, SUBMITTED, PARTIAL_SUCCESS), and the failure block is non-null when employees were excluded (FAILED, PARTIAL_SUCCESS) — both appear together on a partial success.
Retry
Queue a regeneration with refreshed employee data usingPOST /file/run/{payrollConfigId}/year/{year}/frequency/{frequency}/period/{period}/retry. The file must currently be FAILED or PARTIAL_SUCCESS, or, after a re-lock, its supplementary file FAILED or BLOCKED; a retry is refused while a retry or a rebuild is already running. The retry is accepted asynchronously with a 202 and the status moves to RETRYING while it processes.
A retry produces the file again for every employee, not only the ones the earlier file left out, and on a re-lock produces the supplementary file again beside it. The files it replaces are never deleted: they stay downloadable from the history’s replacedFiles (the cycle’s, and the supplementary file’s own). If the earlier file was already sent to the bank, do not send the new one as well: pay the employees it left out by hand.
Rebuild
Build a generated file again with the payment settings as they are now, after changing the bank or the file type (txt or csv), usingPOST /file/run/{payrollConfigId}/year/{year}/frequency/{frequency}/period/{period}/rebuild. The payments are the ones stored when the pay run locked; only the file changes. The file must be GENERATED or PARTIAL_SUCCESS. The rebuild is accepted asynchronously with a 202, the status moves to REBUILDING, and the outcome is announced as a payment file event with trigger rebuild. The file it replaces is never deleted: it stays downloadable from the history’s replacedFiles. If the earlier file was already sent to the bank, do not send the new one as well.
A file built with the payment settings as they are now has nothing to gain from a rebuild: the payment file resource says so in usesCurrentSettings (false once the bank, file type, reference or originating account changed since the file was built), and a rebuild of a file that already uses them is refused with a 409 (rebuildPaymentFileUpToDate). A rebuild is also refused with a 409 while a retry or a rebuild is running (rebuildPaymentFileInProgress), while the pay run is unlocked for a correction (rebuildPaymentFileReopened: locking it again builds the file with the current settings), when no file was generated (rebuildPaymentFileNotGenerated: retry it instead), and when the current payment settings are missing or incomplete (rebuildPaymentFileSettingsMissing, rebuildPaymentFileSettingsInvalid). A refused request changes nothing.
Create a missing file
A pay run that locked before its pay schedule had payment settings has no payment file (GET answers 404). Once the settings exist, create it with POST /file/run/{payrollConfigId}/year/{year}/frequency/{frequency}/period/{period}/generate. The file is built from the payments stored when the pay run locked, with the current settings, and the pay run stays locked. The request is accepted with a 202, the status is GENERATING until the file is ready, and the outcome is announced as a payment file event with trigger generate.
It is refused with a 409 when the pay run already has a file (generatePaymentFileExists: rebuild or retry it instead), is not locked (generatePaymentFilePayRunNotLocked), was corrected after it was first locked (generatePaymentFilePayRunCorrected: unlock and lock it again), has no payments stored (generatePaymentFileNoPayments), or when the payment settings are missing or incomplete (generatePaymentFileSettingsMissing, generatePaymentFileSettingsInvalid). It answers 404 (generatePaymentFilePayRunNotFound) for a pay run that does not exist.
Available payment configurations
List the (method, format, file format) combinations an organisation can configure withGET /available/config.
Organisation payment configuration
Manage the configuration at/config/{payrollConfigId}: create it with POST, then read, replace, or remove it with GET, PUT, and DELETE on the same path.
Custom file layouts
When your bank’s import isn’t one of the listed formats, setformat to Custom and send the file’s layout as fileLayout. Every file for the pay schedule is then written in it.
- The layout’s
extensionis the file format;fileFormatis not needed. rowFormatisDelimited(values separated bydelimiter, a comma when left out) orFixedWidth(every column padded to itswidth).- Each column takes only the options for its
field:sortCode(Digits,Dashed,Spaced),accountNumber(PaddedToEight,Digits),amount(Pounds,PoundsTrimmed,Pence),dateFormatforPaymentDate,literalforLiteral, plusheading,case,characterSet,trim,maxLength,width,alignandpad. Options left out take the defaults the reference lists. - A layout needs exactly one
PayeeSortCode,PayeeAccountNumberandAmountcolumn, and a name column. Limits: 1 to 100 columns, text up to 100 characters,widthandmaxLength1 to 1000. A fixed-width sort code, account number or amount column must be wide enough for every valid payment: 6 (8 with separators), 8, and 11 (10 in pence). PUTwithoutfileLayoutkeeps the stored layout. Changingformataway fromCustomremoves it, andfileLayoutwith any other format is refused.GET /available/configlists each format’s own layout asfileLayouts, each with a stableidsuch asbarclays-csv, to start a custom layout from. A pay schedule’s own layout answersid: null.
400 (createOrganisationPaymentConfigInvalidFileLayout or updateOrganisationPaymentConfigInvalidFileLayout) and one entry in validationIssues per problem. Each names the field (for example fileLayout.columns[2].width, counting from zero) and a reasonToken to branch on; the reason text may change, the tokens do not.
New values may be added to the layout’s sets, such as a new
field. Treat a value you don’t recognise as unknown rather than failing: show it by name, and send it back unchanged.Typical workflow
- Call
GET /available/configto see which payment formats and file formats you can use. - Create the organisation’s configuration with
POST /config/{payrollConfigId}, supplying the method, format, BACS account details, and optionally a reference expression. - Complete a pay run in Flow Payroll — the service generates the payment file for it.
- Fetch the file with
GET /file/run/{payrollConfigId}/year/{year}/frequency/{frequency}/period/{period}and branch onstatus. - If the status is
FAILEDorPARTIAL_SUCCESS, correct the employees listed infailure.affectedEmployees, then queue a regeneration withPOST .../retry. - Download the file from
file.downloadUrland upload it to your bank.
Notes and best practices
The
status field in the 200 response body is the canonical outcome. Resource state is never reported through 4xx/5xx codes — a 500 means a server-side failure, not a failed file.- Download links expire at
file.downloadUrlExpiresAt. Fetch the payment file again to obtain a fresh link. - Use
csvas thefileFormatonly when it appears insupportedFileFormatsfor the chosen method and format. - A retry against a file that is not
FAILEDorPARTIAL_SUCCESSis rejected with a400. createdByisSYSTEMfor the first generation,SYSTEM_REGENfor automatic recovery regenerations, and the administrator who asked for a rebuild, so you can tell how a file version came to exist.externalReferenceis a forward-compatibility placeholder for future API-based payment flows and is always null today.
Authentication
Every request needs anX-Auth-Token header, and credentials with access to more than one organisation also send X-Org-Id — see Authentication. Responses use the shared envelope described in Response format.