Hey @TomBot2000 - welcome to the community.
You can definitely send an email via an API call, but if you want to just have an email triggered every time someone subscribes to a List, using a conventional Klaviyo Flow triggered on a List Subscribe event might be your better option as you’ll have the full suite of Klaviyo tools at your disposal including reporting/analytics, Flow branching logic, A/B testing, Flow,Trigger Filtering and options to send more emails in a sequence.
Take a look at the documentation to trigger a List-Triggered Flow - sometimes referred to as a “Welcome Series” here:
Guide to Creating a List-Triggered Flow
Tip - some common issues for troubleshooting if you’re not getting the email is to make sure you’re confirming the Double Opt-In emails upon subscribing - or set your List Settings to “Single Opt-In” which you mentioned you already have done. And if you happen to be testing it yourself - you can’t subscribe (and get your first email) multiple times with the same email unless you delete the profile first. Use new email addresses for each test.
Using the API Method
If you “have to” send emails programmatically via the Klaviyo API, the endpoints for the “Render and Send Template” is in the docs you mentioned - but your account has to be first verified to do this by Klaviyo. The API requires a Template ID that you can create in the Template section of Klaviyo, and you can append a data payload (JSON Object) that maps to any variables you have in your Template (e.g. First Name, a unique link for the subscriber, etc).
Due note the rate limiting (100/hour, 1,000/day) to make sure it works with your volume - Klaviyo doesn’t really recommend this approach on a large scale. I’m assuming these safeguards is to avoid abuse from some Spammer who signs up for Klaviyo and tries to use this to send spam.
Hope this helps!
@retention Joseph, that was an EXCELLENT response.
So there are 2 potential paths here?
(1) a conventional signup flow (does this mean my users would get bumped out of my app and over to a FORM that I create / is hosted on / Klaviyo? While klavio is sleek, it would nonetheless be a weird /broken user flow to jump out of my app and onto a klavio hosted form (the user would have just filled out a bunch of registration stuff within my app, i wouldn’t want them to submit that only to be bounced to another form asking them to submit again, so i really want to just handle everything for them behind the scenes and make it seamless / one click from my app (registering my app but also firing an API even off to send them a thank you / confirmation). -- if i even understand that correctly that is?
which makes me think you would recommend path #2:
(2) API event to render-and-send a single message with any parameters (i only have one such variable) otherwise it’s a generic template. I think i got you here Joseph. I can get my template ID (done), and on my app, package up the id & my variable into the correct json payload and make said call. I can still use the other list/v2/subscribe call (i already have 100% working) to sign them up to a ‘registered users’ list i have on klaviyo. I think i’ll do both. It’s just that i cant automagically trigger a flow when doing that correct? I can’t simply add/susbribe a user to a list from an API call and ALSO trigger the flow event (new subscriber)… am i correct? i can’t trigger it because i/my app did the subscribing on behalf of that user. is that why the flow never triggers? subscribe endpoint cant also trigger the flow to start? (yes, it’s a single opt in list). If that’s the case, i’ll use ‘subscribe’ to just get them on a list for future mailings if any, and also use render-and-send to send that one-off ‘welcome’ email. don’t worry i won’t be anywhere near spam quotas. likely 5 per week would be some kind magical week! :)
but question if number 2 is the right path: how do i get APPROVAL you mentioned to use this endpoint? can you help with that? i don’t see any way to ask permission, so i’m asking you for your help!!! Thank you Joseph.
Best Regards, Tom
@TomBot2000 - Apologies for the late reply - I just saw it now. Thanks for the context in explaining what you’re trying to do.
Actually, I would still recommend Option 1. You can build your Flow in Klaviyo to be triggered on a List Subscription so you get all the said benefits above - batteries included.
But to address your point, you can use the Klaviyo API “Subscribe” end point to add a Profile to the List (which then triggers them to the Flow you built).
That way, you don’t have to embed a Form in your App and you can Subscribe users programmatically with that Server Side API Call to Subscribe.
Just note, you’ll lose a bit of fidelity with using a Server Side API Call that sometimes is nice with a embedded Klaviyo Form - namely, Klaviyo immediately sets a session ID (cookie) to identify them later, passes in other contextual client-side HTTP header values like the IP Address (to determine a GEO IP location), along with any UTM parameters it detects. But these may not be important to you since they’re in your App and some of it will happen automagically when/if someone clicks over from an email.
Finally, since it’s a proper “Subscribe” function, make sure you have the T&C’s or messaging within your App to let the user know they are explicitly consenting. And, verify your List settings for either Double Opt-In or Single Opt-In. If your List requires a Double Opt-In, they won’t be in the List until they’ve confirmed the Opt-In email notification (by design).
Hope this helps and good luck. We’re here if you need more help!