Office hours: Build your self-driving GTM engine·Oct 29, 9:00am PT, onlineRegister→
Cargo
  • PrimitivesData ModelsYour companies, contacts and deals, merged from every sourceContextWhat your team knows, as files every agent readsTerritoriesWho sells where, defined onceMailboxesMailboxes in your reps' names, warmed up and kept under limitsToolsThe actions your agents, plays and reps callAgentsAI that researches, decides and writes, reading your contextPlaysWorkflows that run on a trigger or a schedule, with retriesAppsInternal apps for your reps, hosted on Cargo
    Add-onsChrome ExtensionSell faster, right in your browserButtonTrigger AI agents inside your CRMFormTurn any tool into an embeddable formSlackTag Cargo in Slack. It does the GTM workGitHubPlan on every pull request, deploy on merge
    MoreProjectsDefine your entire GTM in codeCLIUse Cargo from your terminalMCPUse Cargo from Claude and ChatGPTDeveloper resourcesCargo API docs, OpenAPI spec, auth docs, webhooks, MCP serverAPI ReferenceExplore the Cargo APIDocumentationLearn how to use CargoIntegrationsConnected to your entire GTM stack
  • VeriffHow Veriff replaced MuleSoft with Cargo under NetSuite, Stripe and SalesforceAugmentHow Augment Code routes developer sign-ups to reps in under an hourWeights & BiasesHow Weights & Biases ships a new purchase signal in 2 days on CargoSee all
  • Pricing
  • Cookbooks
  • Blog
Sign in
Blog

Sync Enriched Accounts to HubSpot with Cargo: Create, Update or Upsert

22 Oct6min read
AurelienAurelien

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.

ActionNo record matchesOne record matchesSeveral records match
insertRecordCreates oneCreates one moreCreates one more
updateRecordsWrites nothing, returns an empty arrayUpdates itUpdates every match, or fails the row with isFailingOnMultipleMatches
upsertRecordsCreates one, including the matched valueUpdates itUpdates 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: true and, when more than one company matches, the row fails with 2 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 on updateRecords and upsertRecords, 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_id reads 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.
  • skipIfExist protects 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:

  1. 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.
  2. Domain (domain). The key most enriched accounts carry. Update by it with isFailingOnMultipleMatches: true: exactly one match is updated, more than one fails the row.
  3. 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:

shellscript
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.

shellscript
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.

shellscript
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 data holds 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 data array. Read the results with cargo-ai orchestration batch download --uuid <batch-uuid>, which returns a URL to a CSV with your input columns, including rowId.

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:

shellscript
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, updateRecords and upsertRecords return data as an array of HubSpot records, each shaped id, 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.
  • countRecords returns count.
  • matchRecords returns match (true or false) and record, 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.

~/run-it-on-cargo/

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.

Start building
AurelienAurelienOct 22, 2026
On this page
  • The three write actions
  • Match by record ID, then domain, then name
  • Run it from the CLI
  • What each action returns
  • Contacts work the same way
  • Frequently asked questions

Stay Informed with our
weekly Newsletter

Related articlesSee all articles
Data & Infrastructure
Sync Enriched Records to Pipedrive with Cargo: Create, Update or Upsert

Cargo's Pipedrive connector creates, updates and upserts organizations, persons, deals and leads natively. How it matches on the one field you choose, how to make it fail instead of overwriting when several records match, and the cargo-ai commands to run the sync.

AurelienAurelien·Oct 23, 2026
Data & Infrastructure
Sync Enriched Records to Salesforce with Cargo: Create, Update or Upsert

Cargo's Salesforce connector creates, updates and upserts records natively. How to match accounts by record Id, then website, then name, fail on ambiguous matches instead of overwriting duplicates, and run the sync from the cargo-ai CLI.

AurelienAurelien·Oct 22, 2026
Data & Infrastructure
Build a TAM List by Industry, Headcount and Geography

How go-to-market teams and their coding agents build a total addressable market list with Cargo: count the market for free, then pull the companies at 0.01 credits each, with name, domain, industry, headcount and country. Commands, prices, fields, and how to keep it as a model.

AurelienAurelien·Oct 16, 2026

Build the self-driving GTM engine

Your coding agents build it on Cargo.Or our team builds, operates and improves it with you.

Start building
Cargo
Backed byY CombinatorSOC 2 Type IICertified
LinkedinX

Product

Data ModelsContextTerritoriesMailboxesToolsAI AgentsPlaysAppsIntegrationsPricing

Add-ons

Chrome extensionButtonFormSlackGitHub

Build

DocsDeveloper resourcesCargo API docsCargo OpenAPI specCargo auth docsCargo webhooksCargo MCP serverProjectsClaude CodeCodexCursorAll coding agents

Resources

ReportsBlogCustomer storiesCookbooksEnrichmentRoutingSignalsScoringCRM hygieneAd audiencesGTM skillsGTM EngineeringGlossaryCompareCargo x ClayCargo x WorkatoCargo x n8nCargo x DeeplineCargo x DefaultCargo x LeanDataCargo x UnifyCargo x ValleyCargo x Gojiberry

Company

ManifestoCommunityEventsJobsPartners DirectoryPartner Program

Legal

SecurityTerms of servicePrivacy PolicyRefundsDPASupport
© 2026 Cargo
 ////////    ///////    ////////     ////////    ///////
///         ///   ///   ///   ///   ///         ///   ///
///         ///   ///   ///   ///   ///         ///   ///
///         /////////   ////////    ///  ////   ///   ///
///         ///   ///   /// ///     ///   ///   ///   ///
///         ///   ///   ///  ///    ///   ///   ///   ///
 ////////   ///   ///   ///   ///    ///////     ///////

$ npm install -g @cargo-ai/cli