<!-- Generated by scripts/build-docs.js. Edit docs/swagger.yaml or docs/guides/, then run `npm run docs:build`. -->

# Write a time entry

`POST https://{apiId}.execute-api.us-west-1.amazonaws.com/{stage}/v1/timesheets`

Module: Timesheets · operationId: `writeTimeEntry` · Auth: `Authorization: Bearer <token>`
Web page: https://apidocs.sequipay.com/#/api/write-time-entry

Records one time entry for an employee. The write is asynchronous and idempotent: the service resolves the employee, forwards the entry to sequipay-core's single hours path, and returns 202 with a receipt id. Poll `GET /v1/timesheets/receipts/{id}` for the outcome.

Idempotency is on `reference_id` — your own stable id for this entry. Re-sending the same `reference_id` amends the same entry and never duplicates it, so a 503 is always safe to retry with the same body.

`kind` (worked vs adjustment) is NOT accepted — the service decides, based on whether the work date falls in a paid period.

Requires the `timesheets:write` scope.

## Request body

- `employee_id` (integer (int64), **required**): The employee's id (as returned by the users endpoints). Minimum: 1. Example: `1024`.
- `reference_id` (string, **required**): Your own stable id for this entry — the idempotency key. Re-sending it amends the same entry. Max length: 180. Example: `shift-2024-01-02-1024`.
- `work_date` (string (date), **required**): The date worked (YYYY-MM-DD). Example: `2024-01-02`.
- `started_at` (string (date-time), nullable): Shift start; provide this (with ended_at) or minutes. Example: `2024-01-02T16:00:00Z`.
- `ended_at` (string (date-time), nullable) Example: `2024-01-02T20:00:00Z`.
- `minutes` (integer, nullable): Minutes worked; required when started_at is not given. May be negative for an adjustment. Example: `240`.
- `break_minutes` (integer, nullable) Example: `30`.
- `job_ref` (string, nullable) Example: `J-1001`.
- `job_label` (string, nullable) Example: `Install`.
- `rate_cents` (integer, nullable): Pay rate in cents, if the partner carries it. Example: `3000`.
- `note` (string, nullable) Example: `Overtime approved.`.

## Example request

```bash
curl -X POST "https://{apiId}.execute-api.us-west-1.amazonaws.com/{stage}/v1/timesheets" \
  -H "Authorization: Bearer $SEQUIFI_TOKEN"
```

## Responses

### 202: Accepted and queued. Poll the receipt for the outcome.

- `status` (integer) Example: `202`.
- `message` (string) Example: `accepted`.
- `data` (object)
  - `receipt_id` (string): Opaque, company-bound receipt token — poll it at GET /v1/timesheets/receipts/{id}. Example: `eyJjIjoiY21wXzAxSDhYIiwiciI6IjlmMWMyYTdlIn0.a1B2c3D4`.
  - `status` (string) Example: `queued`.

### 401: Missing, invalid, expired, or revoked token (from the authorizer).

### 403: The token lacks the required scope.

```json
{
  "error": "insufficient_scope",
  "required": "users:read"
}
```

### 404: No such employee for this company.

```json
{
  "status": 404,
  "message": "employee not found for this company",
  "data": null
}
```

### 422: The body failed validation (this service's shape checks or Core's).

### 500: An infrastructure or data error. The endpoint fails closed — a 500, never a partial or empty-looking result.

```json
{
  "status": 500,
  "message": "internal error",
  "data": null
}
```

### 503: sequipay-core could not be reached or was busy. Transient — retry with the SAME `reference_id`; the write is idempotent, so a retry never duplicates.

```json
{
  "status": 503,
  "message": "core unavailable, retry",
  "data": null
}
```
