Skip to content

    Webhooks
    enterprise+ plan

    Have Giveawayz tell your own systems when something happens: an order is paid, an order is refunded, a draw runs, or a competition changes status. Each event is an HTTPS POST to a URL you choose, signed so you can check it came from us.

    Setting up a webhook

    Open the webhook settings

    In your dashboard, go to Settings, open the Security tab and find Webhooks. The owner and any team member can manage them.

    Add an endpoint

    Enter the Endpoint URL, a public address starting with https://. Tick the Events it should get, then click Add Endpoint.

    Copy the signing secret

    Each endpoint gets its own signing secret, starting whsec_. It's shown once, when you add the endpoint: copy it then and store it securely. You need it to check signatures.

    Send a test event

    Click the send icon next to the endpoint to send a signed test event, and check your server receives and verifies it.

    Events

    EventSent when
    order.createdAn order has been paid and its tickets issued
    order.refundedAn order's refund has completed, or you've marked a cancelled order as refunded
    draw.completedA competition's draw has run
    competition.status_changedA competition goes from upcoming to live, or closes without a winner because nobody eligible entered

    What each request looks like

    Every event is a POST with a JSON body and these headers:

    HeaderValue
    Content-Typeapplication/json
    X-Giveawayz-EventThe event name, for example draw.completed
    X-Giveawayz-Signaturet=<timestamp>,v1=<signature> (see below)

    The body is the event's data itself, with no wrapper: the event name is in the X-Giveawayz-Event header. Ids are Giveawayz ids, and times are ISO 8601.

    order.created

    {
      "orderId": "j97c4f1a8e2d6b3k5m0n7p9q2r4s6t8v",
      "orderNumber": "ACME-1042",
      "customerEmail": "jane@example.com",
      "total": 8.97,
      "items": [
        { "competitionId": "k57a2d9h3x8w1q0f6m4r2t7b5n9c3e1j", "quantity": 3, "pricePerTicket": 2.99 }
      ],
      "createdAt": "2026-11-18T14:30:00.000Z"
    }
    

    order.refunded

    {
      "orderId": "j97c4f1a8e2d6b3k5m0n7p9q2r4s6t8v",
      "orderNumber": "ACME-1042",
      "customerEmail": "jane@example.com",
      "total": 8.97,
      "reason": "Cancelled by the entrant",
      "refundedAt": "2026-11-19T09:12:00.000Z"
    }
    

    draw.completed

    {
      "competitionId": "k57a2d9h3x8w1q0f6m4r2t7b5n9c3e1j",
      "competitionTitle": "Win a PS5 Pro Bundle",
      "drawMethod": "auto",
      "winner": { "name": "Jane Smith", "ticketNumber": "00247" },
      "winners": [
        { "place": 0, "prize": "PS5 Pro Bundle", "name": "Jane Smith", "ticketNumber": "00247" },
        { "place": 1, "prize": "£50 cash", "name": "Sam Jones", "ticketNumber": "00012" }
      ],
      "entrantCount": 198,
      "ticketPool": 316,
      "drawnAt": "2026-11-30T20:00:05.000Z"
    }
    

    winners lists every winner in the order they were drawn: place 0 is the main prize's first winner, and winner repeats them for older integrations. A competition with one prize has one entry. drawMethod is auto (drawn at the close) or manual (you ran it). Some older competitions can also send flash or sellout. ticketPool is the number of eligible entries, paid and free; entrantCount is the number of different people behind them. Every draw can be checked on the competition's public verify page.

    competition.status_changed

    {
      "competitionId": "k57a2d9h3x8w1q0f6m4r2t7b5n9c3e1j",
      "competitionTitle": "Win a PS5 Pro Bundle",
      "previousStatus": "upcoming",
      "newStatus": "active",
      "changedAt": "2026-11-18T09:00:00.000Z"
    }
    

    Checking the signature

    Always check the signature before trusting a request. The X-Giveawayz-Signature header holds a timestamp t (milliseconds since 1970) and a signature v1: the HMAC-SHA256, in hex, of the timestamp, a full stop and the raw request body, keyed with your endpoint's signing secret.

    const crypto = require('crypto');
    
    function verifyGiveawayzWebhook(rawBody, header, secret) {
      const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
      const expected = crypto
        .createHmac('sha256', secret)
        .update(`${parts.t}.${rawBody}`)
        .digest('hex');
      const given = Buffer.from(parts.v1 ?? '', 'hex');
      const wanted = Buffer.from(expected, 'hex');
      const fresh = Math.abs(Date.now() - Number(parts.t)) < 5 * 60 * 1000; // refuse replays older than 5 minutes
      return fresh && given.length === wanted.length && crypto.timingSafeEqual(given, wanted);
    }
    
    // Express: keep the raw body for the check.
    app.post('/webhooks/giveawayz', express.raw({ type: 'application/json' }), (req, res) => {
      const ok = verifyGiveawayzWebhook(req.body.toString('utf8'), req.get('x-giveawayz-signature') ?? '', process.env.GIVEAWAYZ_WEBHOOK_SECRET);
      if (!ok) return res.status(401).send('Invalid signature');
      const event = req.get('x-giveawayz-event');
      const data = JSON.parse(req.body.toString('utf8'));
      // handle `event` with `data`
      res.status(200).send('OK');
    });
    

    Delivery and failures

    • Your endpoint has 10 seconds to answer with a 2xx status.
    • Each event is sent once. A failed delivery isn't retried, so if you can't afford to miss one, check the REST API from time to time as well.
    • Every delivery is recorded with its status code, and the record is kept for 30 days. After 10 failures in a row, the endpoint is switched off; fix the problem, then switch it back on with its switch in Settings. You can also pause an endpoint with its switch, or delete it with the bin icon.
    • We never follow redirects, and we only send to public addresses.

    The test event is the one exception to the format above: its body is { "event": "test", "data": { "message": "…", "timestamp": "…" } }, signed the same way.

    Testing locally

    Your endpoint needs a public HTTPS address. While you build, a tunnelling tool such as ngrok can give your local server one: point the webhook at the tunnel's address, then send a test event.

    We use strictly necessary cookies to make this site work. With your permission we'd also use analytics and marketing cookies to improve it. You can accept, reject, or choose. See our Cookie Policy.