delete_campaign
Permanently remove a campaign by providing its campaign ID. This action is irreversible and cannot be undone.
Instructions
Delete a campaign. This action is irreversible.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| campaign_id | Yes | Campaign ID to delete |
Implementation Reference
- src/tools/campaigns.ts:123-137 (registration)The delete_campaign tool is registered via server.tool() in the registerCampaignTools function. It takes a campaign_id string parameter and sends a DELETE request to the Meta Ads API.
server.tool( "delete_campaign", "Delete a campaign. This action is irreversible.", { campaign_id: z.string().describe("Campaign ID to delete"), }, async ({ campaign_id }) => { try { const { data, rateLimit } = await client.delete(`/${campaign_id}`); return { content: [{ type: "text" as const, text: JSON.stringify({ success: true, ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - src/tools/campaigns.ts:129-136 (handler)The handler function that executes delete_campaign logic. Calls client.delete with the campaign_id and returns the API response as JSON text.
async ({ campaign_id }) => { try { const { data, rateLimit } = await client.delete(`/${campaign_id}`); return { content: [{ type: "text" as const, text: JSON.stringify({ success: true, ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } - src/tools/campaigns.ts:126-128 (schema)Zod schema for the delete_campaign tool input: requires a single campaign_id string.
{ campaign_id: z.string().describe("Campaign ID to delete"), }, - src/services/ads-client.ts:194-199 (helper)The AdsClient.delete helper method used by the delete_campaign handler. Wraps the request method with HTTP DELETE.
async delete( path: string, params?: Record<string, unknown> ): Promise<ClientResponse> { return this.request("DELETE", path, params); }