HubSpot OAuth
JsWorkflows provides a platform-managed HubSpot OAuth app — you do not need to create a HubSpot app or provide credentials.
Available scopes
Section titled “Available scopes”| Resource | Operation | Scope |
|---|---|---|
| Contacts | Read contacts | crm.objects.contacts.read |
| Contacts | Create/update/delete contacts | crm.objects.contacts.read, crm.objects.contacts.write |
| Companies | Read companies | crm.objects.companies.read |
| Companies | Create/update/delete companies | crm.objects.companies.read, crm.objects.companies.write |
| Deals | Read deals | crm.objects.deals.read |
| Deals | Create/update/delete deals | crm.objects.deals.read, crm.objects.deals.write |
| Marketing Email | Read/send marketing emails | marketing-email |
| Files | Access file manager | files |
| Tickets | Read/manage tickets | tickets |
| Automation | Manage workflows & sequences | automation |
Connecting
Section titled “Connecting”- Go to OAuth Connections → Add Connection → HubSpot.
- Select the resources and operations your workflow needs.
- Sign in with your HubSpot account and grant the requested permissions.
- 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, }, }), }); }}Example — create a deal
Section titled “Example — create a deal”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', }, }),});