# Update an activity

Operation ID: `updateActivity`

Group: PSA › Activities

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

`PATCH /psa/activities/{id}`

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

Changes an activity (project task). Only the fields you send change; send null to clear a nullable field. Members are not changed here: use POST psa/activities/:id/members and POST psa/activities/:id/members/unassign.

The request is checked before anything is written, and every problem found is returned. Only what the request changes is validated: a stored value you leave alone does not fail the request even if it no longer meets a rule.

Changing billingType clears a stored milestone or fixed fee the new billing type cannot use. An activity that is invoiced, or carries time submitted for invoicing, cannot be changed.

## 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 activity to update. Needs edit permission on its project. Example: `"c4a91b07-6e52-4d38-9a1f-83b7de20c5f6"`. |

## Request body

Required, `application/json`: updateActivityInput.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | no | A new display name. Must not be blank. Example: `"Discovery workshop (2 days)"`. |
| `description` | string | no | A new free-form description. |
| `billingType` | string | no | A new billing type. A stored milestone or fixed fee the new type cannot use is cleared; the same rules as on create apply to the result. One of: `"Hours"`, `"Milestone"`, `"FixedFee"`. |
| `category` | string | no | A new category, with the same rules as on create. On a billable project a fixed-fee or milestone activity's category is always set from the billing type, and a value sent is ignored: it is re-set whenever the request changes the category, billingType or milestone. One of: `"ClientBillable"`, `"NonBillable"`, `"NonValuable"`, `"Valuable"`. |
| `hoursBudget` | decimal \| null | no | A new hours budget, a non-negative count of hours; null clears it. When members carry hoursBudget, it must equal their total. |
| `milestoneId` | string \| null | no | A milestone of the same project; null clears it. |
| `fixedFeeId` | string \| null | no | A fixed fee of the same project; null clears it. |
| `startDate` | date \| null | no | A new start date, format YYYY-MM-DD; null clears it. The resulting dates must be both set or both empty, the start not after the end. |
| `endDate` | date \| null | no | A new end date, format YYYY-MM-DD; null clears it. Example: `"2026-09-03"`. |
| `activityStatusId` | string \| null | no | An active activity status; null clears it. Example: `"8b3f0d62-17ce-4a95-b2e4-6d09a1c35f70"`. |
| `parentActivityId` | string \| null | no | A new parent activity on the same project; null makes the activity top-level. It cannot be the activity itself or one of its sub-tasks, and sub-tasks nest at most two levels. |

```json
{}
```

## Response

`200` Success

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

## 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 |
| `NO_CHANGES` | 400 |
| `ACTIVITY_INVOICED` | 400 |
| `ACTIVITY_BILLED` | 400 |
| `NAME_REQUIRED` | 400 |
| `INVALID_DATE_RANGE` | 400 |
| `INVALID_HOURS_BUDGET` | 400 |
| `MILESTONE_NOT_FOUND` | 400 |
| `FIXED_FEE_NOT_FOUND` | 400 |
| `MILESTONE_REQUIRED` | 400 |
| `FIXED_FEE_REQUIRED` | 400 |
| `BILLING_REFERENCE_MISMATCH` | 400 |
| `CATEGORY_NOT_ALLOWED` | 400 |
| `NON_VALUABLE_NOT_ALLOWED` | 400 |
| `OUTSIDE_FIXED_FEE_PERIOD` | 400 |
| `STATUS_NOT_FOUND` | 400 |
| `PARENT_NOT_FOUND` | 400 |
| `INVALID_PARENT` | 400 |
| `NESTING_TOO_DEEP` | 400 |
| `NON_BILLABLE_MEMBER` | 400 |
| `BUDGET_MISMATCH` | 400 |
| `IDEMPOTENCY_KEY_CONFLICT` | 409 |
| `IDEMPOTENCY_PAYLOAD_MISMATCH` | 422 |

## Advisories

Warnings and information a successful response can carry under `diagnostics`:

- `DATES_OUTSIDE_PROJECT`
- `DATES_OUTSIDE_PARENT`
- `SUBTASK_BUDGET_EXCEEDS_PARENT`

## Statuses

- `400` — Invalid request or business failure. Codes: NOT_FOUND, NO_CHANGES, ACTIVITY_INVOICED, ACTIVITY_BILLED, NAME_REQUIRED, INVALID_DATE_RANGE, INVALID_HOURS_BUDGET, MILESTONE_NOT_FOUND, FIXED_FEE_NOT_FOUND, MILESTONE_REQUIRED, FIXED_FEE_REQUIRED, BILLING_REFERENCE_MISMATCH, CATEGORY_NOT_ALLOWED, NON_VALUABLE_NOT_ALLOWED, OUTSIDE_FIXED_FEE_PERIOD, STATUS_NOT_FOUND, PARENT_NOT_FOUND, INVALID_PARENT, NESTING_TOO_DEEP, NON_BILLABLE_MEMBER, BUDGET_MISMATCH
- `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
