Skip to main content
Solved

Transactional emails via API

  • November 23, 2024
  • 2 replies
  • 59 views

Forum|alt.badge.img
  • Contributor I

We need to send transactional (!) emails via API.
The reason behind the transactional emails are information about coupon codes and rules about misuse of coupon codes.
The template itself is saved on Klaviyo.
We only need to put in e-mail, first-name and some metadata.
The profiles that will get these emails are our customers already and have an active profile.

How does it work?

Best answer by ArpitBanjara

Hey ​@fxi 

Do you know how to utilize Send Email API endpoint? This allows you to send pre-designed templates stored in Klaviyo to specific recipients with dynamic data (like email, first name, and metadata)

so basically endpoint url should be - https://a.klaviyo.com/api/v1/email-template/[TEMPLATE_ID]/send

Method: Post 

and the payload should be something like this

{
  "to": "customer_email@example.com",
  "context": {
    "first_name": "John",
    "coupon_code": "SAVE20",
    "rule_description": "This coupon is valid for one-time use only and cannot be combined with other offers."
  }
}

I hope this helps and thank you for sharing your question here in the community.

Cheers

Arpit

View original
Did this topic or the replies in the thread help you find an answer to your question?

2 replies

ArpitBanjara
Principal User I
Forum|alt.badge.img+36
  • Principal User I
  • 371 replies
  • Answer
  • November 25, 2024

Hey ​@fxi 

Do you know how to utilize Send Email API endpoint? This allows you to send pre-designed templates stored in Klaviyo to specific recipients with dynamic data (like email, first name, and metadata)

so basically endpoint url should be - https://a.klaviyo.com/api/v1/email-template/[TEMPLATE_ID]/send

Method: Post 

and the payload should be something like this

{
  "to": "customer_email@example.com",
  "context": {
    "first_name": "John",
    "coupon_code": "SAVE20",
    "rule_description": "This coupon is valid for one-time use only and cannot be combined with other offers."
  }
}

I hope this helps and thank you for sharing your question here in the community.

Cheers

Arpit


  • Contributor I
  • 1 reply
  • November 27, 2024
ArpitBanjara wrote:

Hey ​@fxi 

Do you know how to utilize Send Email API endpoint? This allows you to send pre-designed templates stored in Klaviyo to specific recipients with dynamic data (like email, first name, and metadata)

so basically endpoint url should be - https://a.klaviyo.com/api/v1/email-template/[TEMPLATE_ID]/send

Method: Post 

and the payload should be something like this

{
  "to": "customer_email@example.com",
  "context": {
    "first_name": "John",
    "coupon_code": "SAVE20",
    "rule_description": "This coupon is valid for one-time use only and cannot be combined with other offers."
  }
}

I hope this helps and thank you for sharing your question here in the community.

Cheers

Arpit

Hey,

isn’t the `send` endpoint heavily restricted?

Furthermore, it gives me: 

 

{

    "status": 403,

    "message": "You must specify an API key to make requests."

}

Even though I authenticated myself in the headers with `Authorization` and my Klaviyo-API-Key!