I’m trying using the list subscribe endpoint (https://a.klaviyo.com/api/v2/list/<list-id>/subscribe) and the API isn’t returning Access Control Allow Origin headers so the browser is blocking the request. Does the Klaviyo API support CORs requests in the browser?
Best answer by Paul S
Our server-side APIs are set up to deny incoming connections from the front-end in order to prevent people from exposing their sensitive private API keys which are required for these endpoints. When sending subscriptions to Klaviyo, here are our recommended approaches:
- If you want to use an API endpoint, use the server-side subscribe endpoint from a server-side location
- If you do not have access to a server-side location for your platform (eg. you’re on a hosted platform), you can set up a proxy which routes a request to subscribe from your front-end to this proxy in order to send the server-side request
- Alternatively, an easy way to set up subscribes from the front-end would be to use our built-in forms or one of our partner integrations who offer subscription forms
Hope that information helps but if you need additional information, please do follow up.