delete_ad
Delete a specific ad by providing its ad ID. This action permanently removes the ad and cannot be undone.
Instructions
Delete an ad. This action is irreversible.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ad_id | Yes | Ad ID to delete |
Implementation Reference
- src/tools/ads.ts:104-119 (handler)The 'delete_ad' tool handler function. It accepts an 'ad_id' string parameter, calls client.delete with the ad ID, and returns the result with a success indicator.
// ─── delete_ad ───────────────────────────────────────────── server.tool( "delete_ad", "Delete an ad. This action is irreversible.", { ad_id: z.string().describe("Ad ID to delete"), }, async ({ ad_id }) => { try { const { data, rateLimit } = await client.delete(`/${ad_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/ads.ts:108-110 (schema)The input schema for 'delete_ad': requires a single string parameter 'ad_id' described as 'Ad ID to delete'.
{ ad_id: z.string().describe("Ad ID to delete"), }, - src/tools/ads.ts:105-119 (registration)Registration of the 'delete_ad' tool via server.tool() call, with name 'delete_ad', description 'Delete an ad. This action is irreversible.', and the handler function.
server.tool( "delete_ad", "Delete an ad. This action is irreversible.", { ad_id: z.string().describe("Ad ID to delete"), }, async ({ ad_id }) => { try { const { data, rateLimit } = await client.delete(`/${ad_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/index.ts:52-52 (registration)Registration call: registerAdTools(server, client) which sets up the 'delete_ad' tool among other ad tools.
registerAdTools(server, client); - src/services/ads-client.ts:194-199 (helper)The AdsClient.delete() method used by the 'delete_ad' handler to issue the HTTP DELETE request to the Meta Ads API.
async delete( path: string, params?: Record<string, unknown> ): Promise<ClientResponse> { return this.request("DELETE", path, params); }