Sage 100 HubSpot integration: balances and orders on company records
Show Sage 100 open balance, credit hold and last order on HubSpot company records, with a field map and a working sync script.
Sales teams ask for one thing from a Sage 100 HubSpot integration: before I call this customer, tell me if they owe us money. That means a few Sage fields on each HubSpot company record, kept fresh. This guide shows the field map, how to match records, and a short script that does the sync.
What to sync
Most teams need a handful of fields, read-only, from Sage into HubSpot. Resist syncing everything; fields nobody looks at still cost API calls.
| HubSpot company property | Source in Sage 100 | API field |
|---|---|---|
sage_customer_key | ARDivisionNo + CustomerNo | division + customer_no |
sage_open_balance | AR_Customer.CurrentBalance | balance |
sage_credit_limit | AR_Customer.CreditLimit | credit_limit |
sage_credit_hold | AR_Customer.CreditHold | credit_hold |
sage_overdue_61_plus | AR aging, 61+ day buckets | overdue_amount with overdue_days_gt=60 |
sage_last_activity | AR_Customer.DateLastActivity | last_activity |
Matching records
The reliable key is the Sage customer key: division plus customer number, for example 01-NORTHFLD. Store it in a custom HubSpot property once (by hand or from a CSV import), then match on it. Matching by company name breaks the first time someone types "Inc." differently. Matching by domain fails for customers who use a generic email provider.
Create the properties once:
curl -X POST https://api.hubapi.com/crm/v3/properties/companies \
-H "Authorization: Bearer $HUBSPOT_TOKEN" -H "Content-Type: application/json" \
-d '{"name":"sage_open_balance","label":"Sage open balance","type":"number","fieldType":"number","groupName":"companyinformation"}'The sync script
This Python script reads customers with a balance from the Greenbar sandbox, finds each HubSpot company by sage_customer_key, and updates the balance fields. Run it every hour with cron or a scheduled task.
import os, requests
SAGE = "https://api.greenbar.octor.top/v1/companies/ABC"
SAGE_H = {"Authorization": "Bearer sk_test_demo"}
HS = "https://api.hubapi.com/crm/v3/objects/companies"
HS_H = {"Authorization": f"Bearer {os.environ['HUBSPOT_TOKEN']}", "Content-Type": "application/json"}
def sage_customers():
url, params = f"{SAGE}/customers", {"limit": 100}
while True:
page = requests.get(url, headers=SAGE_H, params=params, timeout=30).json()
yield from page["data"]
if not page["has_more"]:
break
params["cursor"] = page["next_cursor"]
def find_company(key):
body = {"filterGroups": [{"filters": [{"propertyName": "sage_customer_key", "operator": "EQ", "value": key}]}], "limit": 1}
res = requests.post(f"{HS}/search", headers=HS_H, json=body, timeout=30).json()
return res["results"][0]["id"] if res.get("results") else None
for c in sage_customers():
key = f"{c['division']}-{c['customer_no']}"
company_id = find_company(key)
if not company_id:
continue
props = {"sage_open_balance": c["balance"], "sage_credit_limit": c["credit_limit"],
"sage_credit_hold": str(c["credit_hold"]).lower(), "sage_last_activity": c["last_activity"]}
requests.patch(f"{HS}/{company_id}", headers=HS_H, json={"properties": props}, timeout=30).raise_for_status()Making it production-safe
- Only send changes. Keep the last values you sent and skip companies whose numbers did not move. HubSpot API limits are per app; a full sync of every company every hour wastes them.
- Handle rate limits. Retry on HTTP 429 with a short back-off.
- Keep it one-way. Sage stays the source of truth for financial fields. Letting reps edit a balance in HubSpot and pushing it back is how ledgers get corrupted.
- Log the key, not the customer. Logs that contain balances and names become sensitive data.
Going the other way
Creating a Sage customer or sales order when a HubSpot deal closes is a write, and writes in Sage 100 go through BOI so pricing, tax and credit rules apply. That is the harder half of a HubSpot integration and the part most teams buy rather than build.
curl "https://api.greenbar.octor.top/v1/companies/ABC/customers?balance_gt=0&limit=5" \ -H "Authorization: Bearer sk_test_demo"
A REST API for Sage 100, self-serve
One HTTPS endpoint and a typed SDK instead of BOI scripts and ODBC DSNs on every customer's server. Read access is free during the beta.
Join the waitlist