I’m working with HubSpot’s API using VBA to pull deal information. I can successfully get basic deal data but I’m stuck on something specific.
In HubSpot, you can set probability percentages for each pipeline stage (like setting “proposal sent” to 75% probability). I need to get these probability values through the API but I can’t find the right endpoint.
I’ve looked through their API docs but nothing jumps out at me. Has anyone figured out how to retrieve these stage probability settings programmatically?
Here’s my current code that gets basic deal info:
Sub FetchDealInfo()
Dim httpRequest As Object
Set httpRequest = CreateObject("MSXML2.ServerXMLHttp")
Dim apiUrl As String
Dim authToken As String
authToken = "your-access-token"
apiUrl = "https://api.hubapi.com/crm/v3/objects/deals"
httpRequest.Open "GET", apiUrl, False
httpRequest.setRequestHeader "Authorization", "Bearer " & authToken
httpRequest.setRequestHeader "Content-Type", "application/json"
httpRequest.send
Debug.Print httpRequest.responseText
End Sub
Any tips on where to look or which API endpoints might have this data would be really helpful. Thanks in advance!
Pipeline probability data isn’t stored with deal records - it’s in the pipeline configuration. You need a separate call to the pipelines endpoint like others mentioned, but they missed something important. When calling /crm/v3/pipelines/deals, include the pipeline ID parameter if you’re targeting specific pipelines. The probability values are nested in each stage object under “metadata”. I’ve found these values don’t always populate consistently across pipeline types, especially with migrated older HubSpot accounts. Some organizations disable probability tracking completely, so your VBA code needs to handle null or undefined values. Once you’ve got the pipeline data, create a lookup table matching stage IDs to probabilities - it’ll speed up processing.
hey, u can get the pipeline details from the /crm/v3/pipelines/deals endpoint. just loop through the pipelines and check the stages for prob values. i did this recently, and it worked like a charm!
Pipeline probability settings live at the pipeline level, not on individual deals. You’ll need to hit the pipelines endpoint first to grab that structure, then match it with your deal data. I’ve worked with HubSpot integrations before - the probability values come back as decimals (like 0.75 for 75%) in each stage object. Cache this pipeline data since it rarely changes. Don’t call it every time you need probabilities. Watch out for custom pipelines though. They can have totally different stage setups, so your VBA needs to handle multiple pipelines if your org uses them. The stage IDs from your deals will match the stage IDs in the pipeline response.
You’re using VBA to interact with the HubSpot API to retrieve deal information, but you’re struggling to obtain the probability percentages associated with each pipeline stage. Your current code successfully retrieves basic deal data, but it lacks the necessary API calls to access the stage probability settings.
TL;DR: The Quick Fix:
Don’t try to get pipeline stage probabilities from the deals endpoint. Instead, use the HubSpot API’s /crm/v3/pipelines/deals endpoint to retrieve pipeline configuration data. The probability values are nested within each stage object under the "metadata" key. Then, match these probabilities to your deal data using the stage IDs.
Understanding the “Why” (The Root Cause):
HubSpot separates deal data from pipeline configuration. The probability of a deal reaching a specific stage is a property of the pipeline itself, not the individual deal. Therefore, you need a separate API call to get pipeline stage probabilities, then use that data to enrich your deal information. Directly accessing this data from the deals endpoint isn’t possible; the deal endpoint only provides data about the deal, not the pipeline’s configuration data.
Step-by-Step Guide:
Fetch Pipeline Configuration: Modify your VBA code to call the /crm/v3/pipelines/deals endpoint. This endpoint returns details about your HubSpot pipelines, including stage probabilities. Remember to include necessary authentication (your authToken) and the pipelineId parameter if you need data for a specific pipeline. The response will be a JSON object. Here’s an example of how to adapt your existing VBA code:
Sub FetchPipelineInfo()
Dim httpRequest As Object
Set httpRequest = CreateObject("MSXML2.ServerXMLHttp")
Dim apiUrl As String
Dim authToken As String
Dim pipelineId As String ' Add pipelineId variable
authToken = "your-access-token"
pipelineId = "YOUR_PIPELINE_ID" ' Replace with your actual pipeline ID
apiUrl = "https://api.hubapi.com/crm/v3/pipelines/deals?pipelineId=" & pipelineId
httpRequest.Open "GET", apiUrl, False
httpRequest.setRequestHeader "Authorization", "Bearer " & authToken
httpRequest.setRequestHeader "Content-Type", "application/json"
httpRequest.send
Debug.Print httpRequest.responseText 'Inspect the JSON response
End Sub
Parse the JSON Response: The response from the API will be a JSON object containing pipeline information. You’ll need to parse this JSON to extract the stage ID and its associated probability (which will be a decimal, e.g., 0.75 for 75%). VBA offers various methods to parse JSON; consider using a library or writing custom parsing functions.
Create a Lookup Table: Create a VBA dictionary or array to store the stage IDs as keys and their corresponding probabilities as values. This will allow for efficient lookup during deal processing.
Integrate with Deal Data Retrieval: Once you have the pipeline probability data in your lookup table, modify your existing FetchDealInfo subroutine to use it. After fetching the deal data, use the stage ID from the deal record to find the matching probability in your lookup table.
Handle Missing Probabilities: Be prepared for situations where the probability is not defined for a given stage. Your code should gracefully handle Null or undefined values.
Common Pitfalls & What to Check Next:
Pipeline ID: Ensure you’re using the correct pipelineId. Incorrect IDs will lead to empty or unexpected results. Consult the HubSpot API documentation or your HubSpot account to find the correct ID for your pipeline.
API Rate Limits: HubSpot’s API has rate limits. If you’re making many requests, consider implementing error handling and retry logic to manage potential rate limit exceeding.
JSON Parsing Errors: VBA’s JSON parsing can be tricky. Thoroughly test your JSON parsing code to handle various JSON structures.
Data Consistency: Remember that probability values might not always be consistently populated across all pipeline types or organizations. Handle potential inconsistencies gracefully.
Still running into issues? Share your (sanitized) config files, the exact command you ran, and any other relevant details. The community is here to help!