Skip to content

Documentation · Webhooks

Webhooks

Let Pluko tell your server when a search is done, instead of checking back.

Webhooks

Skip polling: add a webhook to a project (Projects → Webhook) and Pluko sends a signed POST to your https endpoint when a job becomes complete, partial or cancelled. Fetch the results with the usual results endpoint using the event’s job_id.

Event body
{
  "id": "evt_example",
  "type": "job.finished",
  "created": 1760000000000,
  "data": {
    "job_id": "job_example",
    "project_id": "prj_example",
    "status": "complete",
    "requested": "20",
    "returned": 20,
    "queries": [
      {
        "query": "city skyline",
        "requested": "20",
        "found": 20,
        "status": "complete",
        "reason": "requested_count_reached"
      }
    ],
    "results_url": "/v1/jobs/job_example/results"
  }
}

Each request carries Pluko-Event, Pluko-Delivery (unique per event; use it to ignore duplicates) and Pluko-Signature as t=<ms>,v1=<hex>. v1 is the HMAC-SHA256 of "<t>.<raw body>" using your signing secret, which is shown once when you save the webhook. Verify it, and reject timestamps older than five minutes.

verify.js
import {createHmac,timingSafeEqual} from 'node:crypto';

// rawBody must be the exact request body string, before any JSON parsing.
export function verify(secret,header,rawBody){
  const parts=Object.fromEntries(header.split(',').map(part=>part.split('=')));
  if(Math.abs(Date.now()-Number(parts.t))>300000)return false; // reject replays
  const expected=createHmac('sha256',secret).update(`${parts.t}.${rawBody}`).digest('hex');
  const given=Buffer.from(parts.v1||''),wanted=Buffer.from(expected);
  return given.length===wanted.length&&timingSafeEqual(given,wanted);
}
RuleDetail
Answer quicklyAny 2xx status within 8 seconds.
RetriesUp to 5, after about 30 seconds, 2 minutes, 10 minutes, 1 hour and 6 hours. Retry a failed one from the dashboard.
Endpointhttps on port 443 with a public domain name. Private and internal addresses are refused.
OrderingAt least once, not strictly ordered. Treat the job status as the source of truth.

Was this page helpful?

Tell us what’s missing. We read every note.