Delayed Triggers
Schedule a task to run after a specified delay instead of immediately.
Quick Example
import { PingbackClient } from "@usepingback/next";
const pingback = new PingbackClient({ apiKey: process.env.PINGBACK_API_KEY });
// Send a follow-up email 2 hours after sign-up
await pingback.trigger("send-followup", { userId: "usr_123" }, { delay: "2h" });
// Schedule a reminder 1 day and 30 minutes from now
await pingback.trigger("send-reminder", { userId: "usr_123" }, { delay: "1d30m" });How It Works
When a delay is provided in a trigger request:
- The delay is parsed into seconds (see formats below).
scheduledAtis set tonow + delayinstead ofnow.- The job is queued with a
startAfterdelay in PgBoss. - The execution appears as "pending" in the dashboard until the delay expires.
- After the delay, the task is dispatched normally.
Delay Formats
| Format | Example | Seconds |
|---|---|---|
| Integer | 900 | 900 |
| Seconds | "30s" | 30 |
| Minutes | "15m" | 900 |
| Hours | "2h" | 7200 |
| Days | "1d" | 86400 |
| Combined | "1d2h30m" | 95400 |
Constraints
- Maximum delay: 30 days (2,592,000 seconds). Requests exceeding this return
400 Bad Request. - Minimum delay: 1 second. Zero or negative values return
400 Bad Request. - Precision: Fractional seconds are floored to the nearest integer.
SDK Reference
| SDK | Syntax |
|---|---|
| Next.js | pingback.trigger("task", payload, { delay: "15m" }) |
| NestJS | this.pingback.trigger("task", payload, { delay: "15m" }) |
| Go | pb.Trigger(ctx, "task", payload, pingback.WithDelay("15m")) |
| Python | pb.trigger("task", payload, delay="15m") |