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 Records to Salesforce with Cargo: Create, Update or Upsert

22 Oct6min read
AurelienAurelien

Yes, Cargo writes enriched go-to-market records back to Salesforce natively: upsertRecords updates the records whose field matches your value and creates one when none does, updateRecords only updates, and insertRecord only creates. To match by record Id, then website, then name without writing to duplicates, set isFailingOnMultipleMatches: true on the update or upsert: a row whose value matches more than one record fails, and nothing is overwritten. Website is the one key still checked with countRecords first, because the field holds URLs that an exact match misses.

Cargo platform data, 90 days to Oct 16 2026: salesforce.updateRecords ran 6.6M times across 37 workspaces.

The three write actions #

All three take an objectType (Account here) and a list of mappings, each a Salesforce field API name and the value to write. Update and upsert also take one matchingPropertyName and one matchingValue, and find records with a SOQL query on matchingPropertyName = matchingValue.

ActionNo record matchesOne record matchesSeveral records match
insertRecordCreates oneCreates one moreCreates one more
updateRecordsFails the row: “No records have been updated”Updates itUpdates every match, or fails the row with isFailingOnMultipleMatches
upsertRecordsCreates one, including the matched valueUpdates itUpdates every match, or fails the row with isFailingOnMultipleMatches

Four 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 accounts share a name, both get the write. The matches come from one page of SOQL results (up to 2,000 records) and are written in a single Salesforce update request, which accepts at most 200 records, so a value that matches more than 200 records fails the row instead of updating them. Set isFailingOnMultipleMatches: true and, when more than one record matches, the row fails with 2 records match the matching value; "Fail on multiple matches" is on, so nothing was written before anything is written. 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 stale Id fails the row. An Id that no longer exists (the record was merged or deleted) fails that row with No <object> record found with Id <id>, in both updateRecords and upsertRecords. Upsert never creates a new record from an Id match.
  • A partial failure is not a failed row. When several records match and some updates are rejected, the row succeeds and returns only the records that were updated. It fails only when none was.
  • skipIfExist protects what a rep typed. Set it on a mapping and, on update, the field is written only when it is empty in Salesforce. On create, every mapping is written.

The connector also has countRecords, which returns count for a filter, and matchRecord, which returns the first matching record only. Use countRecords for the website check below: a first match cannot tell you there was a second.

Match by record Id, then website, then name #

Use the strongest key each row has, and stop at the first one that gives an answer:

  1. Record Id (Id). If an earlier sync stored the Salesforce Id on your account, update by it. It is the only key that cannot be ambiguous.
  2. Website (Website). The Account Website field holds a URL as someone typed it (https://www.acme.com, acme.com/), not a bare domain, so an equality match on acme.com misses most of them. Count with the contains operator instead, then read the one match back with matchRecord to check its host really is your domain (contains also matches acme.com.au), and update it by Id. If your org keeps a normalized domain in a custom field, match on that with equality instead.
  3. Name (Name). The weakest key, used only when the website matched nothing. Write by it with isFailingOnMultipleMatches: true: exactly one match is updated, more than one fails the row.

Do not write ambiguous matches. A row whose website count is more than 1 is not written, and a row whose name matches more than one account fails with isFailingOnMultipleMatches: true and writes nothing. Send both 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, the upsert by Name creates the account; write its Website in the mappings so the next run finds it.

Run it from the CLI #

Install the CLI, sign in, check the Salesforce connector, 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 connection connector list --integration-slug salesforce
cargo-ai orchestration action list upsert --kind connector --integration-slug salesforce

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 count back to the account it belongs to.

1. Accounts with a Salesforce Id: update by Id.

shellscript
cargo-ai orchestration action execute-batch \
  --action '{"kind":"connector","integrationSlug":"salesforce","actionSlug":"updateRecords"}' \
  --records '[{"objectType":"Account","matchingPropertyName":"Id","matchingValue":"001Hs00003XyZabIAF","mappings":[{"propertyName":"NumberOfEmployees","value":120},{"propertyName":"Description","value":"Payroll API for marketplaces","skipIfExist":true}]}]' \
  --wait-until-finished

2. Accounts without an Id: count the matches by website.

shellscript
cargo-ai orchestration action execute-batch \
  --action '{"kind":"connector","integrationSlug":"salesforce","actionSlug":"countRecords"}' \
  --records '[{"rowId":"acc_1","objectType":"Account","filter":{"conjonction":"and","groups":[{"conjonction":"and","conditions":[{"propertyName":"Website","operator":"contains","values":["acme.com"]}]}]}}]' \
  --wait-until-finished

cargo-ai orchestration batch download --uuid <batch-uuid>

batch download returns a URL to a CSV: your input columns, including rowId, plus cargo_count. Note the spelling conjonction: it is the field name, and the filter is rejected without it.

3. Write each row by what the count said.

  • cargo_count is 1: run matchRecord with the same filter, check that record.Website is your domain, and run step 1’s command with record.Id as matchingValue.
  • cargo_count is more than 1: skip the row and list it for review.
  • cargo_count is 0: upsert by Name with isFailingOnMultipleMatches: true. One match is updated, several fail the row and write nothing, and none creates the account with its Website:
shellscript
cargo-ai orchestration action execute-batch \
  --action '{"kind":"connector","integrationSlug":"salesforce","actionSlug":"upsertRecords"}' \
  --records '[{"rowId":"acc_1","objectType":"Account","matchingPropertyName":"Name","matchingValue":"Acme","isFailingOnMultipleMatches":true,"mappings":[{"propertyName":"Website","value":"https://acme.com"},{"propertyName":"NumberOfEmployees","value":120}]}]' \
  --wait-until-finished

The rows that matched several accounts are the failed runs of that batch: list them with cargo-ai orchestration run list --batch-uuid <batch-uuid> --statuses error, and cargo-ai orchestration run get <run-uuid> shows the error with the match count.

Pass --limit 5 to any of these to run a pilot on the first five records and check the result in Salesforce before the full set.

What each action returns #

  • insertRecord, updateRecords and upsertRecords return data as an array of the Salesforce records they wrote, read back after the write with every field. A create returns one record; an update returns one per record it changed.
  • countRecords returns count, from a SOQL COUNT() query, so it is not capped at a page.
  • matchRecord returns match (true or false) and record, the first match or null.
  • 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. Beyond 2,000 matches the number in that message is capped at one page; the row still fails.

None of the Salesforce actions carries a credit price.

Contacts and leads work the same way #

The same actions take "objectType":"Contact" or "objectType":"Lead". Match by 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 HubSpot version of this page is sync enriched accounts to HubSpot, the broader rules for keeping the CRM clean are in CRM hygiene as code, and the CRM enrichment cookbook fills the identifiers this matching depends on.

Frequently asked questions #

Yes. The Salesforce connector’s upsertRecords action queries for records whose field 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 account is written.

Not by equality on Website, because that field holds a URL rather than a bare domain. Count with the contains operator on Website, confirm the single match with matchRecord, and update it by Id; or match on a custom field that stores the normalized domain.

Not with updateRecords: the update by Id fails that row, and no replacement is created.

Only if you let it. Set skipIfExist on a mapping and an update writes that field only when it is empty in Salesforce.

~/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 website, then name
  • Run it from the CLI
  • What each action returns
  • Contacts and leads 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 Accounts to HubSpot with Cargo: Create, Update or Upsert

Cargo's HubSpot connector creates, updates and upserts company records natively. How to match by record ID, then domain, 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