Docs
API referencePayroll exports

Make a payroll export

Preview· P9
POST
/payroll-exports

Makes a payroll file from a timesheet period's approved, locked timesheets, for the whole organisation or chosen sites. People not in an earlier file for the period get their first lines; people whose figures changed since one (a timesheet reopened and approved again, or a leaver's annual leave balance) get the difference as correction lines; people with nothing new aren't repeated. Hours are by pay code and net of unpaid breaks; days by pay code. Returns invalid_state while a type of leave in it has no pay code or two pay codes clash, while the period is running, and when nothing is new. The file is kept: download it from /payroll-exports/{payroll_export_id}/file. payroll_export.created fires.

Scope: attendance:payroll · Plan: Pro and Enterprise, with the payroll export; in test mode too, the payroll export needs Pro.

Authorization

headerAuthorizationBearer <token>

Send Authorization: Bearer <token> on every request. The token is one of:

PrefixWhat it isWhere it may be used
agoo_sk_live_Secret key, live modeYour servers only
agoo_sk_test_Secret key, test modeYour servers only
agoo_pk_live_Publishable key, live modeBrowsers and apps: create pre-registrations and bookings, read public booking types (with their intake questions) and their free slots, read the visit types open for pre-registration with their public forms. Never lists people.
agoo_pk_test_Publishable key, test modeAs above, in test mode

Admins create keys in Console → Developers → API keys and choose each key's scopes. A key is shown once. Never put a secret key in a URL, a browser or a mobile app.

Scope: attendance:payroll

Header Parameters

Idempotency-Key*string

A UUID you generate for this operation. If you retry with the same key within 24 hours, Agoo returns the original response instead of acting twice. While the first request is still running, a retry returns conflict. Reusing a key with a different request returns idempotency_key_reused. Responses with rate_limited, internal_error or unavailable aren't stored, so retry those with the same key.

Formatuuid

Request Body

application/json
  1. body
period_id*TimesheetPeriodId

A timesheet period ID (TypeID with the tsp prefix).

Match^tsp_[0-7][0-9a-hjkmnp-tv-z]{25}$
Example"tsp_01m5a2b3c4d5e6f7g8h9jkmnpr"
site_ids?array<>

Only people who work at these sites; the whole organisation when left out.

Itemsitems <= 200
format?string

xlsx also has the other layout, each day's figures and breaks, and notes.

Default"csv"
Value in"csv""xlsx"
layout?string
Default"long"
Value in"long""wide"
note?string

A note kept with the file.

Lengthlength <= 300

Response Body

The payroll export, with its file made and kept.

application/json
  1. response

A payroll file made from a timesheet period's approved, locked timesheets. Never changed once made: later changes go in a later file as corrections.

id*PayrollExportId

A payroll export ID (TypeID with the payroll_export prefix).

Match^payroll_export_[0-7][0-9a-hjkmnp-tv-z]{25}$
Example"payroll_export_01m5c4d5e6f7g8h9jkmnpqrstv"
number*integer

Your organisation's payroll exports are numbered 1, 2, 3…

Example3
period*
site_ids*array<>|

The sites it was made for; null for the whole organisation.

format*string
Value in"csv""xlsx"
layout*string

long: a row per person and pay code. wide: a row per person, a column per pay code. custom: one of your organisation's own layouts, made in the Console.

Value in"long""wide""custom"
people*integer

People in it.

corrections*integer

People whose lines correct an earlier file for the same period.

lines*integer
superseded*integer

People in it whose figures a later file corrected.

file*
created_by*|

Who made it; null when an integration did.

Match^person_[0-7][0-9a-hjkmnp-tv-z]{25}$
created_via*string
Value in"person""api"
created_at*string
Formatdate-time
curl -X POST 'https://api.agoo.ardent.africa/v1/payroll-exports' \  -H 'Idempotency-Key: 3f6b2a1e-8c4d-4f7a-9b2e-5d1c0a7e9f64' \  -H 'Content-Type: application/json' \  -d '{  "period_id": "tsp_01m5a2b3c4d5e6f7g8h9jkmnpr",  "format": "csv",  "layout": "long"}'
{  "id": "payroll_export_01m5c4d5e6f7g8h9jkmnpqrstv",  "number": 3,  "period": {    "id": "tsp_01m5a2b3c4d5e6f7g8h9jkmnpr",    "starts_on": "2019-08-24",    "ends_on": "2019-08-24",    "payroll_on": "2019-08-24"  },  "site_ids": [    "site_01kjpt3yw0fz0v414608h9x65s"  ],  "format": "csv",  "layout": "long",  "people": 0,  "corrections": 0,  "lines": 0,  "superseded": 0,  "file": {    "name": "ridge-hospital-payroll-september-2026-3.csv",    "content_type": "string",    "byte_size": 0,    "sha256": "string"  },  "created_by": "string",  "created_via": "person",  "created_at": "2019-08-24T14:15:22Z"}