Documentation

Callback / webhook

We recommend using callbacks instead of polling. Set your backend address as the Callback URL under Developers → Webhooks in the dashboard. When a user approves or rejects, Touchque sends a POST to this URL.

Recommended: Callbacks are more efficient and faster than polling.
Callback payload (Touchque → you)
FieldTypeDescription
requestIdUUIDLogin request ID
statusstring"SUCCESS" (approved; the status check says CONFIRMED) / "REJECTED"
externalUsernamestringUser ID
timestampISO 8601Event timestamp
signaturehexHMAC-SHA256 signature
Always verify the x-signature header in callbacks! It is signed with your API secret; the Signing secret under Developers → Webhooks is the same value.
Callback handler
const express = require('express');
const { Touchque } = require('@touchque/node');

const app = express();
const tq = new Touchque({
  apiKey: 'tq_abc123',
  apiSecret: 'YOUR_API_SECRET'
});

// Webhook Callback - Notification from Touchque
app.post('/touchque/callback', express.text({ type: 'application/json' }), (req, res) => {
  try {
    const headerSig = req.headers['x-signature'];

    // Verify signature and parse body
    const payload = tq.webhook.verify({
      rawBody: req.body,
      signature: headerSig
    });

    if (payload.status === 'SUCCESS') {
      // ✅ User approved
      console.log(`User ${payload.externalUsername} approved!`);
    }

    res.json({ received: true });
  } catch (err) {
    res.status(401).json({ error: 'Invalid signature' });
  }
});

app.listen(3000);