deleteEvent
Remove Nostr events by publishing deletion notices to relays, allowing users to delete specific event IDs with optional reasons.
Instructions
Delete events (kind 5)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| eventIds | Yes | IDs of events to delete | |
| reason | No | Reason for deletion | |
| privateKey | No | Private key (nsec or hex). Optional when NOSTR_BUNKER_URI is configured. | |
| relays | No | Relays to publish to |
Implementation Reference
- src/tools/social-tools.ts:143-155 (handler)The handler function that creates and publishes a NIP-09 deletion event.
export async function deleteEvent({ eventIds, reason, privateKey, relays }: z.infer<typeof deleteEventSchema>) { const tags: string[][] = eventIds.map(id => ['e', id]); const template: EventTemplate = { kind: KINDS.DELETE, content: reason ?? '', tags, created_at: Math.floor(Date.now() / 1000), }; const signed = await signTemplate(template, privateKey); const result = await publishEvent(signed, relays ?? DEFAULT_RELAYS); return { event: signed, published: result }; } - src/tools/social-tools.ts:37-42 (schema)Zod schema for validating the deleteEvent input parameters.
export const deleteEventSchema = z.object({ eventIds: z.array(z.string()).describe('IDs of events to delete'), reason: z.string().optional().describe('Reason for deletion'), privateKey: z.string().optional().describe(privateKeyDesc), relays: z.array(z.string()).optional().describe('Relays to publish to'), });