@@ -15031,35 +15031,327 @@ Source: https://upstash.com/docs/qstash/overall/roadmap
1503115031# Use Cases
1503215032Source: https://upstash.com/docs/qstash/overall/usecases
1503315033
15034- TODO: andreas: rework and reenable this page after we have 2 use cases ready
15035- https://linear.app/upstash/issue/QSTH-84/use-cases-summaryhighlights-of-recipes
15034+ QStash is an HTTP-based messaging and scheduling service. You hand it a request,
15035+ and QStash delivers it to your endpoint later — with retries, delays, ordering,
15036+ rate limits, and a dead letter queue when things go wrong.
1503615037
15037- This section is still a work in progress.
15038+ That makes it a fit for any work that shouldn't happen inside the request that
15039+ triggered it: tasks that take too long, tasks that must survive a failure, tasks
15040+ that must run on a schedule, and tasks that must not overwhelm the service they
15041+ call.
1503815042
15039- We will be adding detailed tutorials for each use case soon.
15043+ Because everything is HTTP, there is no consumer to keep running. Your existing
15044+ API endpoints *are* the consumers, wherever they are deployed — Vercel, AWS
15045+ Lambda, Cloudflare Workers, Fly.io, or your own servers.
1504015046
15041- Tell us on [Discord](https://discord.gg/w9SenAtbme) or
15042- [X](https://x.com/upstash) what you would like to see here.
15047+ ## Background jobs
1504315048
15044- ### Triggering Nextjs Functions on a schedule
15049+ Serverless platforms cap how long a function can run. Anything heavier than a
15050+ few seconds — video processing, report generation, importing a CSV, calling a
15051+ slow third-party API — risks a timeout, and the user is waiting for it.
1504515052
15046- Create a schedule in QStash that runs every hour and calls a Next.js serverless
15047- function hosted on Vercel .
15053+ With QStash, your handler publishes a message and returns immediately. QStash
15054+ calls a second endpoint that does the real work, retrying if it fails .
1504815055
15049- ### Reset Billing Cycle in your Database
15056+ ```typescript
15057+ import { Client } from "@upstash/qstash";
15058+
15059+ const client = new Client({ token: process.env.QSTASH_TOKEN! });
15060+
15061+ await client.publishJSON({
15062+ url: "https://your-app.com/api/process-video",
15063+ body: { videoId },
15064+ retries: 3,
15065+ });
15066+ ```
15067+
15068+ If the job itself is longer than a single function invocation allows, use
15069+ [callbacks](/docs/qstash/features/callbacks) so QStash delivers the response to
15070+ another endpoint once it's ready, instead of your caller blocking on it.
15071+
15072+ <Card
15073+ title="Background Jobs"
15074+ icon="share-all"
15075+ href="/qstash/features/background-jobs"
15076+ >
15077+ Full walkthrough, including local development
15078+ </Card>
15079+
15080+ ## Scheduled and recurring tasks
15081+
15082+ Anything you would put in a cron job — nightly reports, resetting billing
15083+ cycles, expiring trials, syncing a search index, warming a cache — becomes a
15084+ [schedule](/docs/qstash/features/schedules) that calls your endpoint on a cron
15085+ expression.
1505015086
15051- Once a month, reset database entries to start a new billing cycle.
15087+ ```typescript
15088+ await client.schedules.create({
15089+ destination: "https://your-app.com/api/daily-report",
15090+ cron: "0 8 * * *",
15091+ });
15092+ ```
15093+
15094+ Schedules run in UTC by default and support
15095+ [timezones](/docs/qstash/features/schedules#timezones). Unlike platform-native cron
15096+ (such as Vercel Cron), schedules are not tied to a deploy, are not limited to
15097+ one per plan tier, and retry on failure.
15098+
15099+ ## Reliable webhook delivery
15100+
15101+ Webhooks are the most common reason people reach for QStash, in both
15102+ directions:
15103+
15104+ **Receiving webhooks.** Point Stripe, GitHub, Shopify, or Clerk at a QStash
15105+ publish URL instead of your endpoint directly. QStash absorbs the burst, retries
15106+ if your app is down or mid-deploy, and applies whatever delay, timeout, or
15107+ [flow control](/docs/qstash/features/flowcontrol) you configure. The provider gets a
15108+ fast 2xx even when your processing is slow.
15109+
15110+ **Sending webhooks.** If you deliver webhooks to your own customers, QStash
15111+ handles the part nobody wants to build: exponential retries, per-customer
15112+ concurrency limits, and a [dead letter queue](/docs/qstash/features/dlq) for
15113+ endpoints that stay down.
15114+
15115+ <CardGroup cols={2}>
15116+ <Card title="Use as Webhook Receiver" icon="webhook" href="/qstash/howto/webhook">
15117+ Publish URLs, URL Groups, and header forwarding
15118+ </Card>
15119+ <Card
15120+ title="Building Reliable & Type-Safe Webhooks"
15121+ icon="book"
15122+ href="https://upstash.com/blog/webhook-system-with-qstash"
15123+ >
15124+ Designing an outbound webhook system on QStash
15125+ </Card>
15126+ </CardGroup>
1505215127
15053- ### Fanning out alerts to Slack, email, Opsgenie, etc.
15128+ ## Fan- out to multiple services
1505415129
15055- Createa QStash URL Group that receives alerts from a single source and delivers them
15056- to multiple destinations.
15130+ One event often needs to reach several places: a purchase should trigger a
15131+ receipt email, a Slack notification, an analytics event, and a warehouse
15132+ webhook.
15133+
15134+ Publish once to a [URL Group](/docs/qstash/features/url-groups) and QStash creates an
15135+ independent, independently-retried delivery for each subscribed endpoint. Adding
15136+ or removing a consumer is a URL Group change — no redeploy of the producer.
15137+
15138+ ```typescript
15139+ await client.publishJSON({
15140+ urlGroup: "order-created",
15141+ body: { orderId },
15142+ });
15143+ ```
15144+
15145+ The same shape works for alerting: one alert source fanned out to Slack, email,
15146+ and PagerDuty.
15147+
15148+ ## Rate-limited and fragile third-party APIs
15149+
15150+ When you call an API with a quota — OpenAI, Resend, Shopify, a partner's
15151+ internal service — the hard part is not calling it, it's not calling it too
15152+ often. [Flow Control](/docs/qstash/features/flowcontrol) lets QStash hold messages
15153+ back for you, by request rate, by concurrency, or both.
15154+
15155+ ```typescript
15156+ await client.publishJSON({
15157+ url: "https://your-app.com/api/summarize",
15158+ body: { articleId },
15159+ flowControl: { key: "openai", parallelism: 5, rate: 60, period: "1m" },
15160+ });
15161+ ```
15162+
15163+ You can publish ten thousand messages at once and let QStash drip them out at
15164+ the rate your downstream tolerates, instead of building a queue and a limiter
15165+ yourself. Limits apply per key, so the same key can span multiple URLs.
15166+
15167+ <Card
15168+ title="Efficient Article Summarization with QStash"
15169+ icon="book"
15170+ href="https://upstash.com/blog/article-summarizer-qstash-python"
15171+ >
15172+ Handling API rate limits and parallel processing in Python
15173+ </Card>
15174+
15175+ ## AI and LLM requests
15176+
15177+ LLM calls are slow, variable, and expensive to retry by hand — a bad match for a
15178+ 10-second serverless timeout. QStash gives them a 2-hour HTTP timeout, delivers
15179+ the response to a [callback](/docs/qstash/features/callbacks) endpoint when it's
15180+ done, and can [batch](/docs/qstash/features/batch) many requests in one publish.
15181+
15182+ There are built-in integrations for [OpenAI-compatible
15183+ providers](/docs/qstash/integrations/llm) and [Anthropic](/docs/qstash/integrations/anthropic),
15184+ so QStash calls the provider for you and you only handle the callback.
15185+
15186+ Combined with flow control, this is a practical way to run bulk embedding jobs,
15187+ document summarization, or content generation without hitting provider rate
15188+ limits.
15189+
15190+ ## Delayed and time-based messages
15191+
15192+ Some work is defined by *when* it should happen: a welcome email 10 minutes
15193+ after signup, a trial-ending reminder 3 days out, an abandoned-cart nudge, a
15194+ retry of a payment tomorrow.
15195+
15196+ [Delay](/docs/qstash/features/delay) a message by a duration or to an absolute
15197+ timestamp, and QStash holds it until then — up to 7 days on the free plan and up
15198+ to a year on pay-as-you-go.
15199+
15200+ ```typescript
15201+ await client.publishJSON({
15202+ url: "https://your-app.com/api/send-welcome-email",
15203+ body: { userId },
15204+ delay: "10m",
15205+ });
15206+ ```
1505715207
15058- ### Send delayed message when a new user signs up
15208+ With the [Resend integration](/docs/qstash/integrations/resend) you can skip the
15209+ endpoint entirely and have QStash send the email itself at the scheduled time.
15210+
15211+ <CardGroup cols={2}>
15212+ <Card
15213+ title="Scheduling emails in the user's timezone"
15214+ icon="book"
15215+ href="https://upstash.com/blog/timezone-scheduling-emails"
15216+ >
15217+ Per-user send times with QStash
15218+ </Card>
15219+ <Card
15220+ title="Building an Email Scheduler"
15221+ icon="book"
15222+ href="https://upstash.com/blog/email-scheduler-qstash-python"
15223+ >
15224+ An email scheduler with the Python SDK
15225+ </Card>
15226+ </CardGroup>
15227+
15228+ ## Ordered processing
15229+
15230+ Some pipelines break if messages overtake each other — applying a sequence of
15231+ updates to the same record, processing a customer's events in order, or writing
15232+ to a system that can't handle concurrent writes.
15233+
15234+ [Queues](/docs/qstash/features/queues) deliver messages one at a time in FIFO order.
15235+ The next message only becomes active after the current one is delivered, has
15236+ exhausted its retries, or its callback has finished.
15237+
15238+ ```typescript
15239+ const queue = client.queue({ queueName: "user-123-events" });
15240+
15241+ await queue.enqueueJSON({
15242+ url: "https://your-app.com/api/apply-event",
15243+ body: { event },
15244+ });
15245+ ```
15246+
15247+ ## Syncing and periodic data updates
15248+
15249+ Instead of querying a slow or rate-limited third-party API on every request,
15250+ schedule a job that pulls fresh data into your own database, and serve reads
15251+ from there. The same pattern covers flushing Redis state to a primary database,
15252+ refreshing a cache, and rebuilding a search index.
15253+
15254+ <CardGroup cols={2}>
15255+ <Card
15256+ title="Periodic Data Updates"
15257+ icon="rotate"
15258+ href="/qstash/recipes/periodic-data-updates"
15259+ >
15260+ Recipe: keep third-party data fresh in your own database
15261+ </Card>
15262+ <Card
15263+ title="Sync Redis state to your database"
15264+ icon="book"
15265+ href="https://upstash.com/blog/syncing-state-with-qstash"
15266+ >
15267+ Write-behind from Redis using QStash
15268+ </Card>
15269+ </CardGroup>
15270+
15271+ ## Decoupling services
15272+
15273+ Beyond individual jobs, QStash works as the messaging layer between your
15274+ services: producers publish, QStash guarantees
15275+ [at-least-once delivery](/docs/qstash/features/at-least-once), and consumers are just
15276+ HTTP endpoints. [Deduplication](/docs/qstash/features/deduplication) keeps retries
15277+ from double-processing, [signature verification](/docs/qstash/features/security)
15278+ proves a request came from QStash, and the DLQ holds anything that never
15279+ succeeded.
15280+
15281+ This is the pattern behind cutting serverless costs, too: move expensive work
15282+ out of long-running function invocations and let QStash drive short, cheap ones.
15283+
15284+ <Card
15285+ title="Get Rid of Function Timeouts and Reduce Vercel Costs"
15286+ icon="book"
15287+ href="https://upstash.com/blog/vercel-cost-workflow"
15288+ >
15289+ Why offloading work changes your bill
15290+ </Card>
15291+
15292+ ## Multi-step workflows
15293+
15294+ If your task has several dependent steps — call an API, wait for a human,
15295+ branch, then call another — chaining QStash messages by hand gets awkward.
15296+ [Upstash Workflow](/docs/workflow/getstarted) is built on QStash and gives you
15297+ durable, resumable functions where each step is checkpointed automatically.
15298+
15299+ <Tip href="/workflow/getstarted">
15300+ Use QStash directly for single messages, schedules, and fan-out. Reach for
15301+ [Upstash Workflow](/docs/workflow/getstarted) when the logic spans multiple dependent
15302+ steps.
15303+ </Tip>
15304+
15305+ ## More examples
15306+
15307+ <CardGroup cols={2}>
15308+ <Card
15309+ title="Building a seriously reliable serverless API"
15310+ icon="book"
15311+ href="https://upstash.com/blog/build-reliable-serverless-api"
15312+ >
15313+ Retries, idempotency, and failure handling end to end
15314+ </Card>
15315+ <Card
15316+ title="Decouple Webhook Processing on Next.js"
15317+ icon="book"
15318+ href="https://upstash.com/blog/webhook-qstash"
15319+ >
15320+ Taking webhook work off the request path
15321+ </Card>
15322+ <Card
15323+ title="Build a Subscription Service with Next.js & Prisma"
15324+ icon="book"
15325+ href="https://upstash.com/blog/saas-subscription"
15326+ >
15327+ Recurring billing cycles driven by schedules
15328+ </Card>
15329+ <Card
15330+ title="Refresh stale data in a SvelteKit app"
15331+ icon="book"
15332+ href="https://upstash.com/blog/sveltekit-qstash"
15333+ >
15334+ Scheduled revalidation outside the request path
15335+ </Card>
15336+ <Card
15337+ title="Serverless Background Jobs and Message Queues Compared"
15338+ icon="scale-balanced"
15339+ href="https://upstash.com/blog/serverless-background-jobs-and-message-queues-every-major-option-in-2026"
15340+ >
15341+ How QStash compares to the alternatives
15342+ </Card>
15343+ <Card
15344+ title="Why We Chose QStash at Scale"
15345+ icon="book"
15346+ href="https://upstash.com/blog/qstash-workflow-at-scale"
15347+ >
15348+ A production user's account of running QStash
15349+ </Card>
15350+ </CardGroup>
1505915351
15060- Publish delayed messages whenever a new user signs up in your app. After a
15061- certain delay (e.g. 10 minutes), QStash will send a request to your API,
15062- allowing you to email the user a welcome message .
15352+ More posts are on the [QStash blog](https://upstash.com/blog/tag/qstash). If
15353+ there's a use case you'd like documented, tell us on
15354+ [Discord](https://upstash.com/discord) or [X](https://x.com/upstash) .
1506315355
1506415356- [AWS Lambda (Node)](https://upstash.com/docs/qstash/quickstarts/aws-lambda/nodejs.md)
1506515357- [AWS Lambda (Python)](https://upstash.com/docs/qstash/quickstarts/aws-lambda/python.md)
0 commit comments