Skip to content
Get started

Wait for instance to reach a target state

client.instances.wait(stringid, InstanceWaitParams { state, timeout } query, RequestOptionsoptions?): WaitForStateResponse { state, timed_out, state_error }
get/instances/{id}/wait

Blocks until the instance reaches the specified target state, the timeout expires, or the instance enters a terminal/error state. Useful for avoiding client-side polling when waiting for state transitions (e.g. waiting for an instance to become Running).

ParametersExpand Collapse
id: string
query: InstanceWaitParams { state, timeout }
state: "Created" | "Initializing" | "Running" | 5 more

Target state to wait for

Accepts one of the following:
"Created"
"Initializing"
"Running"
"Paused"
"Shutdown"
"Stopped"
"Standby"
"Unknown"
timeout?: string

Maximum duration to wait (Go duration format, e.g. "30s", "2m"). Capped at 5 minutes. Defaults to 60 seconds.

ReturnsExpand Collapse
WaitForStateResponse { state, timed_out, state_error }
state: "Created" | "Initializing" | "Running" | 5 more

Current instance state when the wait completed

Accepts one of the following:
"Created"
"Initializing"
"Running"
"Paused"
"Shutdown"
"Stopped"
"Standby"
"Unknown"
timed_out: boolean

Whether the timeout expired before the target state was reached

state_error?: string | null

Error message when derived state is Unknown

Wait for instance to reach a target state
import Hypeman from '@onkernel/hypeman';

const client = new Hypeman({
  apiKey: 'My API Key',
});

const waitForStateResponse = await client.instances.wait('id', { state: 'Created' });

console.log(waitForStateResponse.state);
{
  "state": "Created",
  "timed_out": true,
  "state_error": "state_error"
}
Returns Examples
{
  "state": "Created",
  "timed_out": true,
  "state_error": "state_error"
}