Stay organized with collections
Save and categorize content based on your preferences.
The sys.sleepstandard library function
suspends execution for the given number of seconds to a maximum of 31536000 (one
year).
Pause a workflow
You can pause the execution of a workflow by adding a sleep step to your
workflow's definition. This step includes a call to sys.sleep and specifies in
seconds how long you want to pause the workflow:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Wait using polling\n\nThe `sys.sleep` [standard library function](/workflows/docs/reference/stdlib/sys/sleep)\nsuspends execution for the given number of seconds to a maximum of 31536000 (one\nyear).\n\nPause a workflow\n----------------\n\nYou can pause the execution of a workflow by adding a sleep step to your\nworkflow's definition. This step includes a call to `sys.sleep` and specifies in\nseconds how long you want to pause the workflow: \n\n### YAML\n\n```yaml\n - STEP_NAME:\n call: sys.sleep\n args:\n seconds: SLEEP_IN_SECONDS\n \n```\n\n### JSON\n\n```json\n [\n {\n \"\u003cvar translate=\"no\"\u003eSTEP_NAME\u003c/var\u003e\": {\n \"call\": \"sys.sleep\",\n \"args\": {\n \"seconds\": \"\u003cvar translate=\"no\"\u003eSLEEP_IN_SECONDS\u003c/var\u003e\"\n }\n }\n }\n ]\n \n```\n\nPoll for data\n-------------\n\nYou can also use `sys.sleep` to poll for data over a given interval. For example,\nyou might want to poll an API until a specific condition is met: \n\n### YAML\n\n```yaml\n main:\n params: [jobId]\n steps:\n - checkJob:\n call: http.get\n args:\n url: ${\"https://example.com/jobs/\" + jobId}\n auth:\n type: OAuth2\n result: jobStatus\n - checkIfDone:\n switch:\n - condition: ${jobStatus.complete}\n return: ${jobStatus}\n - wait:\n call: sys.sleep\n args:\n seconds: 60\n next: checkJob\n \n```\n\n### JSON\n\n```json\n {\n \"main\": {\n \"params\": [\n \"jobId\"\n ],\n \"steps\": [\n {\n \"checkJob\": {\n \"call\": \"http.get\",\n \"args\": {\n \"url\": \"${\\\"https://example.com/jobs/\\\" + jobId}\",\n \"auth\": {\n \"type\": \"OAuth2\"\n }\n },\n \"result\": \"jobStatus\"\n }\n },\n {\n \"checkIfDone\": {\n \"switch\": [\n {\n \"condition\": \"${jobStatus.complete}\",\n \"return\": \"${jobStatus}\"\n }\n ]\n }\n },\n {\n \"wait\": {\n \"call\": \"sys.sleep\",\n \"args\": {\n \"seconds\": 60\n },\n \"next\": \"checkJob\"\n }\n }\n ]\n }\n }\n \n```"]]