Templates

Let’s use the underlying templates API to create a template:

from sparkpost import SparkPost

sp = SparkPost()

response = sp.templates.create(
    id='TEST_ID',
    name='Test Template',
    from_email='test@test.com',
    subject='Test email template!',
    html='<b>This is a test email template!</b>'
)

print response
# outputs {u'id': u'TEST_ID'}

Retrieve a template

from sparkpost import SparkPost

sp = SparkPost()

sp.templates.get('my-template-id')

List all templates

from sparkpost import SparkPost

sp = SparkPost()

sp.templates.list()

API reference

sparkpost.templates

Further examples

See the python-sparkpost templates examples.

Additional documentation

See the SparkPost Templates API Reference.