Upstash Workflow provides a Sleep feature that allows you to pause workflow execution for specified durations without consuming compute resources. This feature enables you to build time-based workflows, implement delays between steps, and create scheduled operations without the limitations of traditional serverless timeouts.Documentation Index
Fetch the complete documentation index at: https://upstash-cloud-4245.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
How Sleep Works
When you usecontext.sleep or context.sleepUntil in your workflow, Upstash Workflow automatically pauses execution and schedules the next step to run after the specified delay.
This happens without keeping your serverless function running, making it cost-effective and reliable for long delays.
Important: Sleep durations have limits based on your pricing plan:
- Free: Maximum delay of 7 days
- Pay-as-you-go: Maximum delay of 1 year
- Fixed pricing: Custom delays (no limit)
Sleep Methods
Upstash Workflow provides two methods for implementing delays in your workflows:1. context.sleep
Pauses workflow execution for a specified duration relative to the current time."10s"= 10 seconds"1m"= 1 minute"30m"= 30 minutes"2h"= 2 hours"1d"= 1 day"1w"= 1 week"1mo"= 1 month"1y"= 1 year
60= 60 seconds (1 minute)3600= 3600 seconds (1 hour)86400= 86400 seconds (1 day)
2. context.sleepUntil
Pauses workflow execution until a specific timestamp in the future.context.sleepUntil, you can use:
Dateobjects (JavaScript/TypeScript)- Unix timestamps (Python)
- ISO string dates