Sub topic 2
Deals, pipelines and stages
This chapter covers how a CRM models a sale in progress. It shows how to create a deal and move it through a pipeline, and which settings decide what a stage means. It assumes you know the basic B2B sales flow (lead, qualification, proposal, close) and can read JSON. The Python and Apex examples are optional.
What a deal is
A deal is one potential sale to one buyer. HubSpot calls the record a deal. Salesforce calls it an Opportunity. Both are records of a standard object, linked to the company and contacts involved. The linking itself is covered in a later chapter.
A deal answers four questions:
- What are we selling, and to whom? (name, company, contacts)
- How much is it worth? (amount)
- When do we expect it to close? (close date)
- How far along is it? (stage)
Everything else, such as notes, calls and emails, hangs off the deal as activity. If the deal record is wrong, every report built on it is wrong too.
| Concept | Salesforce | HubSpot |
|---|---|---|
| Object name | Opportunity | Deal |
| Name field | `Name` | `dealname` |
| Stage field | `StageName` | `dealstage` |
| Value field | `Amount` | `amount` |
| Expected close | `CloseDate` | `closedate` |
| Grouping of stages | Sales Process (per record type) | Pipeline |
| Win/loss flags | `IsClosed`, `IsWon` | Stage metadata `isClosed`, `probability` |
Pipelines and stages
A stage is a named step in your sales process, such as "Qualification" or "Proposal sent". A pipeline is the ordered set of stages a deal moves through. Teams use different pipelines when their sales motions differ, for example new business and renewals.
HubSpot
HubSpot supports several pipelines for deals. Each pipeline has its own stages. A deal belongs to exactly one pipeline and sits in one stage of it. Each stage has:
- a label, which is what people see in the UI,
- an internal ID, which is what the API uses,
- a deal probability, a percentage used for weighted forecasts,
- a closed state: closed won or closed lost.
In a default account the first pipeline has the internal ID default. Its stage IDs include appointmentscheduled, qualifiedtobuy, presentationscheduled, decisionmakerboughtin, contractsent, closedwon and closedlost. Admins can rename stages, add stages or create new pipelines. Renaming changes the label but not the internal ID. Pipelines you create yourself get generated IDs, usually numeric.
Salesforce
Salesforce stores stages as values of the StageName picklist on Opportunity. Three settings control how they behave:
- Sales Process decides which stage values a given kind of opportunity can use. It is attached to a record type.
- Record types let you run separate processes, such as new business and renewal, on the same object. A record type plays the role of a HubSpot pipeline.
- Each stage value is mapped to a probability, a forecast category (Pipeline, Best Case, Commit, Closed or Omitted), and a closed or won flag.
The standard picklist runs from Prospecting through Qualification, Needs Analysis, Value Proposition, Id. Decision Makers, Perception Analysis, Proposal/Price Quote and Negotiation/Review, ending in Closed Won and Closed Lost. Most teams trim it to fit their process.
How stage drives other fields
A stage is not just a label. In both systems it sets values that other parts of the CRM read.
- Probability. Changing the stage usually resets the deal's probability to the stage default. Weighted pipeline is
amount × probability, so a stage change moves your forecast. - Open or closed. Closed Won and Closed Lost end the deal. Open-pipeline reports leave closed deals out.
- Forecast category (Salesforce). The stage maps to a category used in forecast roll-ups.
- Close date behaviour. On closing, Salesforce does not change
CloseDatefor you in a reliable way. Treat it as a field you maintain yourself. HubSpot records when the deal entered each stage, which you can use for stage-duration reports.
The next chapter covers keeping amount and close date current. Here the point is that picking a stage means choosing a probability and a report bucket.
A typical deal path
Deals can also move backward. A buyer may return to evaluation after a proposal, and a rep may correct a stage set by mistake. Both CRMs allow this by default. Some teams add rules to block it, for example a validation rule in Salesforce or required properties in HubSpot.
Creating a deal in the UI
The steps differ in detail, but the order is the same in both CRMs:
- Open the Deals (HubSpot) or Opportunities (Salesforce) tab and choose to create a new record.
- Fill in the required fields. HubSpot needs a name, a pipeline and a stage. Salesforce needs a name, a stage and a close date.
- Select the pipeline or record type first. The stage list depends on it.
- Enter the amount and a realistic close date.
- Associate the company and at least one contact, so the deal appears on their records.
- Save, then check the deal in the board or list view.
Choosing the pipeline or record type first matters. In Salesforce, changing a record type later can invalidate the current stage. In HubSpot, moving a deal to another pipeline forces you to pick a stage in the new pipeline.
Creating a deal through the API
HubSpot
Stage IDs differ between accounts once a pipeline has been customized. Before writing a deal, read the real IDs from your account:
import os
import requests
url = "https://api.hubapi.com/crm/v3/pipelines/deals"
headers = {"Authorization": f"Bearer {os.environ['HUBSPOT_TOKEN']}"}
resp = requests.get(url, headers=headers, timeout=30)
resp.raise_for_status()
for pipeline in resp.json()["results"]:
print(pipeline["id"], pipeline["label"])
for stage in pipeline["stages"]:
prob = stage["metadata"].get("probability")
print(" ", stage["id"], stage["label"], prob)Then create the deal using IDs from that output:
import os
import requests
url = "https://api.hubapi.com/crm/v3/objects/deals"
headers = {
"Authorization": f"Bearer {os.environ['HUBSPOT_TOKEN']}",
"Content-Type": "application/json",
}
body = {
"properties": {
"dealname": "Acme - Annual Platform License",
"amount": "48000",
"pipeline": "default",
"dealstage": "appointmentscheduled",
"closedate": "2026-12-31T00:00:00Z",
}
}
resp = requests.post(url, headers=headers, json=body, timeout=30)
resp.raise_for_status()
print(resp.json()["id"])The response contains the new deal's ID. Keep it, because you need it to associate activities later. A stage ID that does not belong to the stated pipeline is rejected with a 400 error.
Salesforce
In Apex, an Opportunity needs a name, a stage and a close date:
Opportunity opp = new Opportunity(
Name = 'Acme - Annual Platform License',
StageName = 'Qualification',
CloseDate = Date.newInstance(2026, 12, 31),
Amount = 48000,
AccountId = accountId
);
insert opp;
System.debug(opp.Id);The stage name must exist in the picklist and be allowed for the opportunity's record type. Otherwise the insert fails with a validation error. If your org uses record types, set RecordTypeId explicitly so you do not depend on the running user's default.
Moving a deal between stages
In the UI, you drag the card on the HubSpot board, or use the path component or edit the stage field in Salesforce. Through the API, a stage change is an ordinary field update.
import os
import requests
deal_id = os.environ["DEAL_ID"]
url = f"https://api.hubapi.com/crm/v3/objects/deals/{deal_id}"
headers = {
"Authorization": f"Bearer {os.environ['HUBSPOT_TOKEN']}",
"Content-Type": "application/json",
}
body = {"properties": {"dealstage": "qualifiedtobuy"}}
resp = requests.patch(url, headers=headers, json=body, timeout=30)
resp.raise_for_status()
print(resp.json()["properties"]["dealstage"])Use PATCH, not PUT. PATCH changes only the properties you send. You can check a Salesforce stage move with SOQL:
SELECT Id, Name, StageName, Probability, IsClosed, IsWon
FROM Opportunity
WHERE Id = :opportunityIdWatch Probability and IsClosed in the result. They show how the stage change spread to other fields.
Edge cases and common errors
- Wrong stage ID. In HubSpot, IDs from one pipeline do not work in another. Always read stage IDs from the pipelines endpoint instead of copying them from another account or from documentation.
- Renamed stage, same ID. A label change in the UI does not change the internal ID, so old scripts keep working. A deleted stage breaks them.
- Close date in the past on an open deal. Both CRMs accept it. Reports then show the deal as overdue, and forecasts that filter by period leave it out. Set a rule or a weekly review to catch it.
- Skipping stages. Moving a deal from the first stage straight to Closed Won is allowed unless you block it. It leaves no stage history, so conversion reports show no steps in between.
- Closed Lost with no reason. Both CRMs let you close a deal without a reason. Make a loss reason required, because it is the data you will want later.
- Amount in the wrong currency. In multi-currency orgs, the amount is stored in the deal's currency and converted for reporting. Check the currency before comparing totals.
- Reopening a closed deal. You can move a closed deal back to an open stage. Probability resets, and the deal re-enters open pipeline reports. Do this on purpose, and note why in an activity.
Designing stages that work
Good stages describe what the buyer has done, not what the rep feels. "Buyer confirmed budget" is checkable. "Looking good" is not. A short checklist helps:
- Keep the count between five and eight open stages.
- Give each stage an exit criterion that someone could verify from the record.
- Match stage probabilities to real historical conversion, not guesses.
- Use one pipeline per distinct sales process, and no more.
Summary
A deal or opportunity is the record that carries a sale's name, value, expected close and stage. Stages belong to a pipeline in HubSpot and to a sales process and record type in Salesforce. A stage sets probability and open or closed state, so changing it changes the forecast. Read stage IDs from your account before using the API, and treat a stage change as a data change with consequences.
Exercise
A script creates a HubSpot deal with "pipeline": "default" and "dealstage": "renewalnotice", a stage ID copied from a colleague's separate renewals pipeline. The API returns a 400 error. What is the likely cause, and how do you find the right value?
Show answer
The stage ID does not belong to the default pipeline, and HubSpot validates that the stage is part of the pipeline named in the same request. Call GET /crm/v3/pipelines/deals to list each pipeline's ID and its stages' IDs. Then either use a stage from default, or set pipeline to the renewals pipeline's ID so that it matches the stage.
Exercise
In Salesforce, a rep moves an opportunity from Negotiation/Review to Closed Won. Name two other field values that change as a result, and say why a forecast report cares.
Show answer
Probability changes to the Closed Won default (100), and IsClosed and IsWon become true. The forecast category also becomes Closed. The forecast report cares because the amount leaves open pipeline and counts as closed revenue, so weighted pipeline and committed totals both change.