Skip to main content

Replace HTML content example for /send API

Merge in specific content on a per-contact basis when using the transactional /send API

Marcus Warren avatar
Written by Marcus Warren
Updated this week

Data structure and allowed key values

The "replace" property is a simple object, with the provided keys to be replaced with the provided values. Values must be a string, and keys must be delimited by curly brace characters. For example "{HEADLINE_1}" or "{BODY_CONTENT}" are valid key values.

The "replace" property can be added to any contact in the array for "recipients" or "recipient_contact_ids".

You cannot replace Envoke preferences page merge patterns. So using keys such as "{@pref-0}", "{@consent-url}", etc. will return an error.

Example "replace" field object:

{
"{headline_text}": "Hello world!",
"{body_text}": "Content line 1<br><br>Content line 2<br><br><a href=\"https://test.com\">Here is a link</a>"
}

Example with "html" field provided:

curl -X POST -u API_ID:API_KEY -d '{"subject":"API example","recipients":[{"email":"documentation@example.com","replace":{"{headline_text}":"Hello world!","{body_text}":"Content line 1<br><br>Content line 2<br><br><a href=\"https://test.com\">Here is a link</a>"}}],"html":"<h1>{headline_text}</h1><p>{body_text}</p>"}' "https://e1.envoke.com/v1/send"

Example using stored existing content with "template_id":

curl -X POST -u API_ID:API_KEY -d '{"subject":"API example","recipients":[{"email":"documentation@example.com","replace":{"{headline_text}":"Hello world!","{body_text}":"Content line 1<br><br>Content line 2<br><br><a href=\"https://test.com\">Here is a link</a>"}}],"template_id":"123456","enable_merge_fields":true}' "https://e1.envoke.com/v1/send"

Did this answer your question?