Diary entries

List diary entries

Lists diary entries, most-recent-first, paginated. Filters map onto the domain browse: `projectId` and `userId` are repeatable. An API key is **Admin-equivalent and tenant-wide**, so this returns every entry in the tenant. The narrower per-role visibility introduced by SUP-449 — a Site Manager sees their sites plus their own, Site Crew only their own — applies to signed-in users of the web app; there is no crew-scoped API credential. **This read closes expired shifts before it answers** (ADR 0012, amended): open shifts past 12 hours inside the read's scope are auto-closed first, so the list can contain entries created by this very call — `origin` `auto_closed`, `createdBy` null, `durationMinutes`/`hours` **null** (hours *missing*, never 0, zero in totals), `closedAutomaticallyReason` `12h`. An hourly database job runs the same sweep whether or not anyone reads, so the entries exist before they are asked for. Writes never sweep.

GET
/diary-entries

Lists diary entries, most-recent-first, paginated. Filters map onto the domain browse: projectId and userId are repeatable.

An API key is Admin-equivalent and tenant-wide, so this returns every entry in the tenant. The narrower per-role visibility introduced by SUP-449 — a Site Manager sees their sites plus their own, Site Crew only their own — applies to signed-in users of the web app; there is no crew-scoped API credential.

This read closes expired shifts before it answers (ADR 0012, amended): open shifts past 12 hours inside the read's scope are auto-closed first, so the list can contain entries created by this very call — origin auto_closed, createdBy null, durationMinutes/hours null (hours missing, never 0, zero in totals), closedAutomaticallyReason 12h. An hourly database job runs the same sweep whether or not anyone reads, so the entries exist before they are asked for. Writes never sweep.

Authorization

x-api-key<token>

The per-tenant API key, copied from Settings → API & integrations. Sent as the x-api-key request header. The key is tenant-scoped and acts with Admin-equivalent, tenant-wide access.

In: header

Query Parameters

limit?integer

Page size, 1–200. Defaults to 50.

cursor?string

Opaque cursor from a previous page's nextCursor. Omit for the first page.

projectId?array<>

Filter by project id (repeatable).

userId?array<>

Filter by crew-member user id (repeatable).

from?string

Inclusive start of the entry-date range (YYYY-MM-DD).

to?string

Inclusive end of the entry-date range (YYYY-MM-DD).

search?string

Free-text match on description and crew name.

status?array<>

Repeatable. Only entries with this status — how the hours were recorded: checked_out (checked in and out, or closed when the site was archived), no_check_out (auto-closed after 12h without a check-out — its hours stay empty until someone sets them), manual (entered by hand). Ignored when the business records hours in the site diary (entries have no status there).

location?array<>

Repeatable. Only entries whose location reads on_site (every reading on site), off_site (a reading outside the site boundary) or no_location (a reading that couldn't be placed). Ignored when the business has location stamping off.

photos?string

with: only entries with at least one photo; without: only entries with none.

Response Body

application/json

application/json

curl -X GET "https://example.com/diary-entries"
{  "data": [    {      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",      "entryDate": "2019-08-24",      "projectId": "5a8591dd-4039-49df-9202-96385ba3eff8",      "projectName": "string",      "projectArchived": true,      "userId": "2c4a230c-5085-4924-a3e1-25fb4fc5965b",      "crewMemberName": "string",      "durationMinutes": 0,      "hours": 0,      "description": "string",      "photoCount": 0,      "submittedAt": "2019-08-24T14:15:22Z",      "latitude": 0,      "longitude": 0,      "locationAccuracyM": 0,      "siteLocation": {        "verdict": "on_site",        "distanceM": 0,        "accuracyM": 0,        "missingReason": "no_site"      },      "status": "checked_out",      "readings": [        {          "when": "check_in",          "location": {            "verdict": "on_site",            "distanceM": 0,            "accuracyM": 0,            "missingReason": "no_site"          },          "latitude": 0,          "longitude": 0        }      ],      "locationFacet": "on_site",      "locationTag": "off_site",      "origin": "manual",      "attendanceRecordId": "681c1ed7-6de0-4306-80e5-8ea16505936b",      "checkInAt": "2019-08-24T14:15:22Z",      "checkOutAt": "2019-08-24T14:15:22Z",      "checkInLocation": {        "verdict": "on_site",        "distanceM": 0,        "accuracyM": 0,        "missingReason": "no_site"      },      "checkOutLocation": {        "verdict": "on_site",        "distanceM": 0,        "accuracyM": 0,        "missingReason": "no_site"      },      "createdBy": "25a02396-1048-48f9-bf93-102d2fb7895e",      "createdByName": "string",      "closedAutomaticallyAt": "2019-08-24T14:15:22Z",      "closedAutomaticallyReason": "12h",      "siteTimezone": "string",      "marks": [        "no_check_in"      ]    }  ],  "nextCursor": "string"}
{  "error": {    "code": "unauthorized",    "message": "Missing or invalid API key."  }}

Download diary entries as a PDF GET

The diary entries matching the **same filters as `GET /diary-entries`**, as one PDF: for sharing a day's site record (defects, rectification work) with people who aren't on FOREMAN. "What you see is what you download" — the web app's **Export → Download PDF** menu item sends the browse's current filters to the same report. Contents: the business name/logo, the project (or "N projects"), the date span, a summary (entries · hours · people · photos), then entries grouped **project → day**, earliest first — each with the crew member, the shift's times in the site's timezone (or "Entered by hand"), hours, "Logged by … for …" where it applies, the full description, and its photos **two per row**. A range that reaches today is marked as possibly incomplete. API downloads are stamped "Generated via the FOREMAN API". Limits keep the file small enough to email: at most **300 entries** and **120 photos** (photos are embedded resized, ~800px). Over either, or with no matching entries, the call answers `422`; the message names the limit and the count (e.g. "Too many photos for one PDF: this view has 164, the limit is 120. Add filters …"). The key is Admin-equivalent, so every project is downloadable (signed-in web users need to manage every project in the view — an Admin, or that site's Site Manager). Like `GET /diary-entries`, this read closes expired shifts first. The response is **streamed** (`Content-Disposition: attachment`). Not on MCP by design: `list_diary_entries` gives an assistant the same data; the PDF is only a presentation of it.

Edit is not available via the API PUT

Editing a diary entry stays in the app; this verb is answered with a `405` pointing there.