Skip to content

Move audiences between orgs

After these steps, the audiences of one org exist in another, with their filters, folders and the Filter Library entries and outcomes they use.

Before you begin

Permission
In the target org, create, edit and delete access to the CAB objects, for example through the Campaign Audience Builder User permission set. See Permission sets.

The open-source sf CLI plugin sf-plugin-cab copies audiences between Salesforce orgs, for example from a sandbox to production at a go-live. It uses the org aliases your sf CLI already knows; there is no separate login.

You need a current sf CLI on Node 22 or newer (run sf update), an alias for each org, and Campaign Audience Builder in both orgs.

Terminal window
sf plugins trust allowlist add --name @campaign-audience-builder/sf-plugin-cab
sf plugins install @campaign-audience-builder/sf-plugin-cab

The first command adds the plugin to the sf CLI allowlist, so the installation doesn’t ask for confirmation. To update the plugin later, run sf plugins update.

  1. List the audiences of the source org:

    Terminal window
    sf cab audience list -o uat
  2. See what an import into the target org would change. This changes nothing:

    Terminal window
    sf cab audience migrate --source-org uat --target-org prod --all --dry-run
  3. Copy the audiences. The command shows the plan and asks once before it changes the org:

    Terminal window
    sf cab audience migrate --source-org uat --target-org prod --all

Instead of --all, select audiences with --name (API name or name) or --folder (a folder path such as "Marketing/EMEA"). Without a selection, the command shows a list to choose from. A combination or waterfall sequence brings the audiences it uses along.

CommandWhat it does
sf cab audience listShows the audiences of an org, with API names, folders and the audiences that can’t be exported.
sf cab audience exportWrites the selected audiences to a JSON file.
sf cab audience importWrites the audiences from a file into an org. Shows a plan first and writes a backup of the target audiences it updates.
sf cab audience migrateExports and imports in one step, and keeps the export file.

Run a command with --help for all flags and examples.

  • An audience is matched to a target audience by its API name, ignoring case. A match is updated; an audience without a match is created. An audience without an API name can’t be matched, so the export skips it.
  • Each audience is written in one transaction: if a part fails, the target audience stays as it was. An update keeps the target’s schedules, run history and campaign members linked.
  • Folders, Filter Library entries and outcomes are matched by unique name, then by name. The import can create missing ones, but never changes existing ones. A Filter Library entry that is a default in the source org asks whether it stays a default; the answer defaults to no.
  • A Locked library link can only be made in CAB itself. The import then brings the audience without the link and warns; link the entry again in the target org.
  • Filter values that look like record IDs give a warning, because an ID from one org can be wrong in another.
  • Audiences in the target org that aren’t in the file stay as they are.

The plugin doesn’t copy schedules, scheduled actions, final actions, run results or campaign members.

Before its first change, the import writes a backup of the audiences it updates, for example cab-backup-prod-20261014-1412.json. Import that file to give them their previous definitions:

Terminal window
sf cab audience import -o prod --file cab-backup-prod-20261014-1412.json

The restore doesn’t delete audiences the import created; its output lists them.

In a pipeline, the command never asks. Give each answer with a flag, such as --missing-folders create, --missing-templates create, --missing-outcomes create, --template-defaults clear and --yes. If an answer is missing, the command stops before any change and names the flag.

Exit codeMeaning
0All audiences were imported or are unchanged.
1Nothing changed, because of an error or a “no” answer.
68Some audiences were imported; others failed or were skipped.

For all options, see the sf-plugin-cab repository on GitHub.