Try Serpent Free

How to fix TERRITORY2_NOT_ENABLED in Salesforce deployments

A deployment includes Territory2 metadata, but Enterprise Territory Management isn't turned on in the target org.

Surfaces during: metadata deploy validation, before any DML runs

What it means

TERRITORY2_NOT_ENABLED means a deployment carries Territory2 metadata, territory models, territory rules, or related references, into an org where Enterprise Territory Management hasn't been enabled. The feature has to be turned on in Setup before Salesforce will accept any of that metadata, regardless of how clean the deployment itself is.

Enterprise Territory Management is a feature flag Salesforce enables through Setup (or a support case, on some editions), not something the Metadata API can turn on as part of a deploy, so this is always a manual, one-time prerequisite rather than something a fix in your metadata can resolve.

Diagnosis

Common causes

Source org has the feature enabled, target doesn't
Metadata was retrieved from a production org or sandbox with Enterprise Territory Management on and deployed to one that never had it turned on.
Scratch org definition omits the feature
A scratch-org-def.json used to spin up fresh orgs doesn't request the Territory Management feature, so new orgs are created without it.
A profile or permission set references territory permissions in a disabled org
Deployed metadata assumes territory-related permissions exist, but the target org rejects them because the feature itself is off.

The fix

  1. Enable Enterprise Territory Management in the target org
    Turn the feature on in Setup before attempting to deploy Territory2 metadata into that org.
  2. Add the feature to scratch org definitions
    Include Territory Management in the features list of scratch-org-def.json so every new scratch org has it enabled from creation.
    {
      "edition": "Enterprise",
      "features": ["TerritoryManagement2"]
    }
  3. Strip Territory2 references for orgs that don't use territories
    Exclude territory metadata from deployments targeting environments that intentionally don't use Enterprise Territory Management.
In practice

How Serpent prevents this

Serpent's scratch org definitions are version-controlled the same way metadata is, so the Territory Management feature can be baked into every fresh org a task provisions instead of being enabled by hand after the fact. See the Salesforce deployment error library.

Metadata and data in one deployment flow in Serpent

Prevention

Standardize scratch-org-def.json features across the team
Keep one shared, version-controlled scratch org definition that includes every feature production uses, so new scratch orgs never drift from what the metadata actually needs.
Document org-level feature prerequisites alongside the metadata that needs them
Note in your repo's setup docs which Salesforce features, Territory Management, Multi-Currency, Person Accounts, a fresh org needs enabled before its first deploy.
Never enable Enterprise Territory Management without a plan for every org
Treat enabling the feature as an org-wide, largely irreversible decision, and coordinate it across every environment before Territory2 metadata is ever built.
Common questions

TERRITORY2_NOT_ENABLED, answered

Can Enterprise Territory Management be enabled and then disabled again later?
Once enabled and used, it generally can't be fully disabled without significant rework; treat enabling it as a one-way decision for that org.
Can I enable Enterprise Territory Management myself, or do I need Salesforce support?
In most orgs it's self-service from Setup, Territory Settings; some older or heavily customized orgs may need a support case, so check Setup first before opening one.
Does this affect the older, deprecated Territory Management (Territory, not Territory2)?
No. This error is specific to Enterprise Territory Management (Territory2) metadata; the original Territory Management feature has its own separate settings and isn't affected by this check.

Start free. No credit card, no install, no commitment.

Set up in under 15 minutes. No DevOps hire needed.

Curious about faster shipping before you dive in? Let's talk

Commitment free!