Skip to content

HubSpot OAuth

JsWorkflows provides a platform-managed HubSpot OAuth app — you do not need to create a HubSpot app or provide credentials.

ResourceOperationScope
ContactsRead contactscrm.objects.contacts.read
ContactsCreate/update/delete contactscrm.objects.contacts.read, crm.objects.contacts.write
CompaniesRead companiescrm.objects.companies.read
CompaniesCreate/update/delete companiescrm.objects.companies.read, crm.objects.companies.write
DealsRead dealscrm.objects.deals.read
DealsCreate/update/delete dealscrm.objects.deals.read, crm.objects.deals.write
Marketing EmailRead/send marketing emailsmarketing-email
FilesAccess file managerfiles
TicketsRead/manage ticketstickets
AutomationManage workflows & sequencesautomation
  1. Go to OAuth Connections → Add Connection → HubSpot.
  2. Select the resources and operations your workflow needs.
  3. Sign in with your HubSpot account and grant the requested permissions.
  4. Give the connection a handle (e.g., my-hubspot).

Access tokens are refreshed automatically when they expire.

Example — create a contact from a Shopify order

Section titled “Example — create a contact from a Shopify order”
class Workflow {
async start(data, headers, api) {
const { token, error } = await api.getOAuthToken('my-hubspot');
if (error) { api.log('OAuth error:', error); return; }
const customer = data.customer;
await fetch('https://api.hubapi.com/crm/v3/objects/contacts', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`,
},
body: JSON.stringify({
properties: {
email: customer.email,
firstname: customer.first_name,
lastname: customer.last_name,
},
}),
});
}
}
const { token } = await api.getOAuthToken('my-hubspot');
await fetch('https://api.hubapi.com/crm/v3/objects/deals', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`,
},
body: JSON.stringify({
properties: {
dealname: `Order ${data.name}`,
amount: data.total_price,
dealstage: 'closedwon',
},
}),
});