remove_users_from_audience
Remove users from a custom audience by providing audience ID and a payload of SHA-256 hashed identifiers. Maintain precise audience control for ad targeting.
Instructions
Remove users from a custom audience. Payload format is the same as add_users_to_audience.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| audience_id | Yes | Audience ID | |
| payload | Yes | JSON string: {schema: ['EMAIL','PHONE',...], data: [['hash1','hash2',...], ...]}. All PII must be SHA-256 hashed. |
Implementation Reference
- src/tools/audiences.ts:141-143 (registration)Registers the 'remove_users_from_audience' tool with server.tool(), defining its schema and handler.
); // ─── remove_users_from_audience ──────────────────────────── - src/tools/audiences.ts:147-150 (schema)Input schema: requires audience_id (string) and payload (string - JSON with schema and data arrays).
{ audience_id: z.string().describe("Audience ID"), payload: z.string().describe("JSON string: {schema: ['EMAIL','PHONE',...], data: [['hash1','hash2',...], ...]}. All PII must be SHA-256 hashed."), }, - src/tools/audiences.ts:151-158 (handler)Handler function that sends a DELETE request to /{audience_id}/users and returns the response or error.
async ({ audience_id, payload }) => { try { const { data, rateLimit } = await client.delete(`/${audience_id}/users`, { payload }); 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 }; } }