Ask for leave
const url = 'http://127.0.0.1:9090/api/attendance/tenants/example/people/example/leave';const options = { method: 'POST', headers: { 'X-Request-Id': '4f1c2b0e-8a7d-4c51-9e2f-3a6b8d0c1e7f', 'Idempotency-Key': '0b6f1d3e-2c4a-4f8e-9a1b-7d5c3e2f1a09', Authorization: 'Basic <credentials>', 'Content-Type': 'application/json' }, body: '{"category":"vacation","comment":"family visit","days":{"2026-10-12":"8h","2026-10-13":"4h"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://127.0.0.1:9090/api/attendance/tenants/example/people/example/leave \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: 0b6f1d3e-2c4a-4f8e-9a1b-7d5c3e2f1a09' \ --header 'X-Request-Id: 4f1c2b0e-8a7d-4c51-9e2f-3a6b8d0c1e7f' \ --data '{ "category": "vacation", "comment": "family visit", "days": { "2026-10-12": "8h", "2026-10-13": "4h" } }'Records a leave request for the person, by the caller: a pay category and the time on each day, and the values the
tenant’s policy reads of it (the relationship of a bereavement). It waits for the
stages of the tenant’s approval rule for leave (with none, one decision at the stage approval); approved, its time is in the person’s ledgers, in its
category. To change one, ask again naming it in replaces.
With preview=true, nothing is recorded: the answer is what recording would change in the person’s ledgers,
checked and refused exactly as the write is.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The tenant’s id.
The person’s id.
Query Parameters
Section titled “Query Parameters”True: record nothing, and answer what recording would change (a preview); checked and refused as the write is.
Header Parameters
Section titled “Header Parameters”An id to follow the request by: answered back in X-Request-Id, and in the log, the audit trail and the events the request causes. 1 to 128 letters, digits, -, _, . or :; anything else is replaced by a new id.
Example
4f1c2b0e-8a7d-4c51-9e2f-3a6b8d0c1e7fDoes the request once, however often it is sent with this key, for 24 hours: sent again with the same request, it is answered as it was the first time (Idempotent-Replayed: true); with another, 422; while the first runs still, 409.
Example
0b6f1d3e-2c4a-4f8e-9a1b-7d5c3e2f1a09Request Bodyrequired
Section titled “Request Bodyrequired”Leave asked for.
object
The pay category its time is in (vacation, sick…).
The time asked for on each day: “8h”, “4h 30m”.
object
The request’s id, to send it again safely; one is made without it.
The request this one replaces (a change: asked for, and approved, again).
What the tenant’s policy reads of the request beyond its days, by
name: the relationship of a bereavement ({"relationship": "spouse"}), the reason for family leave. Part of what an approval
is of.
object
Example
{ "category": "vacation", "comment": "family visit", "days": { "2026-10-12": "8h", "2026-10-13": "4h" }}Responses
Section titled “Responses”Recorded; with preview=true, what recording it would change.
The request recorded.
object
New, or already (the same was recorded before).
What the write would do, recording nothing.
object
The facts it would record, in order.
A fact the write would record, and what the write would say of it.
object
New, or already (recorded before: it changes nothing).
Each of the person’s ledgers that would change, by period, then side; none: nothing would.
What one ledger would change by: only what differs is listed.
object
Why: the ledger lines that would be added and taken away, each with what the policy’s steps did to it (an adjustment for a closed period says which).
object
The approvals whose state would change, by subject.
An approval or leave request whose state would change; absent before or after: there is none then.
object
Where an approval or a leave request stands.
object
The stage it waits for, was approved at before a change, or was rejected or disputed at.
Pending, needs_reapproval, rejected, disputed, blocked, refused or approved.
Why, where it is refused (a leave request the policy refused) or an approve step blocked it.
Where an approval or a leave request stands.
object
The stage it waits for, was approved at before a change, or was rejected or disputed at.
Pending, needs_reapproval, rejected, disputed, blocked, refused or approved.
Why, where it is refused (a leave request the policy refused) or an approve step blocked it.
The approval’s subject, or the leave request’s id.
The accrual balances at the period’s end that would change.
An accrual balance at the period’s end, as a duration, before and after.
object
The accrual category.
An exception that would be raised, or go.
object
The workday it is on, and the instant it is about.
Its kind: one the engine finds (missing_out…) or a policy step’s.
Its id, as the ledger and the follow-up list name it.
The exceptions that would be raised, and those that would go.
An exception that would be raised, or go.
object
The workday it is on, and the instant it is about.
Its kind: one the engine finds (missing_out…) or a policy step’s.
Its id, as the ledger and the follow-up list name it.
The pay period’s first and last day.
The decimal hours of each pay category that would change.
The hours of a pay category, before and after.
object
The leave requests whose state would change, by id.
An approval or leave request whose state would change; absent before or after: there is none then.
object
Where an approval or a leave request stands.
object
The stage it waits for, was approved at before a change, or was rejected or disputed at.
Pending, needs_reapproval, rejected, disputed, blocked, refused or approved.
Why, where it is refused (a leave request the policy refused) or an approve step blocked it.
Where an approval or a leave request stands.
object
The stage it waits for, was approved at before a change, or was rejected or disputed at.
Pending, needs_reapproval, rejected, disputed, blocked, refused or approved.
Why, where it is refused (a leave request the policy refused) or an approve step blocked it.
The approval’s subject, or the leave request’s id.
The money of each category and currency that would change; absent where the person has no rates set up.
Money of a currency and pay category, in minor units, before and after.
object
The decimal hours in paid categories, and the time worked.
object
object
Pay or bill.
A value as it is, as it would be, and the difference.
object
Why the person’s ledgers cannot be worked out (no zone set up for them, a policy step failing): the write would still be taken.
Example
{ "id": "v1", "recorded": "new"}No days, or a time that is no duration.
A refusal, and why.
object
Why the request was refused, in a sentence.
For a request whose parameters do not fit (422): what is wrong with each field. Absent otherwise.
What is wrong with one field of a request.
object
The parameter, as the request names it (values.volume for a
setting inside values).
What is wrong with it.
The request’s id, as its X-Request-Id header gives it: what to
quote when asking what happened to it.
Examplegenerated
{ "error": "example", "fields": [ { "field": "example", "message": "example" } ], "request_id": "example"}A login is configured and the request carries neither it nor an API token, or it carries a wrong login (WWW-Authenticate: Basic realm="Hour Advantage", no body). Or the request carries an API token that is not one (revoked, or never made), login or not (WWW-Authenticate: Bearer realm="Hour Advantage", error="invalid_token", the body the API token was refused).
Example
the API token was refusedHeaders
Section titled “Headers”The scheme to answer with: Basic realm="Hour Advantage", or for a refused token Bearer realm="Hour Advantage", error="invalid_token".
The Host header does not name a loopback address while one is required (no login configured, or the API listens on loopback), or the Origin header does not match the Host: {"error": ...} says which. Or no login is configured and the request carries Forwarded, X-Forwarded-For or X-Real-IP (a proxy forwarded it): the plain text body says so. Or an API token asks for a route its scope does not reach: the plain text body says so.
A refusal, and why.
object
Why the request was refused, in a sentence.
For a request whose parameters do not fit (422): what is wrong with each field. Absent otherwise.
What is wrong with one field of a request.
object
The parameter, as the request names it (values.volume for a
setting inside values).
What is wrong with it.
The request’s id, as its X-Request-Id header gives it: what to
quote when asking what happened to it.
Example
{ "error": "the Host must name this machine (localhost or a loopback address); an API reached by other names needs the admin login"}Example
a forwarded request needs the admin login; none is setA request with that id is recorded already, differently.
A refusal, and why.
object
Why the request was refused, in a sentence.
For a request whose parameters do not fit (422): what is wrong with each field. Absent otherwise.
What is wrong with one field of a request.
object
The parameter, as the request names it (values.volume for a
setting inside values).
What is wrong with it.
The request’s id, as its X-Request-Id header gives it: what to
quote when asking what happened to it.
Examplegenerated
{ "error": "example", "fields": [ { "field": "example", "message": "example" } ], "request_id": "example"}More than 2 admin logins are being checked at once: send the request again after the Retry-After seconds. A request carrying the login that checked out last, or an API token, is not held up.
Example
too many logins at once; try againHeaders
Section titled “Headers”Seconds to wait: 1.
Something went wrong in the gateway that asking again will not put right by itself; error says what.
A refusal, and why.
object
Why the request was refused, in a sentence.
For a request whose parameters do not fit (422): what is wrong with each field. Absent otherwise.
What is wrong with one field of a request.
object
The parameter, as the request names it (values.volume for a
setting inside values).
What is wrong with it.
The request’s id, as its X-Request-Id header gives it: what to
quote when asking what happened to it.
Example
{ "error": "db error: ERROR: permission denied for table settings"}The attendance engine does not run here.
A refusal, and why.
object
Why the request was refused, in a sentence.
For a request whose parameters do not fit (422): what is wrong with each field. Absent otherwise.
What is wrong with one field of a request.
object
The parameter, as the request names it (values.volume for a
setting inside values).
What is wrong with it.
The request’s id, as its X-Request-Id header gives it: what to
quote when asking what happened to it.
Examplegenerated
{ "error": "example", "fields": [ { "field": "example", "message": "example" } ], "request_id": "example"}