How to send an email automatically from my own server side app via API?

  • 13 January 2022
  • 2 replies


Hi. I want to do what (in my mind) is the simplest use case of an emailer platform (before i get into metrics monitization marketing promotions customer retention). FIRST OFF, I ONLY WANT TO SEND AN EMAIL VIA AN API CALL. IS THIS POSSIBLE?


  1. in my own server side application, users are registering - for my own app, my own product support etc. part of which they are opting into email from me.
  2. at the moment they submit on my server side app, i want to (among all the other things i do there), i want to also sent them a quick thank you email (i have a template made on kalviyo)
  3. this would be on a user-by-user basis, small volume 5 a day would be a stellar day. more like 3 per week avg.

    so: should i just somehow download my template as HTML bundle and mail it via my own php script? my own smtp? this seems primitive. can’t i send directly one email to one person via API? … i tried 2 endpoints so far: list/members and subscribe. both worked to ADD the user to a single-opt-in list (i called it “REGISTERED”) but just adding them to that list does not send them an email on klaviyo.

    I then added a FLOW simply stating “if new suscriber, then trigger the email to be sent” .. but no dice. the user is added to members and list via API no problem, but the flow doesn’t trigger. 

    Then i saw a different endpoint in the docs to render and send template. is that the one i need? it said my account would need some kind of verification to use that endpoint. Help?

thanks. tom.


Best answer by retention 13 January 2022, 22:25

View original

2 replies

Userlevel 7
Badge +29

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