Delete a campaign
lob_campaigns_deleteDelete a campaign using its ID before it has been sent. Removes the campaign from the system.
Instructions
Delete a campaign. Only allowed before send.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Campaign ID (`cmp_…`). |
Implementation Reference
- src/tools/campaigns.ts:111-111 (handler)Handler for lob_campaigns_delete: sends a DELETE request to /campaigns/{id}
handler: async ({ id }) => lob.request({ method: "DELETE", path: `/campaigns/${id}` }), - src/tools/campaigns.ts:110-110 (schema)Input schema for lob_campaigns_delete: requires a campaign ID matching the pattern cmp_*
inputSchema: { id: CAMPAIGN_ID }, - src/tools/campaigns.ts:106-112 (registration)Registration of lob_campaigns_delete tool via registerTool utility
registerTool(server, { name: "lob_campaigns_delete", annotations: { title: "Delete a campaign", ...ToolAnnotationPresets.destructive }, description: "Delete a campaign. Only allowed before send.", inputSchema: { id: CAMPAIGN_ID }, handler: async ({ id }) => lob.request({ method: "DELETE", path: `/campaigns/${id}` }), }); - src/tools/helpers.ts:85-117 (helper)The registerTool helper that wraps handler logic with error handling and registers with the MCP server
export function registerTool<TShape extends ZodRawShape>( server: McpServer, def: ToolDefinition<TShape>, ): void { const a = def.annotations ?? {}; server.registerTool( def.name, { title: a.title ?? def.name, description: def.description, inputSchema: def.inputSchema, annotations: { ...a, // Lob is always external; default the hint accordingly. openWorldHint: a.openWorldHint ?? true, }, }, // The SDK's ToolCallback type is parameterised over the exact ZodRawShape and // resists the generic erasure here. The runtime contract (validated args in, // CallToolResult out) is correct, so we bridge the type boundary with `as never`. (async (args: unknown, serverCtx: unknown): Promise<CallToolResult> => { try { const result = await def.handler(args as never, serverCtx); return { content: [{ type: "text", text: stringifyResult(result) }] }; } catch (err) { return { isError: true, content: [{ type: "text", text: formatErrorForTool(err) }], }; } }) as never, ); } - src/tools/helpers.ts:48-48 (helper)ToolAnnotationPresets.destructive used by lob_campaigns_delete annotation
destructive: {