Groq Webhooks & Events

VerifiedSafe

Securely handle Groq webhooks with signature validation and replay protection. Ideal for setting up webhook endpoints and event handling.

Sby Skills Guide Bot
DevelopmentIntermediate
7/26/2026
Claude CodeCursorWindsurfCopilotCodex
#webhooks#signature-verification#event-handling#idempotency#groq

Recommended for

Automated summary

This skill walks through building a Groq webhook endpoint with HMAC signature verification, replay protection, typed event dispatch, and Redis-backed idempotency.

Strengths

  • Provides a complete Express example that uses express.raw so the raw body needed for signature checks is preserved.
  • Applies a timing-safe comparison (crypto.timingSafeEqual) and rejects timestamps older than five minutes.
  • Offers an event-type dispatch pattern that rethrows handler errors so retries are triggered.
  • Includes concrete testing commands via the Groq CLI or webhook.site.

Limitations

  • Header names (x-groq-signature, x-groq-timestamp), the signing scheme, and the event types are generic placeholders that must be checked against Groq's official docs.
  • isEventProcessed is defined but never called in the sample handler, so idempotency is not actually wired up.
  • The code assumes Node/Express and Redis (ioredis) even though idempotency is described as optional.
When to use it

Use it when you need to expose a secure endpoint that receives and processes Groq event notifications.

When not to use it

Avoid it if you only need to call the Groq API outbound or integrate the completion SDK without receiving webhooks.

Security analysis

Safe
Quality score85/100

The skill provides educational code and instructions for setting up secure webhook endpoints with signature validation, replay protection, and idempotency. It uses curl for legitimate testing and does not instruct destructive, exfiltrating, or obfuscated actions.

No concerns found

How this analysis is made

Examples

Express webhook endpoint
Add a /webhooks/groq Express endpoint that verifies the Groq signature with HMAC-SHA256 using express.raw, rejects timestamps older than 5 minutes, and dispatches each event to a typed handler.
Replay protection
Show me how to protect my Groq webhook handler against replay attacks using the x-groq-timestamp header and a timing-safe signature comparison.
Idempotent event handling
Make my Groq webhook handler idempotent with Redis so duplicate resource.created events are processed only once, using a 7-day TTL.

name: groq-webhooks-events description: | Implement Groq webhook signature validation and event handling. Use when setting up webhook endpoints, implementing signature verification, or handling Groq event notifications securely. Trigger with phrases like "groq webhook", "groq events", "groq webhook signature", "handle groq events", "groq notifications". allowed-tools: Read, Write, Edit, Bash(curl:*) version: 1.0.0 license: MIT author: Jeremy Longshore jeremy@intentsolutions.io

Groq Webhooks & Events

Overview

Securely handle Groq webhooks with signature validation and replay protection.

Prerequisites

  • Groq webhook secret configured
  • HTTPS endpoint accessible from internet
  • Understanding of cryptographic signatures
  • Redis or database for idempotency (optional)

Webhook Endpoint Setup

Express.js

import express from 'express';
import crypto from 'crypto';

const app = express();

// IMPORTANT: Raw body needed for signature verification
app.post('/webhooks/groq',
  express.raw({ type: 'application/json' }),
  async (req, res) => {
    const signature = req.headers['x-groq-signature'] as string;
    const timestamp = req.headers['x-groq-timestamp'] as string;

    if (!verifyGroqSignature(req.body, signature, timestamp)) {
      return res.status(401).json({ error: 'Invalid signature' });
    }

    const event = JSON.parse(req.body.toString());
    await handleGroqEvent(event);

    res.status(200).json({ received: true });
  }
);

Signature Verification

function verifyGroqSignature(
  payload: Buffer,
  signature: string,
  timestamp: string
): boolean {
  const secret = process.env.GROQ_WEBHOOK_SECRET!;

  // Reject old timestamps (replay attack protection)
  const timestampAge = Date.now() - parseInt(timestamp) * 1000;
  if (timestampAge > 300000) { // 5 minutes
    console.error('Webhook timestamp too old');
    return false;
  }

  // Compute expected signature
  const signedPayload = `${timestamp}.${payload.toString()}`;
  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(signedPayload)
    .digest('hex');

  // Timing-safe comparison
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expectedSignature)
  );
}

Event Handler Pattern

type GroqEventType = 'resource.created' | 'resource.updated' | 'resource.deleted';

interface GroqEvent {
  id: string;
  type: GroqEventType;
  data: Record<string, any>;
  created: string;
}

const eventHandlers: Record<GroqEventType, (data: any) => Promise<void>> = {
  'resource.created': async (data) => { /* handle */ },
  'resource.updated': async (data) => { /* handle */ },
  'resource.deleted': async (data) => { /* handle */ }
};

async function handleGroqEvent(event: GroqEvent): Promise<void> {
  const handler = eventHandlers[event.type];

  if (!handler) {
    console.log(`Unhandled event type: ${event.type}`);
    return;
  }

  try {
    await handler(event.data);
    console.log(`Processed ${event.type}: ${event.id}`);
  } catch (error) {
    console.error(`Failed to process ${event.type}: ${event.id}`, error);
    throw error; // Rethrow to trigger retry
  }
}

Idempotency Handling

import { Redis } from 'ioredis';

const redis = new Redis(process.env.REDIS_URL);

async function isEventProcessed(eventId: string): Promise<boolean> {
  const key = `groq:event:${eventId}`;
  const exists = await redis.exists(key);
  return exists === 1;
}

async function markEventProcessed(eventId: string): Promise<void> {
  const key = `groq:event:${eventId}`;
  await redis.set(key, '1', 'EX', 86400 * 7); // 7 days TTL
}

Webhook Testing

# Use Groq CLI to send test events
groq webhooks trigger resource.created --url http://localhost:3000/webhooks/groq

# Or use webhook.site for debugging
curl -X POST https://webhook.site/your-uuid \
  -H "Content-Type: application/json" \
  -d '{"type": "resource.created", "data": {}}'

Instructions

Step 1: Register Webhook Endpoint

Configure your webhook URL in the Groq dashboard.

Step 2: Implement Signature Verification

Use the signature verification code to validate incoming webhooks.

Step 3: Handle Events

Implement handlers for each event type your application needs.

Step 4: Add Idempotency

Prevent duplicate processing with event ID tracking.

Output

  • Secure webhook endpoint
  • Signature validation enabled
  • Event handlers implemented
  • Replay attack protection active

Error Handling

| Issue | Cause | Solution | |-------|-------|----------| | Invalid signature | Wrong secret | Verify webhook secret | | Timestamp rejected | Clock drift | Check server time sync | | Duplicate events | Missing idempotency | Implement event ID tracking | | Handler timeout | Slow processing | Use async queue |

Examples

Testing Webhooks Locally

# Use ngrok to expose local server
ngrok http 3000

# Send test webhook
curl -X POST https://your-ngrok-url/webhooks/groq \
  -H "Content-Type: application/json" \
  -d '{"type": "test", "data": {}}'

Resources

Next Steps

For performance optimization, see groq-performance-tuning.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/groq-webhooks-events-ms1aw5hf/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/groq-webhooks-events-ms1aw5hf' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/groq-webhooks-events-ms1aw5hf/download' --output '.skill-downloads/groq-webhooks-events-ms1aw5hf/SKILL.md.part' && mv '.skill-downloads/groq-webhooks-events-ms1aw5hf/SKILL.md.part' '.skill-downloads/groq-webhooks-events-ms1aw5hf/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Write, Edit, Bash(curl:*)

Original excerpt: Prerequisites
  • Groq webhook secret configured
  • HTTPS endpoint accessible from internet
  • Understanding of cryptographic signatures
  • Redis or database for idempotency (optional)

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/groq-webhooks-events-ms1aw5hf/SKILL.md' && test -s '.skill-downloads/groq-webhooks-events-ms1aw5hf/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/groq-webhooks-events' && cp -R '.skill-downloads/groq-webhooks-events-ms1aw5hf' '.claude/skills/groq-webhooks-events'

Cursor
test -f '.skill-downloads/groq-webhooks-events-ms1aw5hf/SKILL.md' && test -s '.skill-downloads/groq-webhooks-events-ms1aw5hf/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/groq-webhooks-events' && cp -R '.skill-downloads/groq-webhooks-events-ms1aw5hf' '.cursor/skills/groq-webhooks-events'

Codex
test -f '.skill-downloads/groq-webhooks-events-ms1aw5hf/SKILL.md' && test -s '.skill-downloads/groq-webhooks-events-ms1aw5hf/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/groq-webhooks-events' && cp -R '.skill-downloads/groq-webhooks-events-ms1aw5hf' '.agents/skills/groq-webhooks-events'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/groq-webhooks-events-ms1aw5hf'

openskills read 'groq-webhooks-events-ms1aw5hf'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/groq-webhooks-events-ms1aw5hf/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills