# Time records API

> Read and add clock-in and clock-out records. GET /api/v1/time-entries, POST /api/v1/time-entries, PATCH /api/v1/time-entries/{id}, POST /api/v1/time-entries/{id}/void.

4 operations. Each needs an API key with the permission shown; see [API keys and permissions](https://staffedly.com/docs/developers/api-keys).

| Operation | Permission |
| --- | --- |
| [`GET /api/v1/time-entries`](#get-api-v1-time-entries) | `time:read` |
| [`POST /api/v1/time-entries`](#post-api-v1-time-entries) | `time:write` |
| [`PATCH /api/v1/time-entries/{id}`](#patch-api-v1-time-entries-id) | `time:write` |
| [`POST /api/v1/time-entries/{id}/void`](#post-api-v1-time-entries-id-void) | `time:write` |

## GET /api/v1/time-entries

Clock-in and clock-out records. Voided entries are left out unless asked for by status.

- **Permission:** `time:read`
- **Returns:** a page of records: `{ data, hasMore, nextCursor }`, status 200

**Query parameters** (all optional)

| Name | Description |
| --- | --- |
| `from` | Earliest clock-in: YYYY-MM-DD or an ISO-8601 time. |
| `to` | Latest clock-in (not included): YYYY-MM-DD or an ISO-8601 time. |
| `providerId` | Only this person. |
| `facilityId` | Only this site. |
| `status` | open, auto_closed, provider_confirmed, edited, approved, locked, disputed or void. |
| `limit` | Rows per page, 1 to 200. Default 50. |
| `cursor` | The nextCursor value from the previous page. |

**Fields in each record:** `id`, `providerId`, `facilityId`, `assignmentId`, `clockIn`, `clockOut`, `category`, `status`, `minutes`, `externalId`

```bash
curl "https://app.staffedly.com/api/v1/time-entries?limit=50" \
  -H "Authorization: Bearer $STAFFEDLY_API_KEY"
```

## POST /api/v1/time-entries

Add a clock record. A finished record is marked for review before pay.

- **Permission:** `time:write`
- **Returns:** one record: `{ data }`, status 201
- **Safe retry:** send an `Idempotency-Key` header (8 to 128 characters); the same key with the same request returns the first answer again

**Body fields** (JSON; a field the API does not know is refused)

| Field | Description |
| --- | --- |
| `providerId` | Required. |
| `facilityId` | Required. |
| `clockIn` | Required. ISO-8601 time with a zone, not in the future. |
| `clockOut` | Leave out to clock the person in. |
| `category` | regular (default), call or extra. |
| `reason` | Why the record was added; kept with it. |

**Fields in each record:** `id`, `providerId`, `facilityId`, `assignmentId`, `clockIn`, `clockOut`, `category`, `status`, `minutes`, `externalId`

```bash
curl -X POST "https://app.staffedly.com/api/v1/time-entries" \
  -H "Authorization: Bearer $STAFFEDLY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"providerId":"<providerId>","facilityId":"<facilityId>","clockIn":"2027-01-12T07:00:00-05:00"}'
```

## PATCH /api/v1/time-entries/{id}

Clock someone out, or correct a record's times. A correction resets approval.

- **Permission:** `time:write`
- **Returns:** one record: `{ data }`, status 200
- **Safe retry:** send an `Idempotency-Key` header (8 to 128 characters); the same key with the same request returns the first answer again

**Path**

| Name | Description |
| --- | --- |
| `id` | The record's id. |

**Body fields** (JSON; a field the API does not know is refused)

| Field | Description |
| --- | --- |
| `clockOut` | On an open record: clocks the person out at this time. |
| `clockIn` | — |
| `reason` | Required for a correction; kept with the record. |

**Fields in each record:** `id`, `providerId`, `facilityId`, `assignmentId`, `clockIn`, `clockOut`, `category`, `status`, `minutes`, `externalId`

```bash
curl -X PATCH "https://app.staffedly.com/api/v1/time-entries/<id>" \
  -H "Authorization: Bearer $STAFFEDLY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Extra room opened"}'
```

## POST /api/v1/time-entries/{id}/void

Take a wrong or duplicate record out of pay. It is kept, marked void.

- **Permission:** `time:write`
- **Returns:** one record: `{ data }`, status 201
- **Safe retry:** send an `Idempotency-Key` header (8 to 128 characters); the same key with the same request returns the first answer again

**Path**

| Name | Description |
| --- | --- |
| `id` | The record's id. |

**Body fields** (JSON; a field the API does not know is refused)

| Field | Description |
| --- | --- |
| `reason` | Required; kept with the record. |

**Fields in each record:** `id`, `providerId`, `facilityId`, `assignmentId`, `clockIn`, `clockOut`, `category`, `status`, `minutes`, `externalId`

```bash
curl -X POST "https://app.staffedly.com/api/v1/time-entries/<id>/void" \
  -H "Authorization: Bearer $STAFFEDLY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Extra room opened"}'
```

