A collection of methods related to the Deals API
Methods
-
Update a group of deals
Name Type Description updatesarray Array of objects. objectId corresponds with a dealId. See Example below.
Returns:
Type Description Promise If successful the promise will resolve with { updated: true }. Otherwise the promise will resolve with an error message. Example
const hs = new HubspotClient(props); const updates = [{ "objectId": 93630457, "properties": [ { "name": "dealname", "value": "Updated Deal Name" }, { "name": "dealname", "value": "Updated Deal Name" } ]}, { "objectId": 26448234, "properties": [ { "name": "amount", "value": "2000" } ] }]); hs.deals.batchUpdate(updates).then(response => console.log(response)); -
Create or update a deal
Name Type Description optsobject Properties:
Name Type Description opts.idint opts.propertiesarray opts.associationsarray opts.includePropertyVersionsboolean Returns:
Type Description Promise Example
const hs = new HubspotClient(props); const updatedDealOpts = { id:93630457, properties: [ { value: 'Update Deal Name', name: 'dealname' }, { value: '200000', name: 'amount' } ]}; hs.deals.createOrUpdate(updatedDealOpts).then(response => console.log(response)); const newDealOpts = { associations: { associatedCompanyIds: 53333385 }, properties: [ { value: 'Big Deal', name: 'dealname' }, { value: 'appointmentscheduled', name: 'dealstage' }, { value: 'default', name: 'pipeline' }, { value: 1409443200000, name: 'closedate' }, { value: '60000', name: 'amount' }, { value: 'newbusiness', name: 'dealtype' } ] }; hs.deals.createOrUpdate(newDealOpts).then(response => console.log(response)); -
Get all deals
Name Type Description optsobject Properties:
Name Type Description opts.limitint opts.offsetint opts.propertiesarray opts.propertiesWithHistoryarray Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.deals.getRecentlyCreated({ limit: 2, offset: 12356, properties: ['dealname', 'pipeline'], propertiesWithHistory: ['dealstage'] }).then(response => console.log(response)); -
Get deal by ID
Name Type Description idint The id of the deal to retrieve
propertiesobject Optional extra properties to add to the request - see developer docs
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.deals.getById(123412313).then(response => console.log(response)) -
Get recently created deals
Name Type Description optsobject Properties:
Name Type Description opts.countint opts.offsetint opts.sinceint opts.includePropertyVersionsboolean Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.deals.getRecentlyCreated({ count: 50, offset: 5, includePropertyVersions: true, since: 1463680280365 }).then(response => console.log(response));