# WaitTime

Represents the Wait state which delays a state machine from continuing for a specified time.

- Source: [`aws-stepfunctions/lib/states/wait.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-stepfunctions/lib/states/wait.ts#L14)
- Type last changed: v2.178.0 · 6 Feb 2025

## Example

```ts
const convertToSeconds = new tasks.EvaluateExpression(this, 'Convert to seconds', {
  expression: '$.waitMilliseconds / 1000',
  resultPath: '$.waitSeconds',
});

const createMessage = new tasks.EvaluateExpression(this, 'Create message', {
  // Note: this is a string inside a string.
  expression: '`Now waiting ${$.waitSeconds} seconds...`',
  runtime: lambda.Runtime.NODEJS_LATEST,
  resultPath: '$.message',
});

const publishMessage = new tasks.SnsPublish(this, 'Publish message', {
  topic: new sns.Topic(this, 'cool-topic'),
  message: sfn.TaskInput.fromJsonPathAt('$.message'),
  resultPath: '$.sns',
});

const wait = new sfn.Wait(this, 'Wait', {
  time: sfn.WaitTime.secondsPath('$.waitSeconds'),
});

new sfn.StateMachine(this, 'StateMachine', {
  definition: convertToSeconds
    .next(createMessage)
    .next(publishMessage)
    .next(wait),
});
```

## Methods

- `duration(duration: Duration): WaitTime // chainable` (static) — Wait a fixed amount of time.

- `seconds(seconds: string): WaitTime // chainable` (static) — Wait for a number of seconds stored in the state object from string. This method can use JSONata expression.

  If you want to use fixed value, we recommend using `WaitTime.duration()`

  Example value: `{% $waitSeconds %}`

- `secondsPath(path: string): WaitTime // chainable` (static) — Wait for a number of seconds stored in the state object.

  Example value: `$.waitSeconds`

- `timestamp(timestamp: string): WaitTime // chainable` (static) — Wait until the given ISO8601 timestamp. This method can use JSONata expression.

  Example value: `2016-03-14T01:59:00Z`

- `timestampPath(path: string): WaitTime // chainable` (static) — Wait until a timestamp found in the state object.

  Example value: `$.waitTimestamp`
