Skip to content

chore: change webhook back to object #7461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mean-jars-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/service-utils": patch
---

chore: data in webhook payload is an object
9 changes: 6 additions & 3 deletions packages/service-utils/src/node/webhookProducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import assert from "node:assert";
import { createId } from "@paralleldrive/cuid2";
import type { KafkaProducer } from "./kafka.js";

/**
* The event schema for webhook events.
* See more: https://github.com/thirdweb-dev/api-server/blob/dev/docs/webhooks.md
*/
interface WebhookEvent extends Record<string, unknown> {
id?: `evt_${string}`;
teamId: string;
Expand All @@ -11,9 +15,9 @@ interface WebhookEvent extends Record<string, unknown> {
*/
createdAt?: Date;
/**
* An array of your model (defined in api-server). Must not be empty.
* Your model defined in api-server.
*/
payload: Record<string, unknown>[];
data: Record<string, unknown>;
}

/**
Expand Down Expand Up @@ -42,7 +46,6 @@ export class WebhookEventProducer {
*/
async sendEvents(topic: string, events: WebhookEvent[]): Promise<void> {
const parsedEvents: WebhookEvent[] = events.map((event) => {
assert(event.payload.length > 0, "payload must not be empty");
assert(
event.teamId.startsWith("team_"),
"teamId must start with 'team_'",
Expand Down
Loading