Skip to main content
Context actions are methods available on the Restate Context object (ctx) that provide Restate’s core capabilities. These actions enable durable execution, state management, service communication, and timing control.

Durable steps

Use run to safely wrap any non-deterministic operation, like HTTP calls or database responses, and have Restate persist its result.
Without run(), these operations would produce different results during replay, breaking deterministic recovery.

State management

Available in Virtual Object and Workflow handlers for persistent key-value storage.

Get

Retrieve stored state by key.

Set

Store state that persists across function invocations.

Clear

State is retained indefinitely for Virtual Objects, or for the configured retention period for Workflows. To clear state:

Service communication

Request-response calls

Make request-response calls to other services. Your function waits for the result.

Sending messages

Make one-way calls that don’t return results. Your function continues immediately.

Delayed messages

Schedule handlers to run in the future.

Durable timers and timeouts

Pause function execution for a specific duration.
Handlers consume no resources while sleeping and resume at exactly the right time, even across restarts (see suspensions).

Workflow events

Use durable promises to wait for external events or human input in your workflows. Create promises that external systems can resolve to send data to your workflow.
Resolve promises from signal handlers.
To implement a similar pattern in Basic Services or Virtual Objects, have a look at awakeables (TS/Java/Kotlin/Go/Python).