Hello World!
", text: "Hello World!" }, options: { open_tracking: true, click_tracking: true } }, (err, res) => { if (err) { console.log(err); } else { console.log(res.body); console.log("Congrats you can use our SDK!"); } }); // Callback client.transmissions.send({ recipients: [{ address: { email: "john.doe@example.com" } }], content: { email_rfc822: "Content-Type: text/plain\nFrom: From EnvelopeHi {{address.name}} \nSave big this Christmas in your area {{place}}! \nClick http://www.mysite.com and get huge discount\n
" } }, (err, res) => { if (err) { console.log(err); } else { console.log(res.body); console.log("Congrats you can use our SDK!"); } }); // Callback client.transmissions.send({ recipients: [ { address: { email: "original.recipient@example.com", name: "Original Recipient" }, substitution_data: { recipient_type: "Original" } }, { address: { email: "bcc.recipient@example.com", header_to: "\"Original Recipient\"An example email using bcc with SparkPost to the {{recipient_type}} recipient.
" } }, (err, res) => { if (err) { console.log(err); } else { console.log(res.body); console.log("Congrats! You sent an email with bcc using SparkPost!"); } }); // Callback client.transmissions.send({ recipients: [ { address: { email: "original.recipient@example.com", name: "Original Recipient" }, substitution_data: { recipient_type: "Original" } }, { address: { email: "cc.recipient@example.com", name: "Carbon Copy Recipient", header_to: "\"Original Recipient\"An example email using cc with SparkPost to the {{recipient_type}} recipient.
" } }, (err, res) => { if (err) { console.log(err); } else { console.log(res.body); console.log("Congrats! You sent an email with cc using SparkPost!"); } }); // Callback client.transmissions.send({ recipients: { list_id: "example-list" }, content: { from: "From EnvelopeHello World
", text: "Hello World!" } }, (err, res) => { if (err) { console.log(err); } else { console.log(res.body); console.log("Congrats you can use our SDK!"); } }); // Callback client.transmissions.send({ recipients: { list_id: "example-list" }, content: { from: "From EnvelopeHi {{address.name}} \nSave big this Christmas in your area {{place}}! \nClick http://www.mysite.com and get huge discount\n
' } }) .then(data => { console.log('Congrats you can use our client library!'); console.log(data); }) .catch(err => { console.log('Whoops! Something went wrong'); console.log(err); }); // Promise client.transmissions.send({ recipients: [ { address: { email: 'original.recipient@example.com', name: 'Original Recipient' }, substitution_data: { recipient_type: 'Original' } }, { address: { email: 'cc.recipient@example.com', name: 'Carbon Copy Recipient', header_to: '"Original Recipient"An example email using cc with SparkPost to the {{recipient_type}} recipient.
' } }) .then(data => { console.log('Congrats! You sent an email with cc using SparkPost!'); console.log(data); }) .catch(err => { console.log('Whoops! Something went wrong'); console.log(err); }); // Callback client.webhooks.create({ name: "Test webhook", target: "http://client.test.com/test-webhook", auth_token: "AUTH_TOKEN", events: [ "delivery", "injection", "open", "click" ] }, (err, res) => { if (err) { console.log(err); } else { console.log(res.body); console.log("Congrats you can use our SDK!"); } }); // Promise client.webhooks.create({ name: 'Test Webhook', target: 'http://client.test.com/test-webhook', auth_token: 'AUTH_TOKEN', events: [ 'delivery', 'injection', 'open', 'click' ] }) .then(data => { console.log('Congrats you can use our client library!'); console.log(data); }) .catch(err => { console.log('Whoops! Something went wrong'); console.log(err); }); // Callback client.webhooks.delete("TEST_WEBHOOK_UUID", (err, res) => { if (err) { console.log(err); } else { console.log(res.body); console.log("Congrats you can use our SDK!"); } }); // Promise client.webhooks.delete('TEST_WEBHOOK_UUID') .then(data => { console.log('Congrats you can use our client library!'); console.log(data); }) .catch(err => { console.log('Whoops! Something went wrong'); console.log(err); }); // Callback client.webhooks.get('TEST_WEBHOOK_UUID', { timezone: 'America/New_York' }, (err, data) => { if (err) { console.log('Whoops! Something went wrong'); console.log(err); } else { console.log('Congrats you can use our client library!'); console.log(data); } }); // Promise client.webhooks.get('TEST_WEBHOOK_UUID', { timezone: 'America/New_York' }) .then(data => { console.log('Congrats you can use our client library!'); console.log(data); }) .catch(err => { console.log('Whoops! Something went wrong'); console.log(err); }); // Callback client.webhooks.getBatchStatus('TEST_WEBHOOK_UUID', { limit: 1000 }, (err, res) => { if (err) { console.log(err); } else { console.log(res.body); console.log("Congrats you can use our SDK!"); } }); // Promise client.webhooks.getBatchStatus('TEST_WEBHOOK_UUID', { limit: 1000 }) .then(data => { console.log('Congrats you can use our client library!'); console.log(data); }) .catch(err => { console.log('Whoops! Something went wrong'); console.log(err); }); // Callback client.webhooks.getDocumentation((err, res) => { if (err) { console.log(err); } else { console.log(res.body); console.log("Congrats you can use our SDK!"); } }); // Promise client.webhooks.getDocumentation() .then(data => { console.log('Congrats you can use our client library!'); console.log(data); }) .catch(err => { console.log('Whoops! Something went wrong'); console.log(err); }); // Callback client.webhooks.getSamples({ events: "bounce" }, (err, res) => { if (err) { console.log(err); } else { console.log(res.body); console.log("Congrats you can use our SDK!"); } }); // Promise client.webhooks.getSamples({ events: 'bounce' }) .then(data => { console.log('Congrats you can use our client library!'); console.log(data); }) .catch(err => { console.log('Whoops! Something went wrong'); console.log(err); }); // Callback client.webhooks.list((err, res) => { if (err) { console.log(err); } else { console.log(res.body); console.log("Congrats you can use our SDK!"); } }); // Promise client.webhooks.list() .then(data => { console.log('Congrats you can use our client library!'); console.log(data); }) .catch(err => { console.log('Whoops! Something went wrong'); console.log(err); }); // Callback client.webhooks.update('TEST_WEBHOOK_UUID', { name: "Renamed Test webhook", events: [ "policy_rejection", "delay" ] }, (err, res) => { if (err) { console.log(err); } else { console.log(res.body); console.log("Congrats you can use our SDK!"); } }); // Promise client.webhooks.update('TEST_WEBHOOK_UUID', { name: 'Renamed Test Webhook', events: [ 'policy_rejection', 'delay' ] }) .then(data => { console.log('Congrats you can use our client library!'); console.log(data); }) .catch(err => { console.log('Whoops! Something went wrong'); console.log(err); }); // Callback client.webhooks.validate('TEST_WEBHOOK_UUID', { message: { msys: {} } }, (err, res) => { if (err) { console.log(err); } else { console.log(res.body); console.log("Congrats you can use our SDK!"); } }); // Promise client.webhooks.validate('TEST_WEBHOOK_UUID', { message: { msys: {} } }) .then(data => { console.log('Congrats you can use our client library!'); console.log(data); }) .catch(err => { console.log('Whoops! Something went wrong'); console.log(err); });