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

Declare One-Off Go-to-Market Batches and Runs in Code

16 Oct5min read
AurelienAurelien

To run a one-off go-to-market job from code, such as enrolling 50 contacts into a play, enriching a CSV or backfilling a field, declare it with defineBatch or defineRun in a file under outputs/: cargo-ai project plan lists it, and the next cargo-ai project deploy runs it exactly once. A ledger in the project’s deploy state records it before it starts, so no later deploy runs it again.

A resource says what exists. An execution says what to do, once. Declaring it in the repository means the pilot enrollment gets the same review as the play it enrolls into.

Declare a batch #

typescript
// outputs/2026-10-14-expansion-pilot/pilot.ts
import { defineBatch } from "@cargo-ai/cdk";

import { contacts } from "../../infra/models/contacts";
import { expansion } from "../../infra/plays/expansion";

export const pilot = defineBatch("2026-10-14-expansion-pilot", {
  workflow: expansion,
  data: {
    kind: "filter",
    model: contacts,
    filter: {
      conjonction: "and",
      groups: [
        /* … */
      ],
    },
    limit: 50,
  },
});
  • id is what Cargo remembers the execution by: lowercase letters, digits, hyphens and underscores, unique in the project. Start it with a date and executions run in the order you wrote them.
  • workflow is a play, a tool, or a workflow written inline with defineWorkflow. For one the project does not define, pass workflowRef(uuid).
  • data is where the records come from:
kindRuns on
filtera model’s records matching a filter, at most limit (required)
segmentthe records in a segment
recordIdsexactly these record ids
formrecords written in code, checked against the workflow’s form
filethe rows of a CSV in the repository, at most 50 MB

A play batch takes any kind except file, and its model must be the play’s own.

To import a CSV that sits next to the batch:

typescript
// outputs/2026-10-20-import/import.ts
import { defineBatch } from "@cargo-ai/cdk";

import { enrich } from "../../infra/tools/enrich";

export const leads = defineBatch("2026-10-20-import", {
  workflow: enrich,
  data: {
    kind: "file",
    path: new URL("./leads.csv", import.meta.url).pathname,
  },
});

Declare a run #

defineRun runs a tool or an inline workflow once, on one input:

typescript
import { defineRun } from "@cargo-ai/cdk";

import { backfillOwners } from "../../infra/tools/backfillOwners";

export const backfill = defineRun("2026-10-15-backfill-owners", {
  workflow: backfillOwners,
  data: { since: "2026-01-01" },
});

A play runs on records, so it only takes a batch.

Plan, then deploy #

shellscript
cargo-ai project plan     # lists pending executions and the ones already in the ledger
cargo-ai project deploy   # applies resources first, then starts each pending execution

The plan prints pending executions under “Will execute once, after the resources (id order)” and past ones under “In the ledger, so never run again”. The deploy applies resources first, so an execution can use a play created in the same change, then reports each execution as started, refused, unconfirmed or not started. Only not started (it failed before reaching Cargo, such as a file upload) is retried by the next deploy. --draft never runs executions.

Executions are read from outputs/, in any folder under it. In a repository built from the Cargo template with resources in infra/, that is the outputs/ at the repository root. A cargo.json can name other folders in executions.

Exactly once #

You changeWhat happens
The file name or folderNothing, the id is the same
An execution that already ranNothing; the plan lists it as in the ledger
A batch’s CSV, after it ranNothing; it was read once
The idA new execution, run by the next deploy
Delete one that has not runIt never runs

There is no retry. To run something again, give it a new id. A refused execution also stays in the ledger: fix it and give it a new id.

On a connected repository #

When the repository is connected to Cargo, the pull request previews each execution: records, sends and credits, and an approval gate on large ones. The merge starts an execution only if a plan counted that exact version, the plan was approved, and it now runs on no more records than the preview allowed (up to 10% over a filter’s or segment’s count). Otherwise it is held and stays pending.

Caveats #

  • An execution acts on the outside world. A play it enrolls records into may send emails or LinkedIn actions, and reverting the code does not take them back.
  • Executions need the deploy state in your workspace. A project whose cargo.state.json still holds the full map refuses them until cargo-ai project state create moves it.
  • Spelling matters: the filter key is conjonction, as in the rest of Cargo’s filter API.

Full reference: Executions in the Cargo docs. The whole lifecycle: GTM as code: the complete guide.

~/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 16, 2026
On this page
  • Declare a batch
  • Declare a run
  • Plan, then deploy
  • Exactly once
  • On a connected repository
  • Caveats

Stay Informed with our
weekly Newsletter

Related articlesSee all articles
GTM Engineering
CI/CD for Go-to-Market: What It Means and How to Set It Up

CI/CD for GTM means every change to enrichment, scoring, routing and sequences ships as a pull request that is planned, checked, approved, deployed on merge, logged and reversible. What each software CI/CD step becomes for go-to-market, and how to set it up on Cargo.

AurelienAurelien·Nov 3, 2026
GTM Engineering
Require Approval Before a High-Impact Go-to-Market Change Goes Live

How Cargo holds a go-to-market pull request that would send or spend more than set limits until a reviewer adds the cargo:approve-impact label: the thresholds, what counts as high impact, who should approve, and what the gate does not catch.

AurelienAurelien·Nov 3, 2026
GTM Engineering
Test a Go-to-Market Change Before It Reaches Production

How to test a change to enrichment, scoring, routing or outreach before it runs on every lead: check the project offline, dry run an action, read the plan on the pull request, ship the play switched off and pilot it on 50 records, evaluate agents, and use a second workspace as staging.

AurelienAurelien·Nov 3, 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