Idempotent requests
Idempotency is used for safely retrying requests without accidentally performing the same operation twice. On certain API endpoints API, you can use the optional metaId (eg. ‘my_product_123’) key. Then, if a connection error occurs, you can safely repeat the request without risk of performing the trigger twice.
const authHeader = 'Basic ' + Buffer.from(`${API_KEY_USERNAME}:${API_KEY_PASSWORD}`).toString('base64');
fetch('https://live.waypointapi.com/v1/email_messages', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: authHeader, }, body: JSON.stringify({ templateId: 'wptemplate_ABc123XYZ', metaId: 'my_product_123', to: 'jordan@usewaypoint.com', variables: { user: { displayName: 'Jordan', }, product: { title: 'Beechers Mac & Cheese', id: '02934203942', }, }, }),});curl "https://live.waypointapi.com/v1/email_messages" \ -H "Content-Type: application/json" \ -u "API_KEY_USERNAME:API_KEY_PASSWORD" \ -d '{ "templateId": "wptemplate_ABc123XYZ", "metaId": "my_product_123", "to": "jordan@usewaypoint.com", "variables": { "user": { "displayName": "Jordan" }, "product": { "title": "Beechers Mac & Cheese", "id": "02934203942" } }}'