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

# replaceState()

> `protected` **replaceState**(`next`): `Promise`\<`State`>

Replace the persistent state wholesale (no merging) and return it.

Unlike [`setState`](/docs/agent-sdk/interface/setState), nothing of the previous state
survives. [`onStateChanged`](/docs/agent-sdk/interface/onStateChanged) **does** fire —
with the new state and the state before the replacement. Connected
clients subscribed to the `state` stream receive the replacement as a
full snapshot — no broadcast call needed.

**Parameters**

| Parameter | Type | Description |
| - | - | - |
| `next` | `State` | The complete new state. |

**Returns**

`Promise`\<`State`>

`next`, as written.
