A collection of methods related to the Workflows API
Methods
-
Create a new workflow
Name Type Description workflowBodyobject See developer docs for examples of workflow JSON
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.workflows.createWorkflow(workflowBody).then(response => console.log(response)); -
Delete an existing workflow
Name Type Description idint The ID of the workflow you wish to delete
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.workflows.deleteWorkflow(workflowBody).then(response => console.log(response)); -
Enroll a contact in a workflow
Name Type Description optsobject Contact & workflow options
Properties:
Name Type Description opts.workflowIdint The ID of the workflow you want to enroll the contact to.
opts.emailint The email address of the contact you wish to enroll.
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.workflows.enrollContact(opts).then(response => console.log(response)); -
Get all workflows
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.workflows.getAll().then(response => console.log(response)); -
Get workflow enrollments for the specified contact ID
Name Type Description idint Contact id to retrieve enrollments for
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.workflows.getEnrollments(id).then(response => console.log(response)); -
Get workflow by ID
Name Type Description workflowIdint Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.workflows.getWorkflow(workflowId).then(response => console.log(response)); -
Get a list of log events for a contact by workflow. For more information, checkout the developer docs.
Name Type Description optsobject Filtering options
Properties:
Name Type Description opts.vidint The contact ID to filter on
opts.workflowIdint The ID of the workflow you want to get log events for
opts.typesint An array of event types
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.workflows.getWorkflowEventLog({ vid: 1283719823 workflowId: 123239681612, types: ['ENROLLED'] }).then(response => console.log(response)); -
Unenroll a contact from a workflow
Name Type Description optsobject Contact & workflow options
Properties:
Name Type Description opts.workflowIdint The ID of the workflow you want to unenroll the contact from.
opts.emailint The email address of the contact you wish to unenroll.
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.workflows.unenrollContact(opts).then(response => console.log(response)); -
Update an existing workflow
Name Type Description workflowBodyobject See developer docs for examples of workflow JSON
Properties:
Name Type Description opts.idint The ID of the workflow you want to update.
opts.portalIdint The ID of the portal that the workflow resides on
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.workflows.updateWorkflow(workflowBody).then(response => console.log(response));