update_audience
Update an existing custom audience's name or description by providing the audience ID. Only specified fields are modified.
Instructions
Update an existing custom audience. Only provided fields will be modified.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| audience_id | Yes | Audience ID to update | |
| name | No | New audience name | |
| description | No | New audience description |
Implementation Reference
- src/tools/audiences.ts:86-106 (handler)The actual tool handler implementation for 'update_audience'. It calls `client.post(/${audience_id}, params)` to update an existing custom audience by ID. Accepts optional `name` and `description` fields.
// ─── update_audience ─────────────────────────────────────── server.tool( "update_audience", "Update an existing custom audience. Only provided fields will be modified.", { audience_id: z.string().describe("Audience ID to update"), name: z.string().optional().describe("New audience name"), description: z.string().optional().describe("New audience description"), }, async ({ audience_id, name, description }) => { try { const params: Record<string, unknown> = {}; if (name) params.name = name; if (description) params.description = description; const { data, rateLimit } = await client.post(`/${audience_id}`, params); return { content: [{ type: "text" as const, text: JSON.stringify({ ...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/audiences.ts:90-94 (schema)Zod schema for 'update_audience' tool: `audience_id` (required string), `name` (optional string), `description` (optional string).
{ audience_id: z.string().describe("Audience ID to update"), name: z.string().optional().describe("New audience name"), description: z.string().optional().describe("New audience description"), }, - src/tools/audiences.ts:87-106 (registration)The tool is registered via `server.tool("update_audience", ...)` inside the `registerAudienceTools` function in src/tools/audiences.ts.
server.tool( "update_audience", "Update an existing custom audience. Only provided fields will be modified.", { audience_id: z.string().describe("Audience ID to update"), name: z.string().optional().describe("New audience name"), description: z.string().optional().describe("New audience description"), }, async ({ audience_id, name, description }) => { try { const params: Record<string, unknown> = {}; if (name) params.name = name; if (description) params.description = description; const { data, rateLimit } = await client.post(`/${audience_id}`, params); return { content: [{ type: "text" as const, text: JSON.stringify({ ...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/services/ads-client.ts:187-199 (helper)The `post` method on AdsClient used by the handler to send the update request to the Meta Ads API.
async post( path: string, params?: Record<string, unknown> ): Promise<ClientResponse> { return this.request("POST", path, params); } async delete( path: string, params?: Record<string, unknown> ): Promise<ClientResponse> { return this.request("DELETE", path, params); }