Sending with a template
Sending emails through dynamic templates is what most teams use Waypoint for. To send a templated email, use the API call below — pass data variables in the call and reference them from your template.
API endpoints
Section titled “API endpoints”Code example
Section titled “Code example”curl "https://live.waypointapi.com/v1/email_messages" \ -H "Content-Type: application/json" \ -u "API_KEY_USERNAME:API_KEY_PASSWORD" \ -d '{ "templateId": "wptemplate_ABc123XYZ", "to": "jordan@usewaypoint.com", "variables": { "user": { "displayName": "Jordan" }, "product": { "title": "Beechers Mac & Cheese", "id": "02934203942" } }}'const authHeader = 'Basic ' + Buffer.from(`${API_KEY_USERNAME}:${API_KEY_PASSWORD}`).toString('base64');
const options = { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: authHeader, }, body: JSON.stringify({ templateId: 'wptemplate_ABc123XYZ', to: 'jordan@usewaypoint.com', variables: { user: { displayName: 'Jordan', }, product: { title: 'Beechers Mac & Cheese', id: '02934203942', }, }, }),};
fetch('https://live.waypointapi.com/v1/email_messages', options) .then((res) => res.json()) .then((res) => console.log(res)) .catch((err) => console.error(err));