Solved

Send content to a campaign via API

  • 28 September 2022
  • 6 replies
  • 416 views

Badge +1

It seems a version of this question has been asked and answered in the past, but just to confirm:
It is not currently possible to inject actual content into a template (or direct HTML) via the API?
Looking at the API documentation, I don’t see any way fields that seem to support it. The reason why I am asking is that we use Klaviyo for transactional emails right now (for ecommerce) and would like to test ways of publishing content from our site as newsletters. Mailchimp does to support this option, to fetch content from a site, and inject that content as HTML into a campaign (we are using Make for API integrations). Ideally we could do the same with Klaviyo and not use two different email marketing channels. 
 

https://developers.klaviyo.com/en/reference/create-campaign

icon

Best answer by David To 28 September 2022, 16:39

View original

6 replies

Got it @David To, thanks for the insight!

David (or others on the Klaviyo team), I just signed up for the beta API and it’s not clear which method one should use to trigger an email to be sent from the API with the context I provide. For clarification, this is for a loyalty program I’m building for a shopify client that wants birthday emails to be sent out when their ‘family members’ have a birthday (family members are managed via data model attached to the shopify user in an external database we manage).

We’re triggering this action from the external database, but we have access to the full customer object and the family member in question when we send the request. I want to be able to send to the klaviyo API a request to send an email, along with a context payload containing the name of the birthday boy/girl, the shopify customer’s name, etc. What would be the best way to go about doing this?

 

The old render and send template api call would’ve been perfect for this use case, but that seems to be deprecated.

Userlevel 7
Badge +60

Hey @onSight,

Based on the context you shared, the most suitable solution would be through a metric triggered flow. Similar to my explanation in the Send email with dynamic content to specific user via the API Community post I previously shared. 

As you noted, our previous  render and send template API endpoint is depreciated. Klaviyo no longer supports creating and sending emails via API. In fact, even when the render and send template API was available, it was only limited for testing purposes to preview emails. 

David

@David To actually, it looks like a lot of the links you referenced in that other thread have deprecated warnings on them as well, and I can’t find anything on the current API version with the word ‘track’ or ‘identify’ using the search feature. Is the track and identify API still valid/current?

 

Edit: this appears to be the current version of the tutorial that’s relevant to me specifically: https://developers.klaviyo.com/en/docs/javascript_api

However, this implies you’re sending a request from the frontend where you can add the package using a `<script>` tag. I’m doing this from a serverless function we spun up as part of this custom build. Ideally I’d be able to send this request using the node npm package, but I can’t find anything on that package or in the relevant docs about how to send a track & identify request.

Userlevel 7
Badge +60

Hey @onSight,

The JavaScript API for identification and tracking developer guide you linked would indeed for tracking and firing events based on a `<script>` tag on your site. 

To send events via the backend via node, you’ll want to use the Create Event endpoint

David

Userlevel 7
Badge +60

Hello @tjwang,

Welcome to the Klaviyo Community! 

Happy to provide a clarification and confirm that at present, we do not support injecting content into templates via API. I think you may find some of the discussion points in the below Community posts helpful:

Although this sort of function isn’t available right now, our Product Team is actively working on expanding our API capabilities. These new capabilities included in the v3 version includes some enhanced feature of our previously depreciated templates API. If you’re interested, you can signup to our API beta through the form here.

Another idea that comes to mind that I would suggest looking into is potentially using a custom web feed. Using custom web feeds are similar to the behavior you’re explaining of being able to automatically have a template pull data from a specific source - in this case a web feed. A common use case for this would be if a brand has a routine blog that they would like to highlight in their emails. Instead of having to manually add each new blog entry to their templates, because the template is connected to a web feed the email content is updated automatically to showcase the latest blog content.

I hope this helps!
David

Reply