Skip to main content
Glama

update_profile

Modify customer profile details in Klaviyo by updating fields like email, phone number, first name, last name, and custom properties using the profile ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailNoEmail address of the profile
external_idNoExternal ID for the profile
first_nameNoFirst name of the profile
idYesID of the profile to update
last_nameNoLast name of the profile
phone_numberNoPhone number of the profile
propertiesNoAdditional properties for the profile

Implementation Reference

  • The main handler function for the 'update_profile' tool. It extracts the profile ID, builds attributes from input parameters, constructs a PATCH payload, calls klaviyoClient.patch to update the profile, and returns the result or error.
    async (params) => { try { const { id, ...rest } = params; const attributes = {}; // Add all provided fields to attributes for (const [key, value] of Object.entries(rest)) { if (value !== undefined && key !== 'properties') { attributes[key] = value; } } // Add properties if provided if (params.properties) { attributes.properties = params.properties; } const payload = { data: { type: "profile", id, attributes } }; const result = await klaviyoClient.patch(`/profiles/${id}/`, payload); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error updating profile: ${error.message}` }], isError: true }; } },
  • Zod schema defining the input parameters for the 'update_profile' tool, including required profile ID and optional fields like email, phone, names, and custom properties.
    { id: z.string().describe("ID of the profile to update"), email: z.string().email().optional().describe("Email address of the profile"), phone_number: z.string().optional().describe("Phone number of the profile"), external_id: z.string().optional().describe("External ID for the profile"), first_name: z.string().optional().describe("First name of the profile"), last_name: z.string().optional().describe("Last name of the profile"), properties: z.record(z.any()).optional().describe("Additional properties for the profile") },
  • The server.tool call that registers the 'update_profile' tool with its name, input schema, handler function, and description within the registerProfileTools function.
    server.tool( "update_profile", { id: z.string().describe("ID of the profile to update"), email: z.string().email().optional().describe("Email address of the profile"), phone_number: z.string().optional().describe("Phone number of the profile"), external_id: z.string().optional().describe("External ID for the profile"), first_name: z.string().optional().describe("First name of the profile"), last_name: z.string().optional().describe("Last name of the profile"), properties: z.record(z.any()).optional().describe("Additional properties for the profile") }, async (params) => { try { const { id, ...rest } = params; const attributes = {}; // Add all provided fields to attributes for (const [key, value] of Object.entries(rest)) { if (value !== undefined && key !== 'properties') { attributes[key] = value; } } // Add properties if provided if (params.properties) { attributes.properties = params.properties; } const payload = { data: { type: "profile", id, attributes } }; const result = await klaviyoClient.patch(`/profiles/${id}/`, payload); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error updating profile: ${error.message}` }], isError: true }; } }, { description: "Update an existing profile in Klaviyo" } );
  • src/server.js:32-32 (registration)
    Invocation of registerProfileTools(server) which registers the 'update_profile' tool along with other profile-related tools.
    registerProfileTools(server);
  • Import of klaviyoClient utility used by the update_profile handler for making the PATCH request to update profiles.
    import * as klaviyoClient from '../klaviyo-client.js';

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ivan-rivera-projects/Klaviyo-MCP-Server-Enhanced'

If you have feedback or need assistance with the MCP directory API, please join our Discord server