> ## Documentation Index
> Fetch the complete documentation index at: https://docs.endstate.io/llms.txt
> Use this file to discover all available pages before exploring further.

# endstate.units.update

> Updates a unit's tap redirect URL. Send null to clear.

```ts theme={null}
update(unitId: string, body: UpdateUnitRequest, options?: RequestOptions): Promise<Unit>
```

|             |                                                                   |
| ----------- | ----------------------------------------------------------------- |
| Endpoint    | [`PATCH /v1/units/{unit_id}`](/api-reference/units/update-a-unit) |
| Credential  | Secret key (`end_sk_...`)                                         |
| Retry class | `write`                                                           |

Never repeated. The API accepts no idempotency key here, so a second send is a second write. Only `429 rate_limit.exceeded` is retried.

## Example

```ts theme={null}
const result = await endstate.units.update(unit.id, {
  redirect_url: "https://brand.example/p",
});
```

## Parameters

<ParamField body="unit_id" type="string" required>
  Unit id.
</ParamField>

<ParamField body="redirect_url" type="string | null" required>
  Tap redirect URL for this unit. Send null to clear.
</ParamField>

## Returns

`200` - `Unit`.

<ResponseField name="id" type="string" required />

<ResponseField name="external_id" type="string | null" required />

<ResponseField name="name" type="string | null" required />

<ResponseField name="attributes" type="object | null" required />

<ResponseField name="created_at" type="string" required />

<ResponseField name="redirect_url" type="string | null" required>
  Tap redirect URL for this unit; takes precedence over product/collection/org defaults.
</ResponseField>

<ResponseField name="collection" type="object | null" required>
  The unit's collection. Null only for units created before collections existed.
</ResponseField>

<ResponseField name="chips" type="object[]" required>
  Chips paired to this unit.
</ResponseField>

## Errors

Branch on `error.code`, never on the HTTP status - several codes share one.

| Code                  | HTTP | Retry         |
| --------------------- | ---- | ------------- |
| `auth.unauthorized`   | 401  | Do not retry  |
| `internal.error`      | 500  | Safe to retry |
| `rate_limit.exceeded` | 429  | Safe to retry |
| `unit.not_found`      | 404  | Do not retry  |
| `validation.failed`   | 400  | Do not retry  |

See [Errors and retries](/sdks/core/errors-and-retries) for the error types and how to narrow them.
