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

# Get a user's timesheet

`GET https://marketplace-api.sequifi.com/v1/timesheet`

Module: Timesheet · operationId: `listTimesheetByPayPeriod` · Auth: `Authorization: Bearer <token>`
Web page: https://apidocs.sequifi.com/#/api/list-timesheet-by-pay-period

Returns one user's day-by-day time records for their current or previous pay period. Send `user_id` (not `userId`) and `pay_period`; any other query key returns `400 Invalid query parameter(s)`.

**Before you call:**

- Get the user id from GET /v1/users.
- The user's position needs a Weekly, Bi-Weekly, Semi-Monthly or Monthly pay frequency. Daily positions return `400 Position pay frequency not found`.

**What happens:**

- `current` is the pay period containing today's date in UTC. `previous` is the latest period that ended before that date. In US time zones the current period switches in the evening of its last day, local time.
- `timesheets` has one entry per calendar day of the period, oldest first. Each entry's `day` takes one of four shapes:
  1. A day with time records: an object with daily totals and `user_attendance_list`, an array of clock events.
  2. A past scheduled day with no records: `{date, user_attendance_list: {attendance_type: "absent", attendance_time}}`. Here `user_attendance_list` is an object, not an array, and `attendance_time` is the scheduled length.
  3. A day with only an approved time adjustment: an object whose totals are null and whose `user_attendance_list` holds the adjustment (`attendance_type: "Adjustment"`, `clock_in`, `clock_out`, `attendance_time`).
  4. Any other day: `day` is the plain date string `"YYYY-MM-DD"`.
- Deleted records are included. Skip any day or event whose `deleted_at` is set.
- An unknown `user_id` returns `200` with `pay_frequency: null` and an empty `timesheets` array.

**Formats:**

- Dates and clock times are `YYYY-MM-DD HH:MM:SS` strings with no time zone, as stored. On absence and adjustment days, `date` is `YYYY-MM-DD`.
- Durations are `HH:MM:SS`: `current_time` is net worked time for the day, `lunch_time` and `break_time` are the day's breaks, and `attendance_time` is the time until the next event.
- `labor_rate` and `earnings` on clock events are decimal strings with three places, such as `"20.000"`, or null. Pay is stored on the clock-in event.
- `time_format` does not change these values. With `time_format=12`, absence durations can come back as `"NaN:NaN:NaN"`, so omit it.
- Each clock event can also carry other stored fields not listed here; ignore them.

**Errors:**

- `400 Invalid query parameter(s)`, with `data.invalid_params` and `data.allowed_params`.
- `400 user_id is required`.
- `400 Validation Failed` with `data.pay_period`: `"required"`, or `"Invalid. Allowed: current, previous"`.
- `400 Position pay frequency not found`: no pay frequency on the user's position, or it is Daily.
- `400 Pay period not found`: no pay period matches.

**Related:**

- POST /v1/timesheet records time.
- GET /v1/timesheet/{id} is a shortcut for the current period.
- GET /v1/payroll shows the resulting wages in `hourly_salary`.

## Query parameters

- `user_id` (integer, **required**): User id from GET /v1/users. The name is `user_id`; `userId` is rejected. Minimum: 1. Example: `4821`.
- `pay_period` (string, **required**): `current` for the period containing today (UTC), `previous` for the latest period that ended before today. One of: `current`, `previous`. Example: `current`.
- `time_format` (string): Has no effect on returned clock times, and `12` can break absence durations. Omit it. One of: `12`, `24`. Default: `"24"`.

## Example request

```bash
curl -X GET "https://marketplace-api.sequifi.com/v1/timesheet" \
  -H "Authorization: Bearer $SEQUIFI_TOKEN"
```

## Responses

### 200: The user's timesheet for the period

- `status` (integer): The HTTP status code, repeated. Example: `200`.
- `message` (string): Short text. Wording varies by endpoint; branch on the HTTP status, not on this text. Example: `success`.
- `data` (object)
  - `requested_by` (string): Label of the API credential that made the call.
  - `pay_frequency` (object, nullable): The pay period shown, or null when the user does not exist. Other fields of the period may be present.
    - `id` (integer): Pay period id.
    - `pay_period_from` (string): Start of the period, `YYYY-MM-DD HH:MM:SS`.
    - `pay_period_to` (string): End of the period, `YYYY-MM-DD HH:MM:SS`.
  - `timesheets` (array of object): One entry per calendar day of the period, oldest first.
    - `day` (object | string): One calendar day.

```json
{
  "status": 200,
  "message": "success",
  "data": {
    "requested_by": "acme",
    "pay_frequency": {
      "id": 412,
      "pay_period_from": "2026-10-05 00:00:00",
      "pay_period_to": "2026-10-11 00:00:00"
    },
    "timesheets": [
      {
        "day": {
          "date": "2026-10-05",
          "user_attendance_list": {
            "attendance_type": "absent",
            "attendance_time": "08:00:00"
          }
        }
      },
      {
        "day": {
          "id": 90812,
          "user_id": 4821,
          "current_time": "04:00:00",
          "lunch_time": "00:00:00",
          "break_time": "00:00:00",
          "is_synced": 1,
          "date": "2026-10-06 00:00:00",
          "status": 1,
          "deleted_at": null,
          "user_attendance_list": [
            {
              "id": 551203,
              "type": "clock in",
              "attendance_type": "present",
              "attendance_date": "2026-10-06 08:00:00",
              "attendance_time": "04:00:00",
              "entry_type": "Marketplace-API",
              "external_reference_id": "fieldtool:entry:10482",
              "job_id": "1042",
              "job_name": "Unit turn clean",
              "labor_rate": "20.000",
              "earnings": "80.000",
              "office_id": 0,
              "deleted_at": null
            },
            {
              "id": 551204,
              "type": "clock out",
              "attendance_type": "clock out",
              "attendance_date": "2026-10-06 12:00:00",
              "attendance_time": null,
              "entry_type": "Marketplace-API",
              "external_reference_id": "fieldtool:entry:10482",
              "job_id": "1042",
              "job_name": "Unit turn clean",
              "labor_rate": null,
              "earnings": null,
              "office_id": 0,
              "deleted_at": null
            }
          ]
        }
      },
      {
        "day": "2026-10-07"
      }
    ]
  }
}
```

### 400: Missing or invalid query parameter, or the user's pay period cannot be found

Example (invalid_params): Unknown query parameter (for example userId)

```json
{
  "status": 400,
  "message": "Invalid query parameter(s)",
  "data": {
    "invalid_params": [
      "userId"
    ],
    "allowed_params": [
      "user_id",
      "pay_period",
      "time_format"
    ]
  }
}
```

### 401: Missing, invalid or expired token. The gateway rejects the call before it reaches Sequifi, so the body has only a `message`.

```json
{
  "message": "Unauthorized"
}
```

### 500: Internal server error

```json
{
  "status": 500,
  "message": "Internal Server Error",
  "data": {}
}
```
