1

I want to create a version of a dynamic template using SendGrid's Python API. I was able to create the template using the Python API, but I want to add a version to the same template.

Can someone refer any examples ?

Thanks

lizziepika
  • 3,231
  • 1
  • 14
  • 23
Lucifer
  • 11
  • 3

1 Answers1

1

I am not 100% sure but this sample from the documentation also mentions "dynamic templates". So it might be able to help you.

import os
from sendgrid import SendGridAPIClient


sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'), impersonate_subuser = "The subuser's username. This header generates the API call as if the subuser account was making the call.")

template_id = "6f240bf5-d42d-4e4c-b159-82c1a82c1e87"
data = {
    "template_id": "Excepteur Ut qui",
    "active": 1,
    "name": "pariatur non incididunt commodo",
    "html_content": "dolor",
    "generate_plain_content": false,
    "subject": "aliquip nulla Ut",
    "editor": "design",
    "plain_content": "labore dolore"
}

response = sg.client.templates._(template_id).versions.post(
    request_body=data
)

print(response.status_code)
print(response.body)
print(response.headers)
IObert
  • 2,118
  • 1
  • 10
  • 17