Skip to main content
The Payment API turns a completed pay run into a BACS payment file you can upload to your bank. It generates and serves files in the Standard 18, Barclays (CSV or TXT) and Allica formats, or in a custom layout you describe for your bank, manages each organisation’s payment configuration — the source bank account, service user number, and file format — lets you retry generation after fixing employees whose details failed BACS validation, and rebuilds a locked pay run’s file after you change its bank or file type. Pay runs themselves are managed elsewhere; see Running a pay run. All endpoint paths on this page are relative to the service base path /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-limited downloadUrl.
  • 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), SUBMITTED or QUEUED (the payments went to a provider instead of a file), or UNKNOWN (the outcome was not recognised). Always branch on this field, never on the HTTP status code.
  • Affected employees — when the status is FAILED or PARTIAL_SUCCESS, failure.affectedEmployees lists 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 txt or BACS Barclays as txt or csv. Each format advertises its supportedFileFormats; fileFormat defaults to txt when 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 Custom format, 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. A referenceDateFormat enum (default DMY_SLASH) controls how date tokens render.

API structure

Payment files

Fetch the file for a pay run with GET /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 using POST /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), using POST /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 with GET /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, set format to Custom and send the file’s layout as fileLayout. Every file for the pay schedule is then written in it.
That layout writes one row per payment:
  • The layout’s extension is the file format; fileFormat is not needed.
  • rowFormat is Delimited (values separated by delimiter, a comma when left out) or FixedWidth (every column padded to its width).
  • Each column takes only the options for its field: sortCode (Digits, Dashed, Spaced), accountNumber (PaddedToEight, Digits), amount (Pounds, PoundsTrimmed, Pence), dateFormat for PaymentDate, literal for Literal, plus heading, case, characterSet, trim, maxLength, width, align and pad. Options left out take the defaults the reference lists.
  • A layout needs exactly one PayeeSortCode, PayeeAccountNumber and Amount column, and a name column. Limits: 1 to 100 columns, text up to 100 characters, width and maxLength 1 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).
  • PUT without fileLayout keeps the stored layout. Changing format away from Custom removes it, and fileLayout with any other format is refused.
  • GET /available/config lists each format’s own layout as fileLayouts, each with a stable id such as barclays-csv, to start a custom layout from. A pay schedule’s own layout answers id: null.
An invalid layout is refused with a 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

  1. Call GET /available/config to see which payment formats and file formats you can use.
  2. Create the organisation’s configuration with POST /config/{payrollConfigId}, supplying the method, format, BACS account details, and optionally a reference expression.
  3. Complete a pay run in Flow Payroll — the service generates the payment file for it.
  4. Fetch the file with GET /file/run/{payrollConfigId}/year/{year}/frequency/{frequency}/period/{period} and branch on status.
  5. If the status is FAILED or PARTIAL_SUCCESS, correct the employees listed in failure.affectedEmployees, then queue a regeneration with POST .../retry.
  6. Download the file from file.downloadUrl and 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 csv as the fileFormat only when it appears in supportedFileFormats for the chosen method and format.
  • A retry against a file that is not FAILED or PARTIAL_SUCCESS is rejected with a 400.
  • createdBy is SYSTEM for the first generation, SYSTEM_REGEN for automatic recovery regenerations, and the administrator who asked for a rebuild, so you can tell how a file version came to exist.
  • externalReference is a forward-compatibility placeholder for future API-based payment flows and is always null today.

Authentication

Every request needs an X-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.