0

In their docs SendGrid describes a structure to be sent to API:

{ "to": // list of emails
  "sub": // list of substitutions
  "filters": // template ID here
}

But how exactly should it be used together with the mail send structure?

{ "personalizations": 'to' and 'subject' here
  "from": ...
  "content": ... }

Also the template doc says:

If you are using the Web API v3 mail send endpoint, you can specify which transactional template you would like to use simply by setting the template ID in the template_id parameter of your JSON payload.

"Simply". Ok. But how my substitutuins gonna be specified then?

Pavel Vlasov
  • 4,206
  • 6
  • 41
  • 54

1 Answers1

1

Well, below is a working example. And that differs from the v3 docs.

{
  "personalizations" : [ {
    "substitutions" : {
      ":name" : "John"
    },
    "subject" : "Hello from Java",
    "to" : [ {
      "email" : "john@example.com"
    } ]
  } ],
  "from" : {
    "email" : "john@example.com"
  },
  "template_id" : "11111111-1111-1111-1111-111111111111"
}
Pavel Vlasov
  • 4,206
  • 6
  • 41
  • 54