> ## 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.chipReplacements.create

> Retires one chip on an item and pairs a new one in its place.

```ts theme={null}
create(unitId: string, body: CreateChipReplacementRequest, options?: IdempotentRequestOptions): Promise<ChipReplacement>
```

|                 |                                                                                           |
| --------------- | ----------------------------------------------------------------------------------------- |
| Endpoint        | [`POST /v1/units/{unit_id}/chip-replacements`](/api-reference/chips/replace-a-units-chip) |
| Credential      | Secret key (`end_sk_...`)                                                                 |
| Retry class     | `keyed`                                                                                   |
| Idempotency key | Accepted                                                                                  |

Carries an idempotency key. Retried on network failure, timeout, `429`, and `409 idempotency.in_progress` - never on a `5xx`.

## Example

```ts theme={null}
const result = await endstate.chipReplacements.create(unit.id, {
  new_chip_id: "ABCDEF0123",
});
```

## Parameters

<ParamField body="unit_id" type="string" required />

<ParamField body="new_chip_id" type="string" required>
  The chip that replaces the unit's current chip. Must already exist and not be paired to any unit.
</ParamField>

## Returns

`201` - `ChipReplacement`.

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

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

<ResponseField name="old_chip_id" type="string" required>
  The chip being retired from the unit.
</ResponseField>

<ResponseField name="new_chip_id" type="string" required>
  The chip replacing it.
</ResponseField>

<ResponseField name="status" type="'prepared' | 'submitted' | 'confirmed' | 'failed'" required>
  Replacement progress. Poll until `confirmed`; `failed` is terminal.
</ResponseField>

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

## Errors

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

| Code                           | HTTP | Retry             |
| ------------------------------ | ---- | ----------------- |
| `auth.unauthorized`            | 401  | Do not retry      |
| `chip.already_paired`          | 409  | Do not retry      |
| `chip.not_found`               | 404  | Do not retry      |
| `chip_replacement.in_progress` | 409  | Poll the resource |
| `chip_replacement.locked`      | 409  | Do not retry      |
| `claim.in_progress`            | 409  | Poll the resource |
| `collection.not_active`        | 409  | Wait, then retry  |
| `idempotency.in_progress`      | 409  | Safe to retry     |
| `idempotency.key_conflict`     | 409  | Do not retry      |
| `internal.error`               | 500  | Safe to retry     |
| `unit.not_found`               | 404  | Do not retry      |
| `unit.not_minted`              | 409  | Poll the resource |
| `validation.failed`            | 400  | Do not retry      |

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