Skip to content
pushqdocs
Get started

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.

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:

Terminal window
export PUSHQ_API_KEY="pq_..."

Every request sends it as a bearer token (Authorization: Bearer pq_...). API keys explains roles, rotation and revocation.

Pick your language. Every SDK talks to the hosted API by default, and the docs remember the language you pick.

npm install pushq

Install & configure an SDK covers client options, errors and versions for each language.

import { Pushq } from "pushq";
const pq = new Pushq({ apiKey: process.env.PUSHQ_API_KEY });

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 },
});

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
});

A second create with the same task_id fails with 409 already_exists, which makes enqueueing safe to retry. See deduplicate tasks.

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);
});

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.

Terminal window
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.