Customised Email subject line

I’m using a transactional email (Save for single-send API). Here I want to set a subject line with custom values.
for example, subject line is: Hello {{ personalization_token(“contact.firstname”, “”) }}, Would you like to join our group {{group_name}} ?

this group_name is dynamic value and is coming from API call request body. Is there any provision to set this type of dynamic values?

Any help will be appreciated.

Welcome, @unnati.

Yes, it’s the same convention outlined here for custom properties in the body of single-send emails.

In your case, your subject line would be:

Hello {{contact.firstname}}, Would you like to join our group {{custom.group_name}}?

contact.firstname would populate with “John” and custom.group_name with “Cool Group” if you sent the following request to the Single-send API:

POST
https://api.hubapi.com/email/public/v1/singleEmail/send

{
 "emailId": 123456789,
 "message": {
 "to": "example@hubspot.com"
 },
 "contactProperties": [
 {
 "name": "firstname",
 "value": "John"
 }
 ],
 "customProperties": [
 {
 "name": "group_name",
 "value": "Cool Group"
 }
 ]
}