Hi everyone!
I’m trying to create a task that would set the reminder from “No Reminder” to “1 day before”. May I know how I can do that with the updated endpoint?
I’ve visited the legacydocs but it seems like it does not work with the new API endpoint.: https://legacydocs.hubspot.com/docs/methods/engagements/create_engagement?_ga=2.50092449.627993952.1683551007-1667366231.1683551007
Here’s what I have:
const properties = {
hs_timestamp: hs_timestamp,
hs_task_body: hs_task_body,
hubspot_owner_id: “805242080”,
hs_task_subject: `New Contact {${req.body.firstName} ${req.body.lastName}}`,
hs_task_status: “WAITING”,
hs_task_priority: “HIGH”,
};
const SimplePublicObjectInputForCreate = {
properties,
associations: [
{
to: { id: req.body.contactId },
types: [
{ associationCategory: “HUBSPOT_DEFINED”, associationTypeId: 10 },
],
},
],
};
Hello @MG2023
To update the reminder for an engagement/task in HubSpot using the updated API endpoint, you can use the “Engagements API” which allows you to update an engagement/task by its ID.
Here is an example code snippet on how to update an engagement/task’s reminder from “No Reminder” to “1 day before”
const engagementId = "ENGAGEMENT_ID_HERE";
const updateData = {
engagements: [
{
id: engagementId,
metadata: {
taskReminder: {
type: "OFFSET",
offset: {
amount: 1,
unit: "DAY",
},
},
},
},
],
};
const options = {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${YOUR_ACCESS_TOKEN}`,
},
body: JSON.stringify(updateData),
};
fetch(`https://api.hubapi.com/engagements/v1/engagements/modify`, options)
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.log(error));
Replace “ENGAGEMENT_ID_HERE” with the actual ID of the engagement/task you want to update, and replace “YOUR_ACCESS_TOKEN” with your actual HubSpot API access token.
This code sends a PATCH request to the “Engagements API” endpoint with the ID of the engagement/task you want to update, and the metadata object that specifies the taskReminder as an offset of 1 day before the due date. This will update the task’s reminder to 1 day before the due date.