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

# List an open stub's line items

`GET https://marketplace-api.sequifi.com/v1/payroll/{id}/line-items`

Module: Payroll · operationId: `listPayrollLineItems` · Auth: `Authorization: Bearer <token>`
Web page: https://apidocs.sequifi.com/#/api/list-payroll-line-items

Returns the rows that an open pay stub's section totals are built from (which deal, which milestone, how much). Some rows are shown on the stub but not paid on it: sum only rows with `counts_toward_pay: true` to match the stub.

**What happens:**

- Reads the live earning records, so figures move while the payroll is being built. A stub that is finalized but not yet paid is still read live and can drift from what was finalized.
- Each row has a `category` matching a section of the stub: `commission`, `override`, `adjustment`, `reimbursement`, `additional_value` (custom payroll fields) or `deduction`.
- A row with `counts_toward_pay: false` is on the stub but excluded from its totals. `excluded_reason` says why: `paid_externally`, `do_not_pay`, `marked_paid`, `next_payroll`, `one_time_payment` or `moved_to_reconciliation`. These rows are summed into `totals.excluded_total`, not into their category.
- Wages, overtime, reconciliation and taxes are not itemized. They are totals on GET /v1/payroll.
- Money diverted into the user's reserve never reaches a stub, so it is not here. See GET /v1/users/{id}/reserve.

**Filtering and paging:**

- `category` returns one section. `totals` respect `category` but always cover the whole stub, never only the current page.
- `page` defaults to 1. `per_page` defaults to 50, maximum 500.
- Rows are sorted by category, then sale id, then `source` and `id`.

**Formats:**

- Amounts are JSON numbers in dollars, rounded to cents, signed as they affect the check: clawbacks and deductions are negative.
- `date` is the date the row was last updated (`YYYY-MM-DD`), not the date it was earned.
- `customer_name` is the sale's customer on deal rows and the user's own name on other rows.
- `product_code`, `milestone` and `customer_signoff` appear only on commission and override rows.
- `(source, id)` is the unique row key; `id` alone repeats across sources. Treat `source` as an opaque label.
- `pay_frequency` is the pay frequency id (`2` Weekly to `6` Daily).

**Errors:**

- `400 Invalid payroll id`, `400 Invalid category` (with `data.allowed_categories`), `400 page must be a positive integer`, `400 per_page must be an integer between 1 and 500`, and `400 Invalid query parameter(s)` for any other query key.
- `404 Payroll record not found`: usually the stub was paid. Use GET /v1/payroll-history/{id}/line-items with the same id.

**Related:**

- GET /v1/payroll/{id} returns the stub's totals.
- GET /v1/payroll-history/{id}/line-items is the same view after the stub is paid.
- GET /v1/users/{id}/earnings/items lists a user's earning lines with their `payroll_id`.

## Path parameters

- `id` (integer, **required**): The open pay stub id (`id` in GET /v1/payroll). Minimum: 1. Example: `5521`.

## Query parameters

- `category` (string): Return only one section of the stub. Omit for every row. One of: `commission`, `override`, `adjustment`, `reimbursement`, `additional_value`, `deduction`. Example: `commission`.
- `page` (integer): Page number. Default: `1`. Minimum: 1.
- `per_page` (integer): Rows per page. Default: `50`. Minimum: 1. Maximum: 500.

## Example request

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

## Responses

### 200: Line items for the open pay stub

- `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)
  - `requestedBy` (string): Label of the API credential that made the call.
  - `payroll_id` (integer): The pay stub id.
  - `user` (object): The user on the stub.
    - `id` (integer): User id.
    - `employee_id` (string, nullable): Employee id shown in Sequifi.
    - `first_name` (string): First name.
    - `last_name` (string): Last name.
    - `position_id` (integer, nullable): The user's current position id.
    - `position_name` (string, nullable): The user's current position name.
    - `worker_type` (string): Worker type on the stub: `1099` or `w2`.
  - `pay_period_from` (string (date)): Start of the pay period, `YYYY-MM-DD`.
  - `pay_period_to` (string (date)): End of the pay period, `YYYY-MM-DD`.
  - `pay_frequency` (integer): Pay frequency id.
  - `is_history` (boolean): Always `false` on this endpoint.
  - `totals` (object): Sums over the whole stub (after any `category` filter), never only this page.
    - `commission` (number): Counted commission rows.
    - `override` (number): Counted override rows.
    - `adjustment` (number): Counted adjustment rows.
    - `reimbursement` (number): Counted reimbursement rows.
    - `additional_value` (number): Counted custom payroll field rows.
    - `deduction` (number): Counted deduction rows (negative).
    - `line_items_total` (number): Sum of every row with `counts_toward_pay` true.
    - `excluded_total` (number): Sum of every row with `counts_toward_pay` false.
  - `filters` (object, nullable): `{category}` when filtered, otherwise null.
  - `current_page` (integer): Page returned.
  - `per_page` (integer): Rows per page.
  - `total` (integer): Rows across all pages.
  - `last_page` (integer): Last page number. At least `1`.
  - `line_items` (array of object): The rows on this page.
    - `id` (integer): Row id. Unique only together with `source`.
    - `source` (string): Opaque label for the kind of record. Use with `id` as the row key.
    - `category` (string): Section of the stub. One of: `commission`, `override`, `adjustment`, `reimbursement`, `additional_value`, `deduction`.
    - `type` (string): Label shown on the stub, for example `Commission`, `Clawback`, an override kind, an adjustment type or a deduction name.
    - `pid` (string, nullable): Sale id on deal rows, otherwise null.
    - `customer_name` (string, nullable): Sale customer on deal rows, the user's name on other rows.
    - `product_code` (string, nullable): Product code. Commission and override rows only.
    - `milestone` (string, nullable): Milestone name. Commission and override rows only.
    - `customer_signoff` (string, nullable): Sale date, `YYYY-MM-DD`. Commission and override rows only.
    - `amount` (number): Dollars as they affect the check. Clawbacks and deductions are negative.
    - `date` (string, nullable): Date the row was last updated, `YYYY-MM-DD`.
    - `description` (string, nullable): Free text from the row, if any.
    - `counts_toward_pay` (boolean): `false` when the row is shown on the stub but not paid on it.
    - `excluded_reason` (string, nullable): Why the row does not count, or null when it does. One of: `paid_externally`, `do_not_pay`, `marked_paid`, `next_payroll`, `one_time_payment`, `moved_to_reconciliation`, `null`.

```json
{
  "status": 200,
  "message": "success",
  "data": {
    "requestedBy": "acme",
    "payroll_id": 5521,
    "user": {
      "id": 4821,
      "employee_id": "EMP-4821",
      "first_name": "Alex",
      "last_name": "Morgan",
      "position_id": 14,
      "position_name": "Sales Rep",
      "worker_type": "1099"
    },
    "pay_period_from": "2026-07-26",
    "pay_period_to": "2026-08-01",
    "pay_frequency": 2,
    "is_history": false,
    "totals": {
      "commission": 1250,
      "override": 0,
      "adjustment": 0,
      "reimbursement": 0,
      "additional_value": 0,
      "deduction": 0,
      "line_items_total": 1250,
      "excluded_total": -300
    },
    "filters": null,
    "current_page": 1,
    "per_page": 50,
    "total": 2,
    "last_page": 1,
    "line_items": [
      {
        "id": 70114,
        "source": "user_commission",
        "category": "commission",
        "type": "Commission",
        "pid": "SALE-10482",
        "customer_name": "Riley Chen",
        "product_code": "SOLAR",
        "milestone": "Install Complete",
        "customer_signoff": "2026-06-29",
        "amount": 1250,
        "date": "2026-08-01",
        "description": null,
        "counts_toward_pay": true,
        "excluded_reason": null
      },
      {
        "id": 3307,
        "source": "approvals_and_requests",
        "category": "adjustment",
        "type": "Advance",
        "pid": null,
        "customer_name": "Alex Morgan",
        "amount": -300,
        "date": "2026-07-30",
        "description": "Advance repayment",
        "counts_toward_pay": false,
        "excluded_reason": "paid_externally"
      }
    ]
  }
}
```

### 400: Invalid payroll id, category, paging value or query parameter

Example (invalid_params): Unknown query parameter

```json
{
  "status": 400,
  "message": "Invalid query parameter(s)",
  "data": {
    "invalid_params": [
      "pay_period_from"
    ],
    "allowed_params": [
      "category",
      "page",
      "per_page"
    ]
  }
}
```

### 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"
}
```

### 404: No open stub with this id. It may have been paid.

```json
{
  "status": 404,
  "message": "Payroll record not found",
  "data": {}
}
```

### 500: Internal server error

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