# Update a payroll detail

Operation ID: `updatePayrollDetail`

Group: Accounting › Payroll Details

[Open in the interactive reference](https://docs.api.lensing.ai/lensing/v1/endpoints/updatePayrollDetail)

`PATCH /accounting/payroll-details/{id}`

Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.

Updates a payroll detail with the fields you send. A field you leave out keeps its current value.

Use the payroll detail's id, not its payrollDetailNumber.

lines and attachments are lists. A list you send replaces the whole list, so include every item you want to keep. Send an empty array to remove them all.

Leave a list out to keep it as it is. Every update creates the lines again, even when you leave lines out, so line ids change.

The payroll detail's main fields, lines, and attachments can change. The legal entity can't.

The same checks as on create apply to the result: the lines you send must balance, and the accounting period must be open for the resulting journal entry date. Each category must be an active category of the template or one the payroll detail already uses.

The response is empty. To see the updated payroll detail, use GET accounting/payroll-details/:id.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Api-Version` | header | string · v1 | yes | The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version `v1`. |
| `Idempotency-Key` | header | string | no | An opaque caller-chosen string (1-255 characters) that makes this request safe to retry. Repeating the same key with an identical request body replays the original response instead of re-executing - but only once that original request succeeded; a failed attempt re-executes on retry. Repeating the key with a different body is answered with 422. A key still in flight is answered with 409 - as is a key whose original request was interrupted before it finished, for a few minutes afterwards, until that attempt is presumed dead. A completed response stays replayable for 24 hours. The key is scoped to the caller, not to the action: reusing it for a different action is answered with 409 or 422 rather than treated independently. On read actions this header is ignored. On write actions that cannot offer the guarantee it is answered with `400 IDEMPOTENCY_NOT_SUPPORTED` rather than silently ignored. |
| `id` | path | string | yes | The unique identifier of the payroll detail you want to update. Example: `"4d8f2b61-7a09-4c35-8e12-9b3d5f0a6c47"`. |

## Request body

Required, `application/json`: updatePayrollDetailInput.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `templateId` | string | no | The payroll template this run uses. See id on GET accounting/payroll-templates/:id. Omit to leave unchanged. |
| `grouping` | string | no | How the payroll is grouped. Values include 'Employee', 'Department' and 'Multi-level'. Omit to leave unchanged. |
| `status` | string | no | The status of the payroll. Omit to leave unchanged. |
| `payrollDate` | date | no | The issue date of the payroll. Use format YYYY-MM-DD. Omit to leave unchanged. |
| `startDate` | date | no | The first day of the payroll period. Use format YYYY-MM-DD. Omit to leave unchanged. |
| `endDate` | date | no | The last day of the payroll period. Use format YYYY-MM-DD. Omit to leave unchanged. |
| `currency` | string | no | The currency the payroll is denominated in. Format ISO 4217, for example 'USD'. Omit to leave unchanged. |
| `description` | string | no | A description of the payroll. Omit to leave unchanged. Example: `"August 2026 payroll (revised)"`. |
| `isNetPayCategoryMapped` | boolean | no | Whether the net-pay category is matched in the account mapping. Omit to leave unchanged. |
| `origin` | string | no | The source system this record came from, as free-form text, for example 'Ramp'. Omit it and it stays unset. The server does not set a value. |
| `lines` | array<object> | no | The complete replacement set of lines. Omit to keep the stored lines. Send an empty array to clear them. Child ids are neither published nor preserved. Example: `[{"employeeId":"3f1a8c25-9d47-4e60-b892-0c5a7e3b1d84","lineItems":[{"categoryId":"9b2d5e10-4c78-4a36-8f51-6e0a3c7b2d95","amount":"5200.00"},{"categoryId":"e5c7a390-1d64-4b28-9a07-2f8b6d4c1e53","amount":"5200.00"}]}]`. |
| `lines[].employeeId` | string | no | The employee this line is for. There is no endpoint for it. With grouping 'Employee', a line that names an employee but no department has the department backfilled from that employee's primary job. |
| `lines[].departmentId` | string | no | The department this line is charged to. See id on GET people/departments/:id. |
| `lines[].lineItems` | array<object> | yes | The amounts on this line, one per payroll category. Each category must be reachable from the payroll's template. An item whose amount is null is dropped before the payroll is saved. |
| `lines[].lineItems[].categoryId` | string | yes | The payroll category this amount belongs to. There is no endpoint for it. It must be an active category of the payroll's template, or one the payroll already uses. |
| `lines[].lineItems[].amount` | decimal | yes | The amount for this category, as a decimal in the payroll's currency. |
| `attachments` | array<object> | no | Files to attach to the payroll, as a complete replacement set. Omit to keep the stored attachments. Send an empty array to clear them. |
| `attachments[].fileName` | string | yes | The display name of the attached file. |
| `attachments[].fileId` | string | yes | The identifier of the uploaded file in file storage, as a text reference. There is no endpoint for it. |

```json
{
  "templateId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "grouping": "<grouping>",
  "status": "<status>",
  "payrollDate": "2026-01-15",
  "startDate": "2026-01-15",
  "endDate": "2026-01-15",
  "currency": "<currency>",
  "description": "August 2026 payroll (revised)",
  "isNetPayCategoryMapped": true,
  "origin": "<origin>",
  "lines": [
    {
      "employeeId": "3f1a8c25-9d47-4e60-b892-0c5a7e3b1d84",
      "lineItems": [
        {
          "categoryId": "9b2d5e10-4c78-4a36-8f51-6e0a3c7b2d95",
          "amount": "5200.00"
        },
        {
          "categoryId": "e5c7a390-1d64-4b28-9a07-2f8b6d4c1e53",
          "amount": "5200.00"
        }
      ]
    }
  ],
  "attachments": [
    {
      "fileName": "<fileName>",
      "fileId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
    }
  ]
}
```

## Response

`200` Success

```json
{
  "data": {},
  "diagnostics": [
    {
      "code": "<code>",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": "<details>"
    }
  ]
}
```

## Response headers

- `Idempotency-Replayed` — Present and `true` only when this response replays a previously stored one for the same Idempotency-Key, rather than reflecting a live execution. Absent on a live response - never sent as `false`.

## Errors

| Code | Status |
| --- | --- |
| `NOT_FOUND` | 400 |
| `REFERENCE_NOT_FOUND` | 400 |
| `CATEGORY_NOT_IN_TEMPLATE` | 400 |
| `INVALID_DATE_RANGE` | 400 |
| `AMOUNT_NOT_BALANCED` | 400 |
| `NO_ACCOUNTING_BOOK` | 400 |
| `NO_ACCOUNTING_PERIOD` | 400 |
| `POSTING_PERIOD_CLOSED` | 400 |
| `TOO_MANY_LINES` | 400 |
| `ATTACHMENT_REQUIRED` | 400 |
| `IDEMPOTENCY_KEY_CONFLICT` | 409 |
| `IDEMPOTENCY_PAYLOAD_MISMATCH` | 422 |

## Statuses

- `400` — Invalid request or business failure. Codes: NOT_FOUND, REFERENCE_NOT_FOUND, CATEGORY_NOT_IN_TEMPLATE, INVALID_DATE_RANGE, AMOUNT_NOT_BALANCED, NO_ACCOUNTING_BOOK, NO_ACCOUNTING_PERIOD, POSTING_PERIOD_CLOSED, TOO_MANY_LINES, ATTACHMENT_REQUIRED
- `401` — The request carries no valid access token.
- `403` — Not authorized
- `404` — Not found
- `409` — The Idempotency-Key is still being processed by another request.
- `422` — The Idempotency-Key was already used with a different request payload.
- `429` — Too many requests from this client address. The response has no body and no `Retry-After` header.
- `500` — Internal server error
