DEV Community

Alex Spinov
Alex Spinov

Posted on

Upstash QStash Has a Free API — Serverless Message Queue for Edge Functions

What if you could send messages between serverless functions without managing RabbitMQ, SQS, or any infrastructure?

Upstash QStash is an HTTP-based message queue designed for serverless and edge environments.

Why QStash Exists

Serverless functions have a problem: they cannot run background jobs. No persistent connections, no long-running workers, no cron without hacks.

QStash solves this with a simple HTTP API:

  • Publish a message → QStash delivers it to your endpoint
  • Schedule messages → built-in cron with Upstash-Cron header
  • Retry on failure — automatic retries with exponential backoff
  • No connections — pure HTTP, works everywhere (Vercel, Cloudflare, Deno Deploy)

Quick Start

# Publish a message to your endpoint
curl -X POST "https://qstash.upstash.io/v2/publish/https://your-app.vercel.app/api/process" \
  -H "Authorization: Bearer QSTASH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"orderId": "12345", "action": "send-email"}'
Enter fullscreen mode Exit fullscreen mode

Schedule a recurring task:

# Run every hour
curl -X POST "https://qstash.upstash.io/v2/publish/https://your-app.com/api/cleanup" \
  -H "Authorization: Bearer QSTASH_TOKEN" \
  -H "Upstash-Cron: 0 * * * *"
Enter fullscreen mode Exit fullscreen mode

In Your Code

import { Client } from "@upstash/qstash";

const qstash = new Client({ token: process.env.QSTASH_TOKEN });

// Send a background job
await qstash.publishJSON({
  url: "https://your-app.com/api/process-order",
  body: { orderId: "12345" },
  retries: 3,
});

// Schedule a cron job
await qstash.publishJSON({
  url: "https://your-app.com/api/daily-report",
  cron: "0 9 * * *", // Every day at 9am
});
Enter fullscreen mode Exit fullscreen mode

Free Tier

  • 500 messages/day
  • Unlimited endpoints
  • Built-in scheduling (cron)
  • Automatic retries
  • DLQ (Dead Letter Queue) for failed messages

Real Use Case

A SaaS startup needed to send welcome emails after signup without slowing down the registration flow. They added one QStash call — user signs up, QStash delivers the email job to their /api/send-welcome endpoint 2 seconds later. Response time dropped from 3s to 200ms.

When to Use QStash

✅ Background jobs in serverless (email, PDF generation, webhooks)
✅ Scheduled tasks without cron servers
✅ Event-driven architectures on edge
✅ Retry-safe webhook delivery

❌ High-throughput streaming (use Kafka/Redpanda)
❌ Real-time pub/sub (use WebSockets)

Get Started

Sign up at upstash.com — free forever tier, no credit card.


Need custom data pipelines or scraping solutions? Check out my Apify actors or email me at spinov001@gmail.com for custom solutions.

Top comments (0)