Skip to content

Environment Strategy

Environment strategy underpins a well-managed Salesforce development lifecycle. The topology must balance developer productivity, testing rigor, release safety, and cost. The wrong strategy causes bottlenecks, data leaks, deployment failures, and developer frustration.

Sandbox Types

Salesforce offers four sandbox types, each with different capabilities and limitations. Choose the right mix based on team size, data needs, and release cadence.

FeatureDeveloperDeveloper ProPartial CopyFull Copy
MetadataFull copyFull copyFull copyFull copy
DataNoneNoneSample (template)Full copy
Storage200 MB1 GB (configurable storage upgrades available since Spring ‘25)5 GBSame as production
Refresh cycle1 day1 day5 days29 days
Included inEE, UE, PEEE, UE, PEEE, UE, PEUE, PE
Typical countManySeveral2-31
Best forIndividual developmentDevelopment + unit testingIntegration testing, UATStaging, performance testing

Sandbox Limits by Edition

Enterprise Edition includes 25 Developer, 1 Developer Pro, and 1 Partial Copy (Full Copy requires separate purchase). Unlimited Edition includes 100 Developer, 5 Developer Pro, 1 Partial Copy, and 1 Full Copy. Performance Edition is similar to Unlimited. Additional sandboxes can be purchased. Always verify current limits with the customer’s contract.

Developer Sandbox

Use for: Individual feature development, POC work, learning, and experimentation.

Limitations:

  • No data. Developers must create test data manually or use scripts.
  • 200 MB storage, insufficient for large data testing
  • Cannot test data-dependent features (reports, dashboards with live data)

Developer Pro Sandbox

Use for: Development work requiring more storage, unit testing with moderate data volumes.

Limitations:

  • Still no production data; data must be manually created
  • 1 GB storage, better than Developer but still limited
  • Not suitable for volume testing

Partial Copy Sandbox

Use for: Integration testing, QA, UAT. Uses a sandbox template to copy a sample of production data.

Key considerations:

  • Sandbox template defines which objects and records to include (up to 10K records per object)
  • Template design matters. Include enough data to test but not so much that it slows refresh.
  • Data is a snapshot, not a live sync. It becomes stale after refresh.
  • Sensitive data may be included unless data masking is in place

Full Copy Sandbox

Use for: Staging, performance testing, final UAT, training. Full copy of production metadata and data.

Key considerations:

  • 29-day refresh cycle. Plan carefully; there is no quick reset.
  • Full production data includes PII and sensitive data, so data masking is essential
  • Storage matches production, which gets expensive if production is large
  • Performance testing is only valid here (data volume affects query performance)

Environment Topology

Standard Enterprise Topology

Developer sandboxes and CI scratch orgs converge at SIT, then promote sequentially through UAT and a Full Copy staging sandbox to production.
Figure 1. SIT is the merge point where individual developer streams come together for the first time. Separating SIT from UAT ensures that business users accept a stable build, not one still receiving in-flight developer changes.

Environment Purpose Matrix

EnvironmentPurposeDataWho Uses ItRefresh Cadence
Dev SandboxesFeature developmentTest data scriptsDevelopersAs needed (daily capable)
Scratch OrgsCI/CD validation, feature isolationTest data scriptsCI/CD pipelinePer feature branch
SIT (System Integration Test)Integration testing, cross-team validationPartial copy (template)Dev team, QAPer sprint/release
UATBusiness user acceptance testingPartial copy (template)Business users, BAPer release
StagingPre-production validation, performanceFull copyRelease team, QAPer release (29-day min)
ProductionLive environmentReal dataAll usersN/A

Scratch Orgs

Scratch orgs are ephemeral, fully configurable environments created from a definition file. They are central to modern Salesforce DX development.

When to Use Scratch Orgs

Use Scratch OrgsUse Sandboxes
CI/CD pipeline validationIntegration testing with real data
Feature branch isolationUAT with business users
Package developmentPerformance testing
Automated testingTraining environments
Short-lived, disposable environmentsLong-lived, persistent environments

Scratch Org Definition File

The project-scratch-def.json defines the scratch org’s shape:

{
"orgName": "CTA Study Scratch Org",
"edition": "Enterprise",
"features": ["Communities", "ServiceCloud"],
"settings": {
"lightningExperienceSettings": {
"enableS1DesktopEnabled": true
},
"securitySettings": {
"passwordPolicies": {
"enableSetPasswordInApi": true
}
}
}
}

DevHub Configuration

  • DevHub is the production org (or business org) that manages scratch org creation
  • Enable it in Setup > Dev Hub
  • Scratch orgs count against the DevHub’s active scratch org limit. Limits by edition: Performance/Unlimited (100 active, 200 daily), Enterprise (40 active, 80 daily), Developer (3 active, 6 daily)
  • A namespace can be linked to DevHub for package development

Scratch Org Limits

Scratch orgs expire after a maximum of 30 days (default 7). They cannot be refreshed; they must be recreated from source. If the CI/CD pipeline creates many scratch orgs, monitor the daily creation limit. Exceeding it blocks the pipeline.

Sandbox Refresh Lifecycle

The full refresh lifecycle determines environment availability and disruption windows.

Every sandbox refresh triggers a SandboxPostCopy Apex script that masks PII, updates integration endpoints, verifies email deliverability, and creates test users.
Figure 2. The SandboxPostCopy interface is the only reliable way to automate post-refresh setup, because manual checklists get skipped under time pressure. Verifying email deliverability remains at ‘System email only’ (the default since Spring ‘13) is critical for Partial Copy and Full Copy sandboxes that contain real customer email addresses.

Automate Post-Copy Tasks

Do not rely on manual steps after a sandbox refresh. Implement the SandboxPostCopy interface in Apex so that endpoint updates, data masking, email deliverability verification, and test user creation happen automatically every time. Manual post-refresh checklists are error-prone and get skipped under time pressure.

Salesforce DX Environment Flow

Modern Salesforce DX development uses DevHub and scratch orgs alongside traditional sandboxes. The diagram below shows how these components interact.

DevHub authorizes scratch org creation; developers push source from Git through the CLI into short-lived feature and CI scratch orgs.
Figure 3. Scratch orgs are defined entirely by source (the scratch-def.json and the project metadata), so any developer can recreate an identical environment in minutes. CI scratch orgs use a 1-day TTL to reduce active org count consumption against DevHub limits.

Source Tracking

Source tracking bridges local project files and the scratch org or sandbox:

  • sf project deploy start pushes local changes to the org
  • sf project retrieve start pulls org changes to the local project
  • Source tracking (enabled by default in scratch orgs; also supported in Developer and Developer Pro sandboxes when the associated production org has source tracking enabled) detects which files changed on either side, enabling bidirectional sync
  • Conflict detection flags cases where both local and org have changed the same metadata component

Source Tracking Limitations

Source tracking works with scratch orgs and Developer/Developer Pro sandboxes only. It does not work with Partial Copy or Full Copy sandboxes, production orgs, or Developer Edition orgs. For non-tracked orgs, specify what to deploy or retrieve using manifest files (package.xml).

Refresh Planning

Refresh Cadence Best Practices

EnvironmentRecommended CadenceTrigger
Developer SandboxesAs neededWhen sandbox drifts too far from production metadata
SITPer release/sprintStart of each sprint or release cycle
UATPer releaseBefore each UAT cycle begins
StagingPer release (if possible)Before final pre-production validation

Pre-Refresh Checklist

  1. Notify teams: All users of the sandbox must know it is being refreshed
  2. Export configuration: Any sandbox-specific configuration that is not in source control
  3. Document manual steps: Anything that must be re-done after refresh
  4. Verify source control: Ensure all in-progress work is committed
  5. Schedule appropriately: Full Copy sandboxes take hours to days

Post-Refresh Activities

Post-copy scripts automate setup that must happen after every sandbox refresh. Implement them using the SandboxPostCopy interface in Apex:

Common post-copy tasks:

  • Update integration endpoint URLs (sandbox vs production)
  • Mask or anonymize sensitive data (PII, financial data)
  • Verify email deliverability is set to ‘System email only’ (default since Spring ‘13, but verify after every refresh)
  • Update custom settings with sandbox-specific values
  • Deactivate or reassign workflow email alerts
  • Create test users with appropriate profiles
  • Update Named Credential endpoints
global class PostCopySetup implements SandboxPostCopy {
global void runApexClass(SandboxContext context) {
// Mask PII data
// Update integration endpoints
// Verify email deliverability is 'System email only'
// Create test data
}
}

Data Masking

Data masking is required for any environment that copies production data (Partial Copy, Full Copy).

What to Mask

Data CategoryExamplesMasking Approach
PIINames, emails, phone numbersRandomize or replace with fake data
FinancialCredit card numbers, bank accountsReplace with test numbers
HealthMedical records, diagnosesRemove or generalize
AuthenticationPasswords, tokens, API keysReset or remove
Business sensitiveRevenue, pricing, contractsGeneralize or replace

Data Masking Architecture

Production PII flows through three parallel masking mechanisms before landing in the non-production sandbox as anonymized data.
Figure 4. Three masking strategies serve different scenarios: Salesforce Data Mask handles bulk field-level anonymization after refresh, SandboxPostCopy Apex covers targeted programmatic masking, and template filtering simply excludes objects too sensitive to copy at all.

Masking Strategies

  • Salesforce Data Mask: Native Salesforce managed package add-on installed in production with masking rules configured there. After each sandbox refresh, Data Mask is run manually or via API in the sandbox to apply field-level masking with pattern matching, random generation, and deletion. It does not run automatically during sandbox creation. Preferred for compliance.
  • Post-copy Apex script: Masks data programmatically after refresh using the SandboxPostCopy interface. Limited by governor limits and execution time, so it suits targeted masking but not full-org sweeps.
  • Third-party tools: Informatica, OwnBackup, Provar. These offer more sophisticated masking rules, cross-object consistency, and referential integrity.
  • Sandbox template filtering: Excludes sensitive objects entirely from Partial Copy templates. Simplest approach but limits testing realism.

Compliance Requirement

In regulated industries (healthcare, financial services), failing to mask production data in non-production environments is a compliance violation. HIPAA, PCI-DSS, GDPR, and SOX all have requirements around data in non-production environments. Address this explicitly in the architecture.

Sandbox Naming Conventions

Consistent naming reduces confusion and prevents deployment errors:

PatternExampleDescription
{Purpose}DEV, SIT, UAT, STAGESimple, clear purpose
{Purpose}-{Team}DEV-SALES, DEV-SERVICEMulti-team environments
{Purpose}-{Release}UAT-R2024Q4Release-specific environments
{Purpose}-{Feature}DEV-CPQ-MIGRATIONFeature-specific development

Email Suffix

Sandbox emails append .{sandboxname} to the user’s email (e.g., user@company.com.dev). Keep sandbox names short and clear so email addresses stay readable.

Environment Strategy for CTA Scenarios

Small Team (5-10 developers)

  • 3-5 Developer Sandboxes
  • 1 Partial Copy for SIT/QA
  • 1 Partial Copy for UAT
  • 1 Full Copy for Staging
  • Scratch orgs for CI/CD

Large Team (20+ developers)

  • 15-20 Developer Sandboxes (or scratch orgs via DevHub)
  • 2-3 Partial Copy for SIT (per workstream)
  • 1 Partial Copy for UAT
  • 1 Full Copy for Staging
  • 1 Full Copy for Performance Testing
  • DevHub with high scratch org limits

Multi-Cloud / Multi-Org

  • Each org needs its own environment topology
  • Cross-org integration testing requires coordinated sandbox refreshes
  • Environment parity matters: integrations should point to corresponding sandbox tiers

Sources

Personal study notes for the Salesforce CTA exam. Content compiled from VJ's study notes, official Salesforce documentation, community sources, and online publicly available content, then organized and presented with AI assistance. Not affiliated with Salesforce. © 2025–2026 VJ Srivastava.