# Bulk update milestones

Operation ID: `updateMilestones`

Group: PSA › Milestones

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

`PATCH /psa/milestones`

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

Updates milestones in one request, with the fields you send. A field you leave out keeps its current value; send null to clear a nullable one. If any milestone can't be updated, none are, and every broken rule is reported with its own error code. 'index' in an error's details is the milestone's position in the request.

The rules match the project's Milestones tab, and an invoiced milestone can't be changed. A milestone can't move to another project. Products and sales order links can't be set through this API, and an update leaves the ones set in the Milestones tab as they are, with two exceptions the tab also applies: turning billable off sets the amount to 0 and removes them, and while an invoice milestone is linked, the milestone's name, and its amount when the invoice milestone has a price, come from the invoice milestone, whatever you send. Every identifier you send is a UUID.

The response is empty. Read an updated milestone with GET psa/milestones/: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. |

## Request body

Required, `application/json`: updateMilestonesInput.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `milestones` | array<object> | yes | The milestones to update. If any of them can't be updated, none are. Example: `[{"id":"9b1c7f42-3d8a-4e05-b6c1-27fa5e903d18","status":"accomplished"},{"id":"5e0a4c1b-8f27-4d63-a9b2-c14d7e66f031","name":"Go-live","description":null,"dueDate":"2027-01-15","amount":"27500.00"}]`. |
| `milestones[].id` | string | yes | The unique identifier of the milestone to update. Each milestone can appear only once per request. |
| `milestones[].name` | string | no | A new display name. Can't be empty. Ignored while an invoice milestone is linked, which owns the name. |
| `milestones[].description` | string \| null | no | A new free-form description. Send null to clear it. |
| `milestones[].dueDate` | date | no | A new due date. Must be within the project's start and end dates. Use format YYYY-MM-DD. |
| `milestones[].status` | string | no | A new status. A milestone becomes 'invoiced' only through invoicing. One of: `"pending"`, `"accomplished"`. |
| `milestones[].billable` | boolean | no | Whether the milestone is billable to a customer. Can't be true on an Internal or NonBillable project. Turning it off sets the amount to 0 and removes any product or sales order link; sending a link along with billable false is rejected. |
| `milestones[].amount` | decimal \| null | no | A new amount, in the project currency. A billable milestone needs one other than 0; not negative, at most 2 decimal places. Must be null or 0 when the milestone is not billable. Ignored while a linked invoice milestone has a price. |
| `milestones[].salesOrderProductLineId` | string \| null | no | The sales order product line this milestone fulfills. It must be a one-time, milestone-billed line on a sales order of the project's sales arrangement that no other project uses. Only on a billable milestone. Send null to unlink. Omit to keep the stored link. See id in the salesOrderProductLines collection (SalesOrderListProductLinesEndpointV1). |
| `milestones[].invoiceMilestoneId` | string \| null | no | The invoice milestone this milestone is linked to. It must be on salesOrderProductLineId, not yet invoiced, and not linked to another milestone of the project. While linked, it sets the milestone's name and, when it has a price, its amount. When newly linked and no dueDate is sent, the due date becomes the invoice milestone's projected date. Send null to unlink. Omit to keep the stored one; moving to another sales order product line without sending one removes it. See invoiceMilestoneId on GET psa/milestones/:id. |

```json
{
  "milestones": [
    {
      "id": "9b1c7f42-3d8a-4e05-b6c1-27fa5e903d18",
      "status": "accomplished"
    },
    {
      "id": "5e0a4c1b-8f27-4d63-a9b2-c14d7e66f031",
      "name": "Go-live",
      "description": null,
      "dueDate": "2027-01-15",
      "amount": "27500.00"
    }
  ]
}
```

## 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 |
| `DUPLICATE_ID` | 400 |
| `FORBIDDEN` | 400 |
| `MILESTONE_INVOICED` | 400 |
| `NAME_REQUIRED` | 400 |
| `BILLABLE_NOT_ALLOWED` | 400 |
| `AMOUNT_REQUIRED` | 400 |
| `AMOUNT_NOT_ALLOWED` | 400 |
| `AMOUNT_NEGATIVE` | 400 |
| `AMOUNT_TOO_PRECISE` | 400 |
| `DUE_DATE_OUTSIDE_PROJECT` | 400 |
| `SALES_ORDER_LINK_NOT_ALLOWED` | 400 |
| `SALES_ORDER_PRODUCT_LINE_NOT_AVAILABLE` | 400 |
| `INVOICE_MILESTONE_NOT_AVAILABLE` | 400 |
| `IDEMPOTENCY_KEY_CONFLICT` | 409 |
| `IDEMPOTENCY_PAYLOAD_MISMATCH` | 422 |

## Statuses

- `400` — Invalid request or business failure. Codes: NOT_FOUND, DUPLICATE_ID, FORBIDDEN, MILESTONE_INVOICED, NAME_REQUIRED, BILLABLE_NOT_ALLOWED, AMOUNT_REQUIRED, AMOUNT_NOT_ALLOWED, AMOUNT_NEGATIVE, AMOUNT_TOO_PRECISE, DUE_DATE_OUTSIDE_PROJECT, SALES_ORDER_LINK_NOT_ALLOWED, SALES_ORDER_PRODUCT_LINE_NOT_AVAILABLE, INVOICE_MILESTONE_NOT_AVAILABLE
- `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
