The Salesforce Sandbox Post-Refresh Checklist (16 Steps)

After a Salesforce sandbox refresh, work through four groups of tasks. Lock down email and access, repoint every integration away from production, restore the jobs and settings the copy didn't bring over, and clean up the data by masking PII and seeding test records. Then automate as much as you can in a SandboxPostCopy Apex class.

A refresh gives you a new org that looks like production and still has production's endpoints. Most post-refresh incidents come from something in the copy that still points at, or behaves like, a live system. Work through the list in order: email and integrations first, because those are the steps where a mistake reaches real customers.

Access and email (do these first)

The first job after a refresh is making sure the sandbox can't email real people. Salesforce helps here, but only partly.

  1. Check the email deliverability setting. New and refreshed sandboxes default to System email only, which allows only system-generated mail such as password resets (Email Deliverability). Leave it there until you've finished steps 2–3 and 13, then open it up only if testing needs it.
  2. Fix user emails only for testers who need them. User email addresses get .invalid appended (jane@acme.com becomes jane@acme.com.invalid). Remove the suffix for the people who need notifications. Each sandbox user's email must be verified before that user can send email from Salesforce (Users and Contacts in sandboxes).
  3. Remember that record emails are not changed. Salesforce changes user emails but "don't change other email addresses in Salesforce, such as email addresses in contact records." Contacts, Leads, Person Accounts, and custom email fields still hold real addresses. Handle them in step 13 before any email automation runs.
  4. Review who can log in. Every production user comes along, with the sandbox name appended to their username (user@acme.com.test) and they can log in with their production password. Freeze or deactivate users who have no reason to be in a copy of production data, especially in a Full sandbox.

Integrations and endpoints

Every integration setting in the sandbox was copied from production, so it still points at production systems until you change it.

  1. Repoint Named Credentials and External Credentials. Change their endpoints from production APIs (ERP, payment gateway, marketing platform) to those systems' test environments, and replace the credentials.
  2. Audit Remote Site Settings and CSP Trusted Sites. Remove or repoint entries for production-only hosts so a stray callout fails instead of reaching a live system.
  3. Check outbound messages, platform event consumers, and webhooks. Workflow outbound messages and any Apex that posts to a URL should target a test listener, not the production endpoint.
  4. Update custom settings and custom metadata. Search for production URLs, API keys, record IDs, and environment flags in custom settings and custom metadata types. They're easy to overlook because they're data-shaped configuration.
  5. Reconnect external systems to the sandbox. Integrations that log in to Salesforce need the sandbox's login URL, and OAuth apps need callback URLs that match the sandbox's My Domain. Reset the passwords and tokens of integration users so production secrets aren't reused in a lower environment.
  6. Update anything keyed on the org ID. The sandbox gets a new org ID on every refresh (Refresh Your Sandbox). License checks, allowlists, and integration configs keyed on the old ID need updating.

Jobs and automation

A refresh copies metadata, but not everything that runs on a schedule comes along.

  1. Reschedule the Apex jobs you need. Salesforce says scheduled Apex jobs from the source org aren't copied and must be rescheduled (sandbox considerations). Reschedule only the ones the sandbox needs. A nightly sync to production is not one of them.
  2. Reactivate Salesforce-to-Salesforce connections. These connections and their mappings aren't copied. Recreate the ones the sandbox needs, pointed at other test orgs.

Data

What you do here depends on the sandbox type. Partial Copy and Full sandboxes arrive with production data. Developer and Developer Pro sandboxes arrive empty.

  1. Mask or purge PII (Partial Copy and Full). Replace personal data in names, emails, phones, and government IDs, or delete records the sandbox doesn't need. Deterministic masking keeps related records consistent. See six ways to mask PII in a sandbox.
  2. Seed test data (Developer and Developer Pro). Load the records your tests expect: reference data, a few named test accounts, and enough volume to exercise list views and reports. Script it so you get the same records every time.
  3. Load the production slice you actually need. If you need specific, current production records in a lighter sandbox, copy them in with external IDs, in dependency order and masked. The step-by-step guide to copying production data covers the details.
  4. Check storage. Make sure seeded and copied data fit within the sandbox's allocation (200 MB for Developer, 1 GB for Developer Pro) before the team starts loading its own data.

Automate it with SandboxPostCopy

Most of this list can run automatically. When you create or refresh a sandbox, you can specify an Apex class that implements the SandboxPostCopy interface, and Salesforce runs it after each create and refresh of that sandbox. The class implements one method:

global class PrepareSandbox implements SandboxPostCopy {
    global void runApexClass(SandboxContext context) {
        // context.organizationId(), context.sandboxId(), context.sandboxName()
        // e.g. update custom settings, invalidate contact emails,
        // enqueue a batch job to mask PII, create test users
    }
}

SandboxContext gives you the org ID, sandbox ID, and sandbox name, so one class can behave differently in uat and dev1. Good candidates for automation are custom setting updates (step 8), invalidating contact emails (step 3), and kicking off a batch masking job (step 13). Steps that need secrets, such as new Named Credential passwords, are usually safer done by hand or from your deployment pipeline. Cover the class with a test that calls Test.testSandboxPostCopyScript. A post-copy script that fails on a real refresh is its own small incident.

Where Syntharil fits

For the data steps (13–15), Syntharil's test data generator can seed a freshly refreshed Developer sandbox with schema-valid, related records, and its replication masks PII in transit so production personal data never lands in the target. Runs start from the UI, the API, or the CLI, so a pipeline step can kick them off after a refresh.

Bottom line

A refreshed sandbox is a copy of production that still has production's settings. Do the steps in order of blast radius: email and access, then integrations, then scheduled jobs, then data. Put everything repeatable into a SandboxPostCopy class or a pipeline script. Keep the checklist in version control next to that code and update it every time a refresh surprises you.

FAQ

How do I log in to a sandbox after a refresh?

Use your production username with the sandbox name appended (user@acme.com.test for a sandbox named 'test'). You can log in with your production password. Right after a refresh, use the sandbox's My Domain login URL, because test.salesforce.com can take 24-48 hours to recognize it.

Why aren't emails sending from my refreshed sandbox?

New and refreshed sandboxes default to the 'System email only' deliverability setting, and user email addresses get '.invalid' appended. Change deliverability in Setup and fix the addresses of the testers who need email.

Does a sandbox refresh change contact and lead email addresses?

No. Salesforce only modifies user email addresses. Email addresses on contacts, leads, and other records are copied as they are, so invalidate or mask them before turning email back on.

Can I test a SandboxPostCopy class before a refresh?

Yes. Write an Apex test that calls Test.testSandboxPostCopyScript with an instance of your class and sample org and sandbox IDs, so the script's logic is covered before it runs on a real refresh.

Related reading

Try Syntharil free