klaviyo_subscribe_to_list
Subscribe an email to a Klaviyo mailing list.
klaviyo_subscribe_to_list(context: dict, email: str, list_id: str) -> dictSubscribes an email address to a specific Klaviyo mailing list.
Requires the Klaviyo integration to be installed for the business.
Parameters
| Name | Type | Description |
|---|---|---|
context | dict | The context object passed to your action |
email | str | The customer's email address |
list_id | str | The Klaviyo list ID to subscribe to |
Returns
dict — {"success": true}
Examples
Subscribe a customer to a newsletter
def execute_action(context):
email = context["args"]["email"]
klaviyo_subscribe_to_list(context, email, "WbBHEg")
return {"success": True, "message": "You've been subscribed to our newsletter!"}Subscribe to a list chosen by the customer
def execute_action(context):
email = context["args"]["email"]
list_id = context["args"]["listId"]
klaviyo_subscribe_to_list(context, email, list_id)
return {"success": True}