Quickstart: send your first HTTP task
This quickstart takes you from zero to a delivered task with the hosted pushq API at https://api.pushqueue.dev: you create an API key, create a queue, enqueue an HTTP task and receive it on your own endpoint. Every step works the same against a server you run yourself; to try pushq on your machine without an account, see local development with pushq dev.
Create an API key
Section titled “Create an API key”Sign in to the pushq console and create a key under Settings → API keys. The key is shown once, so store it as an environment variable:
export PUSHQ_API_KEY="pq_..."Every request sends it as a bearer token (Authorization: Bearer pq_...). API keys explains roles, rotation and revocation.
Install an SDK
Section titled “Install an SDK”Pick your language. Every SDK talks to the hosted API by default, and the docs remember the language you pick.
npm install pushqpip install pushqgo get github.com/blissfulrays/pushq/sdks/go<!-- Not on Maven Central yet: build it with `mvn install` in sdks/java first. --><dependency> <groupId>io.github.blissfulrays</groupId> <artifactId>pushq</artifactId> <version>1.0.0-SNAPSHOT</version></dependency>dotnet add package Pushq# No install needed: call the REST API directly.curl https://api.pushqueue.dev/v1/version -H "Authorization: Bearer $PUSHQ_API_KEY"Install & configure an SDK covers client options, errors and versions for each language.
Create a client
Section titled “Create a client”import { Pushq } from "pushq";
const pq = new Pushq({ apiKey: process.env.PUSHQ_API_KEY });import osfrom pushq import Pushq
pq = Pushq(api_key=os.environ["PUSHQ_API_KEY"])import ( "context" "os"
pushq "github.com/blissfulrays/pushq/sdks/go")
pq := pushq.New("", os.Getenv("PUSHQ_API_KEY")) // "" = https://api.pushqueue.devctx := context.Background()import io.pushq.*;
Pushq pq = Pushq.builder() .apiKey(System.getenv("PUSHQ_API_KEY")) .build();using Pushq;
using var pq = new PushqClient(apiKey: Environment.GetEnvironmentVariable("PUSHQ_API_KEY"));export PUSHQ_URL="https://api.pushqueue.dev"Create a queue
Section titled “Create a queue”A queue holds tasks and says where to deliver them and how fast. This one delivers to https://api.example.com at up to 10 requests per second, 5 at a time, and signs every delivery.
await pq.upsertQueue("emails", { rateLimits: { maxDispatchesPerSecond: 10, maxConcurrentDispatches: 5 }, target: { baseUrl: "https://api.example.com", signingSecret: process.env.PUSHQ_SIGNING_SECRET },});from pushq import RateLimits, Target
pq.upsert_queue( "emails", rate_limits=RateLimits(max_dispatches_per_second=10, max_concurrent_dispatches=5), target=Target(base_url="https://api.example.com", signing_secret=os.environ["PUSHQ_SIGNING_SECRET"]),)_, err := pq.UpsertQueue(ctx, "emails", pushq.QueueConfig{ RateLimits: &pushq.RateLimits{ MaxDispatchesPerSecond: pushq.Float64(10), MaxConcurrentDispatches: pushq.Int(5), }, Target: &pushq.Target{ BaseURL: "https://api.example.com", SigningSecret: os.Getenv("PUSHQ_SIGNING_SECRET"), },})pq.upsertQueue("emails", QueueConfig.builder() .rateLimits(RateLimits.builder() .maxDispatchesPerSecond(10) .maxConcurrentDispatches(5) .build()) .target(Target.builder() .baseUrl("https://api.example.com") .signingSecret(System.getenv("PUSHQ_SIGNING_SECRET")) .build()) .build());await pq.UpsertQueueAsync("emails", new QueueConfig{ RateLimits = new RateLimits { MaxDispatchesPerSecond = 10, MaxConcurrentDispatches = 5 }, Target = new Target { BaseUrl = "https://api.example.com", SigningSecret = Environment.GetEnvironmentVariable("PUSHQ_SIGNING_SECRET"), },});curl -X PUT "$PUSHQ_URL/v1/queues/emails" \ -H "Authorization: Bearer $PUSHQ_API_KEY" \ -d '{ "rate_limits": {"max_dispatches_per_second": 10, "max_concurrent_dispatches": 5}, "target": {"base_url": "https://api.example.com", "signing_secret": "whsec_..."} }'Enqueue a task
Section titled “Enqueue a task”A task is one HTTP request pushq makes for you. path is resolved against the queue’s base URL, so this task becomes POST https://api.example.com/hooks/send-welcome, delivered in an hour.
await pq.createTask("emails", { taskId: "welcome-user-42", // optional: a second create with this ID is rejected path: "/hooks/send-welcome", jsonBody: { user_id: 42 }, delaySeconds: 3600, // omit to deliver now});pq.create_task( "emails", task_id="welcome-user-42", path="/hooks/send-welcome", json_body={"user_id": 42}, delay_seconds=3600,)_, err = pq.CreateTask(ctx, "emails", pushq.TaskCreate{ TaskID: "welcome-user-42", Path: "/hooks/send-welcome", JSONBody: map[string]any{"user_id": 42}, DelaySeconds: pushq.Float64(3600),})pq.createTask("emails", TaskCreate.builder() .taskId("welcome-user-42") .path("/hooks/send-welcome") .jsonBody(Map.of("user_id", 42)) .delaySeconds(3600) .build());await pq.CreateTaskAsync("emails", new TaskCreate{ TaskId = "welcome-user-42", Path = "/hooks/send-welcome", JsonBody = new Dictionary<string, object> { ["user_id"] = 42 }, Delay = TimeSpan.FromHours(1),});curl -X POST "$PUSHQ_URL/v1/queues/emails/tasks" \ -H "Authorization: Bearer $PUSHQ_API_KEY" \ -d '{"task_id": "welcome-user-42", "path": "/hooks/send-welcome", "json_body": {"user_id": 42}, "delay_seconds": 3600}'A second create with the same task_id fails with 409 already_exists, which makes enqueueing safe to retry. See deduplicate tasks.
Receive the task and verify its signature
Section titled “Receive the task and verify its signature”pushq calls your endpoint with the task’s body and X-Pushq-* headers. Return any 2xx to mark the task done; any other status, or a timeout, is retried with backoff. Because the queue has a signing secret, verify each delivery against the raw request body before trusting it:
import express from "express";import { verifySignature, WebhookVerificationError } from "pushq";
const app = express();
// express.raw keeps the exact bytes; don't run express.json() on this route.app.post("/hooks/send-welcome", express.raw({ type: "*/*" }), async (req, res) => { let webhookId: string; try { webhookId = await verifySignature({ secret: process.env.PUSHQ_SIGNING_SECRET!, headers: req.headers, payload: req.body, }); } catch (err) { if (err instanceof WebhookVerificationError) return res.status(401).end(); throw err; } const { user_id } = JSON.parse(req.body.toString("utf8")); await sendWelcomeEmail(user_id, webhookId); // webhookId is stable across retries res.sendStatus(204);});import osfrom fastapi import FastAPI, HTTPException, Requestfrom pushq import WebhookVerificationError, verify_signature
app = FastAPI()
@app.post("/hooks/send-welcome")async def send_welcome(request: Request): body = await request.body() # raw bytes, not parsed JSON try: webhook_id = verify_signature(os.environ["PUSHQ_SIGNING_SECRET"], request.headers, body) except WebhookVerificationError: raise HTTPException(status_code=401) # webhook_id ("emails/welcome-user-42") is stable across retries return {"ok": True}func handleSendWelcome(w http.ResponseWriter, r *http.Request) { body, err := io.ReadAll(r.Body) // raw bytes, before any JSON decoding if err != nil { http.Error(w, "read error", http.StatusBadRequest) return } id, err := pushq.VerifySignature(os.Getenv("PUSHQ_SIGNING_SECRET"), r.Header, body, 5*time.Minute) if err != nil { http.Error(w, "invalid signature", http.StatusUnauthorized) return } _ = id // "emails/welcome-user-42", stable across retries w.WriteHeader(http.StatusNoContent)}@PostMapping("/hooks/send-welcome")public ResponseEntity<Void> sendWelcome(@RequestBody byte[] payload, // raw body, unparsed @RequestHeader("webhook-id") String id, @RequestHeader("webhook-timestamp") long ts, @RequestHeader("webhook-signature") String sig) { try { Webhooks.verifySignature(System.getenv("PUSHQ_SIGNING_SECRET"), id, ts, payload, sig, 300); } catch (WebhookVerificationException e) { return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } // trusted: parse the payload and do the work return ResponseEntity.ok().build();}app.MapPost("/hooks/send-welcome", async (HttpRequest req) =>{ using var ms = new MemoryStream(); await req.Body.CopyToAsync(ms); var body = ms.ToArray(); try { // "emails/welcome-user-42": stable across retries string webhookId = Webhooks.VerifySignature( Environment.GetEnvironmentVariable("PUSHQ_SIGNING_SECRET")!, name => req.Headers[name].FirstOrDefault(), body); return Results.Ok(); } catch (WebhookVerificationException) { return Results.Unauthorized(); }});Delivery is at-least-once, so make the handler safe to run twice: the verified ID (queue/task_id) stays the same across retries and works as an idempotency key. See delivery and signing and idempotent handlers.
Check the task’s status and attempts
Section titled “Check the task’s status and attempts”curl "$PUSHQ_URL/v1/queues/emails/stats" -H "Authorization: Bearer $PUSHQ_API_KEY"curl "$PUSHQ_URL/v1/queues/emails/tasks/welcome-user-42/attempts" -H "Authorization: Bearer $PUSHQ_API_KEY"Or open the console to see every queue with live stats and each task’s attempt history.
Read more
Section titled “Read more”- Queues: rate limits, concurrency, folders, pause and purge.
- Tasks: scheduling, deduplication and batch enqueue.
- Retries and backoff: what happens when a delivery fails.
- Rate limits: protect a downstream API.
- Going to production: the checklist before you ship.