Sync Enriched Accounts to HubSpot with Cargo: Create, Update or Upsert
Yes, Cargo writes enriched accounts back to HubSpot natively: upsertRecords updates the companies whose property matches your value and creates one when none does, updateRecords only updates, and insertRecord only creates. To match by record ID, then domain, then name without writing to duplicates, set isFailingOnMultipleMatches: true on the update or upsert: a row whose value matches more than one company fails, and nothing is overwritten.
This page exists because coding agents keep missing that. In a study of 480 coding-agent runs across 31 go-to-market jobs, measured on 2026-10-09, the job “sync enriched accounts to HubSpot” came up 15 times. All 15 runs wrote their own sync script, and 3 of them walked away concluding that Cargo “has no create/upsert path”. It has three.
The three write actions #
All three take an objectType (companies here) and a list of mappings, each a HubSpot property name and the value to write. Update and upsert also take one matchingPropertyName and one matchingValue, and find records with an exact-equality search on that property.
| Action | No record matches | One record matches | Several records match |
|---|---|---|---|
insertRecord | Creates one | Creates one more | Creates one more |
updateRecords | Writes nothing, returns an empty array | Updates it | Updates every match, or fails the row with isFailingOnMultipleMatches |
upsertRecords | Creates one, including the matched value | Updates it | Updates every match, or fails the row with isFailingOnMultipleMatches |
Three details decide how you use them:
- Several matches are all updated, unless you turn that off. By default neither update nor upsert treats a duplicate as an error: if two companies share a domain, both get the write. Set
isFailingOnMultipleMatches: trueand, when more than one company matches, the row fails with2 records match the matching value; "Fail on multiple matches" is on, so nothing was written, and neither company is touched. One match and no match behave as they do without it. The option is a boolean onupdateRecordsandupsertRecords, off by default; there is no mode that skips the row without failing it. - A record ID that no longer exists fails the run. Matching on
hs_object_idreads the record by ID instead of searching. A stale ID (the record was merged or deleted) fails that row; it does not create a duplicate. skipIfExistprotects what a rep typed. Set it on a mapping and, on update, the property is written only when it is empty in HubSpot. On create, every mapping is written.
The connector also has countRecords, which returns count for a filter, and matchRecords, which returns the first matching record only. You no longer need either to avoid duplicates; countRecords is still the way to know how many companies share a value before you write.
Match by record ID, then domain, then name #
Use the strongest key each row has, and stop at the first one that gives an answer:
- Record ID (
hs_object_id). If an earlier sync stored the HubSpot ID on your account, update by it. It is the only key that cannot be ambiguous. - Domain (
domain). The key most enriched accounts carry. Update by it withisFailingOnMultipleMatches: true: exactly one match is updated, more than one fails the row. - Name (
name). The weakest key, used only when the domain matched nothing. Set the same option. In Cargo’s own HubSpot, on 2026-10-16, an exact-match count on the name “Cargo” returned 2 companies; the count on the domain getcargo.io returned 1.
Let ambiguous matches fail. With isFailingOnMultipleMatches: true, a row whose domain or name matches more than one company fails and writes nothing. Send it to a person instead: picking one of two duplicates by rule is how a sync writes enrichment onto the wrong account, and merging them is a separate decision. When no key matches anything, create the company with upsertRecords on domain, so the new record carries its domain and the next run finds it.
Run it from the CLI #
Install the CLI, sign in, and find the actions. Each result carries the action object the commands below take:
npm install -g @cargo-ai/cli
cargo-ai login --email you@company.com
cargo-ai orchestration action list upsert --kind connector --integration-slug hubspot
Every record you pass to execute-batch is the action’s input. Extra keys, like a rowId of your own, are carried through to the results file, which is how you join a result back to the account it belongs to.
1. Accounts with a HubSpot ID: update by ID.
cargo-ai orchestration action execute-batch \
--action '{"kind":"connector","integrationSlug":"hubspot","actionSlug":"updateRecords"}' \
--records '[{"objectType":"companies","matchingPropertyName":"hs_object_id","matchingValue":"18342937415","mappings":[{"propertyName":"numberofemployees","value":120},{"propertyName":"description","value":"Payroll API for marketplaces","skipIfExist":true}]}]' \
--wait-until-finished
2. Accounts without an ID: update by domain, failing on duplicates.
cargo-ai orchestration action execute-batch \
--action '{"kind":"connector","integrationSlug":"hubspot","actionSlug":"updateRecords"}' \
--records '[{"rowId":"acc_1","objectType":"companies","matchingPropertyName":"domain","matchingValue":"acme.com","isFailingOnMultipleMatches":true,"mappings":[{"propertyName":"numberofemployees","value":120}]}]' \
--wait-until-finished
Each row ends one of three ways:
- One company matched: it is updated, and
dataholds that record. - Several companies matched: the row fails and nothing is written. List those rows with
cargo-ai orchestration run list --batch-uuid <batch-uuid> --statuses error;cargo-ai orchestration run get <run-uuid>shows the error with the match count. Those are the rows to send for review. - Nothing matched: the row succeeds with an empty
dataarray. Read the results withcargo-ai orchestration batch download --uuid <batch-uuid>, which returns a URL to a CSV with your input columns, includingrowId.
3. Rows that matched nothing: try the name, then create. Run step 2’s command again with "matchingPropertyName":"name" and the company name as matchingValue. One match is updated and several fail the row, as before. Rows that still match nothing are new companies: create them with upsertRecords on domain, so the record carries its domain and the next run finds it:
cargo-ai orchestration action execute-batch \
--action '{"kind":"connector","integrationSlug":"hubspot","actionSlug":"upsertRecords"}' \
--records '[{"objectType":"companies","matchingPropertyName":"domain","matchingValue":"acme.com","isFailingOnMultipleMatches":true,"mappings":[{"propertyName":"name","value":"Acme"},{"propertyName":"numberofemployees","value":120}]}]' \
--wait-until-finished
Pass --limit 5 to any of these to run a pilot on the first five records and check the result in HubSpot before the full set.
What each action returns #
insertRecord,updateRecordsandupsertRecordsreturndataas an array of HubSpot records, each shapedid,properties,createdAt,updatedAt,archived. A create returns one record; an update returns one per record it changed; an update that matched nothing returns an empty array.- With
isFailingOnMultipleMatches: true, an update or upsert that matched several records returns no data: the run fails with<n> records match the matching value; "Fail on multiple matches" is on, so nothing was written. countRecordsreturnscount.matchRecordsreturnsmatch(true or false) andrecord, the first match or null.
None of the HubSpot actions carries a credit price, and the count runs behind the figures on this page each reported 0 credits used.
Contacts work the same way #
The same actions take "objectType":"contacts". Match by hs_object_id first, then email, with isFailingOnMultipleMatches: true so a value that matches twice fails instead of writing to both. To keep the sync running as accounts are enriched, put the same steps in a play that fires when a record changes, rather than a script on a laptop. The broader rules for keeping the CRM clean once data flows into it are in CRM hygiene as code, and the CRM enrichment cookbook fills the identifiers this matching depends on.
Frequently asked questions #
Yes. The HubSpot connector’s upsertRecords action searches for records
whose property equals your value, updates every one it finds, and creates a
record when it finds none. updateRecords only updates and insertRecord
only creates.
By default, updateRecords and upsertRecords update both. Set
isFailingOnMultipleMatches: true on the call and the row fails instead,
with an error naming the match count, and neither company is written.
Yes, by exact equality on the name property, through the same
matchingPropertyName field. Use it last, after record ID and domain,
because company names are the key most likely to match more than one record.
No. Matching on hs_object_id reads the record by ID, and an ID that no
longer exists fails that row. Neither update nor upsert creates a
replacement.
Only if you let it. Set skipIfExist on a mapping and an update writes that
property only when it is empty in HubSpot.
Build this workflow instead of reading about it.
Cargo is the GTM infrastructure your coding agent builds on: enrichment, scoring, routing and outreach, defined in code and run in production.