create_list
Generate and manage customer lists or segments within the Klaviyo API by specifying a name and type. Use this tool to organize and segment audience data for targeted marketing campaigns.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_type | Yes | Type of list (list or segment) | |
| name | Yes | Name of the list |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"list_type": {
"description": "Type of list (list or segment)",
"enum": [
"list",
"segment"
],
"type": "string"
},
"name": {
"description": "Name of the list",
"type": "string"
}
},
"required": [
"name",
"list_type"
],
"type": "object"
}
Implementation Reference
- src/tools/lists.js:58-80 (handler)The handler function for the 'create_list' tool. It constructs a payload with the list name and type, then calls klaviyoClient.post to create the list via Klaviyo API, returning the result or error.async (params) => { try { const payload = { data: { type: "list", attributes: { name: params.name, list_type: params.list_type } } }; const result = await klaviyoClient.post('/lists/', payload); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error creating list: ${error.message}` }], isError: true }; } },
- src/tools/lists.js:54-57 (schema)Zod schema defining the input parameters for the create_list tool: name (string) and list_type (enum: list or segment).{ name: z.string().describe("Name of the list"), list_type: z.enum(["list", "segment"]).describe("Type of list (list or segment)") },
- src/tools/lists.js:52-82 (registration)Direct registration of the 'create_list' tool using server.tool, including schema, inline handler, and description.server.tool( "create_list", { name: z.string().describe("Name of the list"), list_type: z.enum(["list", "segment"]).describe("Type of list (list or segment)") }, async (params) => { try { const payload = { data: { type: "list", attributes: { name: params.name, list_type: params.list_type } } }; const result = await klaviyoClient.post('/lists/', payload); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error creating list: ${error.message}` }], isError: true }; } }, { description: "Create a new list in Klaviyo" } );
- src/server.js:33-33 (registration)Top-level call to registerListTools(server), which in turn registers the create_list tool among others.registerListTools(server);