---
editLink: false
lastUpdated: false
---

[@salesforce/b2c-tooling-sdk](../../../modules.md) / [operations/ods](../index.md) / waitForSandbox

# Function: waitForSandbox()

> **waitForSandbox**(`client`, `options`): `Promise`\<`void`\>

Defined in: [packages/b2c-tooling-sdk/src/operations/ods/wait-for-sandbox.ts:100](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/e7c16f1ae423da0aa47b3e10be88f9770b53619b/packages/b2c-tooling-sdk/src/operations/ods/wait-for-sandbox.ts#L100)

Waits for a sandbox to reach a target state by polling its status.

This function polls the ODS API at regular intervals until the sandbox reaches the desired state,
times out, or enters a terminal error state (failed/deleted).

## Parameters

### client

[`OdsClient`](../../../clients/type-aliases/OdsClient.md)

ODS client for API calls

### options

[`WaitForSandboxOptions`](../interfaces/WaitForSandboxOptions.md)

Polling configuration options

## Returns

`Promise`\<`void`\>

## Throws

If the timeout is exceeded before reaching target state

## Throws

If the API request fails

## Throws

If the sandbox enters a terminal error state

## Example

```typescript
await waitForSandbox(odsClient, {
  sandboxId: 'abc-123',
  targetState: 'started',
  pollIntervalSeconds: 5,
  timeoutSeconds: 300,
  onPoll: (info) => console.log(`State: ${info.state} (${info.elapsedSeconds}s)`),
});
```
