API email with dynamic fields

Hi,

I am a developer, I want to send an email using PHP that the template of the email is inside Hubspot with dynamic fields.
For example, the start of the email is:
Hi {name},
I want to change the {name} from the PHP code.

How can I achive it?

Hi @Music

I have share a curl hope this could help you resolve your query and a link for your reference.

curl --request POST \
 --url https://api.hubapi.com/marketing/v4/email/single-send \
 --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
 --header 'content-type: application/json' \
 --data '{
 "emailId": 0,
 "message": {
 "cc": [
 "string"
 ],
 "sendId": "string",
 "bcc": [
 "string"
 ],
 "replyTo": [
 "string"
 ],
 "from": "string",
 "to": "string"
 },
 "contactProperties": {
 "firstname": "XYZ",
 "lastname": "Hello",
 "email": "test@example.com"
 }
}'

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!