I am trying to get the contact list and check if the email recipient opened the email or not. I found this code and tried but got 401.
import config from "@server/config"
sgClient.setApiKey(config.sendgridKey)
const headers = {
"on-behalf-of": "my account user name" // I put my account user name here
}
const request = {
url: `/v3/subusers`,
method: "GET"
} as any
const list = await sgClient
.request(request)
.then()
.catch((err) => {
console.log("list", err.response.body)
})
What do I need to put for the header 'on-behalf-of'? What does the subuser's user name? And is there any example to get the 'email opened' event? I am using Node.js.
Thank you!