Salesforce custom metadata deployment fails for a reason most teams miss: the records themselves are metadata, which means they deploy, but the values inside them are data, which means they're supposed to change per org. That split causes more broken integrations and silent config drift than almost any other metadata type. Get the pattern wrong and your sandbox settings end up live in production, pointed at the wrong endpoint, with the wrong flag flipped on.

Custom metadata types were built to solve a real problem. Hardcoded values in Apex and Flow are a maintenance headache, and custom settings don't deploy cleanly across orgs. Custom metadata records fixed half of that. The other half, keeping environment-specific values separate from environment-independent structure, is where most admins get burned.

Why custom metadata doesn't behave like other metadata

A custom object definition deploys the same way everywhere. Fields, layouts, validation rules, all identical in every target org. Custom metadata records break that assumption because the record itself ships with the deployment, including whatever values were sitting in its fields when you packaged it.

That's the part people forget. A custom metadata record called Integration_Endpoint__mdt isn't just defining a structure, it's carrying a literal URL, API key reference, or org ID inside it. Deploy that record from sandbox to production and you've just pushed your sandbox endpoint into your live org. Nobody flagged it as an error because, technically, it isn't one. The deployment succeeded. The config is just wrong.

We see this most often with integration settings, feature toggles, and routing rules stored as custom metadata. Teams build it once, test it in sandbox, and assume the values will somehow reset for production. They won't. Metadata API deploys the record exactly as it exists in source.

The environment-specific config trap

Here's where it actually bites. A team builds a custom metadata type called API_Config__mdt with a field for Callout_URL__c. In the sandbox, that field points to a test instance. The developer deploys the whole type, records included, straight to production through a change set or a metadata deploy, and the test URL goes live.

Nothing in the deployment log tells you this happened. Validation passes, tests pass, the deploy succeeds. The only sign something's wrong is when a production integration starts calling a sandbox endpoint and either errors out or, worse, quietly writes test data into a system that thinks it's receiving real records.

The fix isn't complicated, but it does require discipline most release processes skip. Separate your custom metadata type definition from the deployment of its records. Deploy the type once to establish structure, then manage record values per environment, either manually through setup or through a deployment tool that lets you exclude specific records from a push.

DeployEzee handles this by letting you scope a deployment to metadata type definitions without dragging every child record along. You decide which records travel and which stay put, which means your production endpoint stays your production endpoint no matter how many times sandbox gets refreshed.

Protected custom metadata changes the rules again

If you're packaging custom metadata inside a managed or unlocked package, there's a second layer worth understanding: protected versus unprotected visibility.

Protected custom metadata records are visible only to the package that owns them. Subscriber orgs can't see or edit the values, which is useful for licensing logic or internal configuration you don't want customers touching. Unprotected records are editable in the subscriber org, meaning a customer admin can change a value and that change survives future package upgrades.

The mistake we see most is teams picking unprotected by default because it's the path of least resistance during initial build, then discovering months later that a critical config value got overwritten by an end user with sysadmin access. Decide visibility deliberately, not by accident, and document which records are meant to be touched downstream.

ScenarioRecommended Visibility
Internal feature flags controlling package behaviorProtected
Customer-facing configuration (thresholds, labels)Unprotected
Integration endpoints or credentialsProtected, managed outside package records
Business logic lookups tied to record typesProtected

Dependency resolution gets messy fast

Custom metadata records often reference other metadata: a lookup field pointing to a record type, a picklist value tied to a validation rule, a relationship to another custom metadata type entirely. When one of those dependencies doesn't exist yet in the target org, the whole deployment stalls.

This is the same dependency chain problem that trips up permission sets and flows, except custom metadata adds a wrinkle: the dependency might be a record, not a component. Metadata API doesn't always resolve record-level dependencies in the order you'd expect, especially across multiple custom metadata types that reference each other.

Manually ordering these deployments means tracking which type depends on which, then sequencing change sets accordingly. It's tedious, and it's exactly the kind of work that should be automated rather than remembered. DeployEzee builds the dependency graph before you push, flags missing prerequisites, and sequences the deploy so referenced records land before the records that reference them.

A deployment pattern that actually holds up

The teams that stop fighting custom metadata do three things consistently. First, they treat the type definition and its records as separate deployment artifacts, never bundled by default. Second, they maintain an environment-specific values sheet, essentially a lookup table of what each record's fields should contain per org, so nobody has to guess after a refresh. Third, they validate record values as part of their pre-deploy checklist, not as an afterthought when something breaks in production.

None of this requires exotic tooling, but it does require someone to own the process. In our experience, the orgs that skip this ownership step are the ones that end up with three different custom metadata types doing roughly the same job because nobody trusted the first one after it caused an outage.

If you're validating before every push anyway, build a dedicated check for custom metadata record values. Confirm URLs, API versions, and flags match the target environment before the deploy goes out, not after.

Testing custom metadata changes without guessing

Apex tests referencing custom metadata records can mask real problems if they're written against hardcoded values that happen to match your sandbox. Write tests that query the metadata type dynamically and assert on structure or logic, not on the literal value of a field that's supposed to change per org.

It's also worth running a validation-only deploy before any custom metadata push that touches production. This surfaces dependency errors and visibility conflicts without actually committing the change, giving you a chance to fix sequencing issues before they become downtime.

Custom metadata types are one of the better tools Salesforce has given admins for managing configuration without hardcoding values into Apex. They're also one of the easiest things to deploy badly if you treat them like ordinary metadata. Separate structure from values, control visibility deliberately, and resolve dependencies before you push. That's the whole discipline, and it's worth building into your release process once rather than relearning after an incident.

Frequently Asked Questions

Why does deploying a custom metadata type move data, not just structure?

Custom metadata records store configuration values directly in fields, and Metadata API deploys those records exactly as they exist in the source org. Unlike custom objects, where deploying structure doesn't move records, custom metadata ships the field values along with the type definition. That's why a sandbox endpoint or test flag can end up live in production if the deployment isn't scoped carefully.

How do I deploy a custom metadata type without pushing its record values to production?

Scope your deployment to the type definition only and exclude the specific record components from the package or deploy set. Most CI tools and change sets let you select individual metadata records rather than the whole type, so you can push structure now and manage record values per environment separately.

What's the difference between protected and unprotected custom metadata in a package?

Protected custom metadata records are hidden from subscriber orgs and can't be edited after install, which keeps internal configuration safe from accidental changes. Unprotected records are editable by the subscriber, meaning end users can modify values and those changes persist through package upgrades. Pick based on whether the value should ever change outside your control.

Why do custom metadata deployments fail on missing dependencies?

Custom metadata records often reference other metadata, like record types or related custom metadata entries, and if that referenced component doesn't exist yet in the target org, the deploy stalls. This happens because dependency resolution for records isn't always automatic the way it is for some component types. Sequencing the deploy so prerequisites land first resolves it.

Can custom metadata values be different in sandbox and production safely?

Yes, and that's actually the intended use case: structure stays consistent while values like endpoints or thresholds differ per environment. The key is managing those value differences deliberately through a documented values sheet or a deployment tool that lets you exclude records from automatic pushes. Without that control, a routine deploy can silently overwrite production values with sandbox ones.