Wait workflow state - Amazon Step Functions
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Wait workflow state

Managing state and transforming data

Step Functions recently added variables and JSONata to manage state and transform data.

Learn about Passing data with variables and Transforming data with JSONata.

A Wait state ("Type": "Wait") delays the state machine from continuing for a specified time. You can choose either a relative time, specified in seconds from when the state begins, or an absolute end time, specified as a timestamp.

In addition to the common state fields, Wait states have one of the following fields.

Seconds

A time, in seconds, to wait before beginning the state specified in the Next field. You must specify time as a positive, integer value from 0 up to 99999999.

In JSONata states, you can specify a JSONata expression which must evaluate to a positive integer in the stated range.

Timestamp

An absolute time to wait until beginning the state specified in the Next field.

Timestamps must conform to the RFC3339 profile of ISO 8601, with the further restrictions that an uppercase T must separate the date and time portions, and an uppercase Z must denote that a numeric time zone offset is not present, for example, 2024-08-18T17:33:00Z.

In JSONata states, you can specify a JSONata expression which results in a string that conforms to the previous requirements.

Note

Currently, if you specify the wait time as a timestamp, Step Functions considers the time value up to seconds and truncates milliseconds.

SecondsPath (Optional, JSONPath only)

A time, in seconds, to wait before beginning the state specified in the Next field, specified using a path from the state's input data.

You must specify an integer value for this field.

TimestampPath (Optional, JSONPath only)

An absolute time to wait until beginning the state specified in the Next field, specified using a path from the state's input data.

Note

You must specify exactly one of Seconds, Timestamp, SecondsPath, or TimestampPath. In addition, the maximum wait time that you can specify for Standard Workflows and Express workflows is one year and five minutes respectively.

Wait State Examples

The following Wait state introduces a 10-second delay into a state machine.

"wait_ten_seconds": { "Type": "Wait", "Seconds": 10, "Next": "NextState" }

In the next example, the Wait state waits until an absolute time: March 14, 2024, at 1:59 AM UTC.

"wait_until" : { "Type": "Wait", "Timestamp": "2024-03-14T01:59:00Z", "Next": "NextState" }

You don't have to hard-code the wait duration. For example, given the following input data:

{ "expirydate": "2024-03-14T01:59:00Z" }

You can select the value of "expirydate" from the input using a reference path to select it from the input data.

"wait_until" : { "Type": "Wait", "TimestampPath": "$.expirydate", "Next": "NextState" }