Long-running tools finish asynchronously. Instead of polling, register a webhook and GREM will POST an event to your URL when a job completes.
Register an endpoint
In the cabinet, AI tools → API → Webhooks: add a public https:// URL and pick the events you want. A signing secret (whsec_…) is shown once — store it to verify deliveries.
Events follow a <tool>.<result> shape, for example:
valuation.completed,valuation.failedcontent.completed,content.partial,content.failedphoto.completed,avatar.completed,pdf.completed(and their.failedvariants)
Payload
Each delivery is a POST with a JSON body:
{
"id": "…",
"type": "content.completed",
"createdAt": "2026-07-21T10:00:00.000Z",
"data": { }
}
And these headers:
x-grem-event: content.completed
x-grem-signature: t=1721556000,v1=3b78a03b78058d229023db2a0b4ee072…
Verify the signature
Always verify the signature before trusting a delivery. The signature is an HMAC-SHA256 over the string "<t>.<raw-body>", keyed with your webhook secret. t is a Unix timestamp; reject old timestamps to prevent replay.
Verify against the raw request body exactly as received — before any JSON parsing. Re-serializing the JSON changes the bytes and the signature will not match.
Node.js (Express)
const crypto = require('crypto');
function verifyGremSignature(secret, header, rawBody, toleranceSec = 300) {
// header: "t=<unix>,v1=<hex>"
const parts = Object.fromEntries(header.split(',').map((kv) => kv.split('=')));
const t = Number(parts.t);
if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSec) return false; // stale
const expected = crypto.createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
const a = Buffer.from(expected);
const b = Buffer.from(parts.v1 || '');
return a.length === b.length && crypto.timingSafeEqual(a, b);
}
// Capture the RAW body for this route.
app.post('/grem-hook', express.raw({ type: 'application/json' }), (req, res) => {
const raw = req.body.toString('utf8');
if (!verifyGremSignature(process.env.GREM_WEBHOOK_SECRET, req.get('x-grem-signature'), raw)) {
return res.status(400).send('invalid signature');
}
const event = JSON.parse(raw);
// handle event.type / event.data …
res.sendStatus(200);
});
Python (Flask)
import hmac, hashlib, time
from flask import Flask, request
def verify_grem_signature(secret, header, raw_body, tolerance=300):
parts = dict(kv.split('=', 1) for kv in header.split(','))
t = int(parts.get('t', 0))
if not t or abs(time.time() - t) > tolerance:
return False # stale
expected = hmac.new(secret.encode(), f"{t}.{raw_body}".encode(), hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts.get('v1', ''))
app = Flask(__name__)
@app.post('/grem-hook')
def grem_hook():
raw = request.get_data(as_text=True) # RAW body, before parsing
if not verify_grem_signature(GREM_WEBHOOK_SECRET, request.headers.get('x-grem-signature', ''), raw):
return 'invalid signature', 400
event = request.get_json()
# handle event['type'] / event['data'] …
return '', 200
Delivery, retries and security
- Respond with a
2xxstatus quickly. Do the heavy work asynchronously. - Failed deliveries are retried with exponential backoff; after repeated failures the endpoint is disabled and you're notified.
- Endpoints must be public
https://URLs. Private, loopback and internal addresses are rejected (anti-SSRF). - Rotate the signing secret any time from the Webhooks tab; use Send test to fire a sample delivery, and check the deliveries log.