Skip to main content

Prerequisites

To follow along this guide you’ll need to get your bearer token from HubSpot. You can find the instructions on how to get it here. Remember to correctly set the Read/Write actions depending on wether you want to be able to update that information using the API step from Hilos or not.

Create a deal

If you want to update a deal via a Hilos Flow, you can use a combination of the API step and the HubSpot Deals API. To create a new deal from an Hilos flow you need to make a POST request to /crm/v3/objects/deals endpoint with the properties of your pipeline, for example:
{
  "properties": {
    "amount": "1500.00",
    "closedate": "2019-12-07T16:50:06.678Z",
    "dealname": "New deal",
    "pipeline": "default",
    "dealstage": "contractsent",
    "hubspot_owner_id": "910901"
  }
}
You can view the properties of your pipeline by making a GET request to /crm/v3/properties/deals endpoint using HTTPie, cURL or Postman.
You can associate a deal with a company by adding the associations property to the request:
Remember you can use the results from the API step as a variable for a later step in your flow. This allows you to easily update the information according to a previous result, however when testing you might need to hardcode the values to make sure the request is successful. Then before publishing change the hardcoded values to the variables.
{
  "properties": {
    "amount": "1500.00",
    "closedate": "2019-12-07T16:50:06.678Z",
    "dealname": "New deal",
    "pipeline": "default",
    "dealstage": "contractsent",
    "hubspot_owner_id": "910901"
  },
  "associations": [
    {
      "to": {
        "id": 201
      },
      "types": [
        {
          "associationCategory": "HUBSPOT_DEFINED",
          "associationTypeId": 5
        }
      ]
    },
    {
      "to": {
        "id": 301
      },
      "types": [
        {
          "associationCategory": "HUBSPOT_DEFINED",
          "associationTypeId": 3
        }
      ]
    }
  ]
}
The association can be something like a company, contact, or activity.

Retrieve and update a deal

To update a deal first you need to know the deal ID, to get it you can make a GET request to /crm/v3/objects/deals endpoint to see the active deals. You can include the following query parameters to filter results and make it easier to use:
  • properties: A comma separated list of the properties to be returned in the response. If the requested deal doesn’t have a value for a property, it will not appear in the response.
  • propertiesWithHistory: A comma separated list of the current and historical properties to be returned in the response. If the requested deal doesn’t have a value for a property, it will not appear in the response.
  • associations: A comma separated list of objects to retrieve associated IDs for. Any specified associations that don’t exist will not be returned in the response. Learn more about the associations API.
Once you have the deal ID you want to update you can make a PATCH request to /crm/v3/objects/deals/{dealId} and include the data you want to update.