Docs

Deploy an AI Act Radar webhook receiver on Vercel, Cloudflare Workers, or AWS Lambda

Information only. Receiver code below is illustrative. Verify signatures, secrets handling, and production hardening for your own deployment.

An AI Act Radar webhook receiver is a small HTTP endpoint that verifies the signature, parses the payload, and forwards the event into your stack. The same logic runs on any modern serverless platform with under 50 lines of code. This page shows the three most common targets (Vercel, Cloudflare Workers, AWS Lambda) with the exact handler code, the deployment command, and the operational notes for each.

What every receiver must do

Vercel: Edge Function

// app/api/aia/route.ts
import { NextRequest } from 'next/server';

export const runtime = 'edge';

export async function POST(req: NextRequest) {
  const raw = await req.text();
  const sig = req.headers.get('x-aiar-signature') ?? '';
  const ts  = req.headers.get('x-aiar-timestamp') ?? '';

  if (!await verify(raw, ts, sig, process.env.AIA_SECRET!)) {
    return new Response('invalid signature', { status: 401 });
  }

  const event = JSON.parse(raw);
  await fetch(process.env.SLACK_WEBHOOK!, {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    body: JSON.stringify({
      text: `[${event.severity}] ${event.title_en}: ${event.url_official}`
    })
  });

  return new Response('ok', { status: 200 });
}

async function verify(body: string, ts: string, sig: string, secret: string) {
  const drift = Math.abs(Date.now() / 1000 - Number(ts));
  if (drift > 300) return false;
  const enc = new TextEncoder();
  const key = await crypto.subtle.importKey(
    'raw', enc.encode(secret),
    { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']
  );
  const mac = await crypto.subtle.sign('HMAC', key, enc.encode(`${ts}.${body}`));
  const hex = Array.from(new Uint8Array(mac))
    .map(b => b.toString(16).padStart(2, '0')).join('');
  return timingSafeEqual('v1=' + hex, sig);
}

function timingSafeEqual(a: string, b: string) {
  if (a.length !== b.length) return false;
  let r = 0;
  for (let i = 0; i < a.length; i++) r |= a.charCodeAt(i) ^ b.charCodeAt(i);
  return r === 0;
}

Deploy with vercel deploy --prod. Set AIA_SECRET and SLACK_WEBHOOK in the project settings. The endpoint is reachable at https://your-app.vercel.app/api/aia: register that URL as the webhook target.

Cloudflare Workers

// src/index.ts
export interface Env {
  AIA_SECRET: string;
  EVENTS: KVNamespace;
}

export default {
  async fetch(req: Request, env: Env): Promise<Response> {
    if (req.method !== 'POST') return new Response('method not allowed', { status: 405 });

    const raw = await req.text();
    const sig = req.headers.get('x-aiar-signature') ?? '';
    const ts  = req.headers.get('x-aiar-timestamp') ?? '';
    if (!(await verify(raw, ts, sig, env.AIA_SECRET))) {
      return new Response('invalid signature', { status: 401 });
    }

    const event = JSON.parse(raw);
    const seen = await env.EVENTS.get(event.id);
    if (seen) return new Response('duplicate', { status: 200 });
    await env.EVENTS.put(event.id, '1', { expirationTtl: 86400 });

    // forward to your downstream system here

    return new Response('ok', { status: 200 });
  }
};

async function verify(body: string, ts: string, sig: string, secret: string) {
  const drift = Math.abs(Date.now() / 1000 - Number(ts));
  if (drift > 300) return false;
  const enc = new TextEncoder();
  const key = await crypto.subtle.importKey(
    'raw', enc.encode(secret),
    { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']
  );
  const mac = await crypto.subtle.sign('HMAC', key, enc.encode(`${ts}.${body}`));
  const hex = Array.from(new Uint8Array(mac))
    .map(b => b.toString(16).padStart(2, '0')).join('');
  const expected = 'v1=' + hex;
  if (expected.length !== sig.length) return false;
  let r = 0;
  for (let i = 0; i < expected.length; i++) r |= expected.charCodeAt(i) ^ sig.charCodeAt(i);
  return r === 0;
}

Deploy with wrangler deploy. Bind a KV namespace named EVENTS for idempotency tracking. Workers limit CPU time per request, more tightly on the free plan: keep downstream calls async with ctx.waitUntil for heavy fan-out.

AWS Lambda: function URL

// handler.mjs
import crypto from 'node:crypto';

export const handler = async (event) => {
  const raw = event.body || '';
  const sig = event.headers['x-aiar-signature'] || '';
  const ts  = event.headers['x-aiar-timestamp'] || '';

  const drift = Math.abs(Date.now() / 1000 - Number(ts));
  if (drift > 300) return { statusCode: 401, body: 'expired' };

  const expected = 'v1=' + crypto
    .createHmac('sha256', process.env.AIA_SECRET)
    .update(`${ts}.${raw}`)
    .digest('hex');

  const ok = crypto.timingSafeEqual(
    Buffer.from(expected),
    Buffer.from(sig.padEnd(expected.length, '0').slice(0, expected.length))
  );
  if (!ok) return { statusCode: 401, body: 'invalid signature' };

  const payload = JSON.parse(raw);
  // forward to SNS, EventBridge, SQS, ...

  return { statusCode: 200, body: 'ok' };
};

Deploy with SAM, CDK, or the console. Enable the function URL with AuthType: NONE: auth is the HMAC signature, not IAM. Configure a 10-second timeout and set AIA_SECRET as an environment variable, ideally sourced from Secrets Manager.

Operational notes per platform

PlatformCold startIdempotency storeTimeout default
Vercel EdgeSub-50msVercel KV or Upstash Redis30s
Cloudflare WorkersSub-10msWorkers KV (built-in)30s
AWS Lambda100-400ms (Node 20)DynamoDB single-table3s default, raise to 10s

Hardening checklist

→ See live updates: https://aiactradar.com

→ Subscribe to webhook: https://docs.aiactradar.com/quickstart