unsubscribe_subscriber
Remove a subscriber's email from a mailing list to manage email preferences and comply with unsubscribe requests.
Instructions
Unsubscribe subscriber from a mailing list
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| listId | Yes | Id of the mailing list | |
| Yes | Email of the subscriber |
Implementation Reference
- src/tools/api.ts:149-165 (handler)Handler function that executes the unsubscribe operation by calling the SendClient's subscribers.unsubscribe method and returns success or error message.execute: async ({ listId, email }) => { try { await client.subscribers.unsubscribe(listId, email); return { content: [ { type: "text", text: `Subscriber '${email}' successfully unsubscribed from mailing list '${listId}'` } ] } } catch (e) { return { content: [ { type: "text", text: `Error: ${(e as ApiResponseError).sendResponse?.Error}` } ] } } }
- src/tools/api.ts:141-144 (schema)Zod schema defining input parameters: listId (UUID) and email.parameters: z.object({ listId: z.string().uuid().describe("Id of the mailing list"), email: z.string().email().describe("Email of the subscriber") }),
- src/tools/api.ts:138-166 (registration)Registration of the 'unsubscribe_subscriber' tool using server.addTool, including name, description, schema, annotations, and handler.server.addTool({ name: "unsubscribe_subscriber", description: "Unsubscribe subscriber from a mailing list", parameters: z.object({ listId: z.string().uuid().describe("Id of the mailing list"), email: z.string().email().describe("Email of the subscriber") }), annotations: { title: "Unsubscribe subscriber from a mailing list", openWorldHint: true, }, execute: async ({ listId, email }) => { try { await client.subscribers.unsubscribe(listId, email); return { content: [ { type: "text", text: `Subscriber '${email}' successfully unsubscribed from mailing list '${listId}'` } ] } } catch (e) { return { content: [ { type: "text", text: `Error: ${(e as ApiResponseError).sendResponse?.Error}` } ] } } } });