marketo_remove_leads_from_list
Remove specific leads from a Marketo static list. Provide list ID and array of up to 300 lead IDs to clean your lists.
Instructions
Remove one or more leads from a static list by lead IDs. Max 300 leads per call.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| listId | Yes | Static list ID | |
| leadIds | Yes | Array of lead IDs to remove (max 300) |
Implementation Reference
- src/tools/lists.ts:56-66 (handler)The handler function for marketo_remove_leads_from_list. Maps leadIds to input array and POSTs to Marketo's /rest/v1/lists/{listId}/leads/delete.json.
async (args) => { try { const input = args.leadIds.map(id => ({ id })); return ok(await makeRequest( `/rest/v1/lists/${args.listId}/leads/delete.json`, "POST", { input }, "application/json" )); } catch (e) { return err(e); } } - src/tools/lists.ts:52-55 (schema)Input schema using Zod: listId (number) and leadIds (array of numbers, max 300).
{ listId: z.number().describe("Static list ID"), leadIds: z.array(z.number()).describe("Array of lead IDs to remove (max 300)"), }, - src/tools/lists.ts:49-67 (registration)Tool registration via server.tool() with name 'marketo_remove_leads_from_list' and description.
server.tool( "marketo_remove_leads_from_list", "Remove one or more leads from a static list by lead IDs. Max 300 leads per call.", { listId: z.number().describe("Static list ID"), leadIds: z.array(z.number()).describe("Array of lead IDs to remove (max 300)"), }, async (args) => { try { const input = args.leadIds.map(id => ({ id })); return ok(await makeRequest( `/rest/v1/lists/${args.listId}/leads/delete.json`, "POST", { input }, "application/json" )); } catch (e) { return err(e); } } ); - src/index.ts:21-26 (registration)The registerListTools function is called here, which registers all list tools including marketo_remove_leads_from_list.
registerFormTools(server); registerLeadTools(server); registerProgramTools(server); registerEmailTools(server); registerSmartListTools(server); registerListTools(server); - src/client.ts:21-49 (helper)The makeRequest helper used by the handler to send authenticated HTTP requests to the Marketo API.
export async function makeRequest<T = unknown>( endpoint: string, method: Method = "GET", data?: unknown, contentType?: string, ): Promise<T> { const token = await getAccessToken(); const config: AxiosRequestConfig = { url: `${MARKETO_BASE_URL}${endpoint}`, method, headers: { Authorization: `Bearer ${token}`, ...(contentType ? { "Content-Type": contentType } : {}), }, ...(data && method !== "GET" ? { data } : {}), ...(data && method === "GET" ? { params: data } : {}), }; const res = await axios(config); const body = res.data; // Marketo REST API returns errors inside the response body if (body?.errors?.length) { const e = body.errors[0]; throw new MarketoError(`${e.code}: ${e.message}`, res.status); } return body as T; }