Hello @abhinav99
I am assuming the external endpoint is returning a JSON object with all values required to create a template.
What you can do is read data from the endpoint and create template with some JS code.
How to read JSON data from an API:
var req = new HttpClientRequest("ENDPOINT")
req.header["Authorization"] = "Bearer " // if any auth is required
req.header["Content-Type"] = "application/json";
req.method = "GET";
try {
req.execute()
}
catch(e)
{
logError(e)
}
var response = req.response
var res=JSON.parse(response.body);
req.disconnect()
You will have the data in res and then you can fetch the data from any available attribute
Then create the transactional email delivery with JS Code:
var delivery = nms.delivery.create()
delivery.Duplicate("nms:delivery|3714"); // 3714 is the primarky key of default transactional template
delivery.eventType=eventType; // change this according to your variables
delivery.label = deliveryLabel; // change this according to your variables
delivery.content.html.source=deliveryHTMLContent; // change this according to your variables
delivery.content.text.source=delvieryTextContent; // change this according to your variables
delivery.save();