This library provides easy access to the Templates Resource.
- all(callback)
List a summary of all templates.
callback
- executed after task is completed. required- standard
callback(err, data)
err
- any error that occurreddata
- full response from request client
- standard
- find(options, callback)
Retrieve details about a specified template by its id
options.id
- the id of the template you want to look up requiredoptions.draft
- specifies a draft or published templatecallback
- see all function
- create(options, callback)
Create a new recipient list
options.template
- a template object requiredcallback
- see all function
- delete(id, callback)
Delete an existing template
id
- the id of the template you want to delete requiredcallback
- see all function
- preview(options, callback)
Preview the most recent version of an existing template by id
options.id
- the id of the template you want to look up requiredoptions.data
- Object of substitution dataoptions.draft
- specifies a draft or published templatecallback
- see all function
var SparkPost = require('sparkpost');
var client = new SparkPost('YOUR_API_KEY');
client.templates.all(function(err, data) {
if(err) {
console.log(err);
return;
}
console.log(data.body);
});
Check out all the examples provided here.