A named credential holds where a callout goes, and an external credential holds how it authenticates. Users get permission to call through a principal on the external credential, granted by a permission set. For a SaaS company whose managed package calls its own API from customers' orgs, that split decides what ships in the package and what each customer's admin has to set up after install.
Most guides stop at configuring one org by hand. A package has to work in hundreds of orgs you'll never log into, where tokens and certificates don't travel with the package and since February 2026 the customer can't edit your credential by default. Appnigma builds native Salesforce apps for SaaS teams, and its marketplace apps projects cover the managed package, install documentation for customer admins, and security review preparation.
Updated October 2026. Checked against Salesforce's Named Credentials developer guide and packaging guide. Legacy named credentials are now deprecated, not just frozen. This update adds the packaging rules, principal access and the callout errors customers see after install.
How named and external credentials divide the work
| Named credential | External credential | |
|---|---|---|
| Holds | The endpoint URL, custom headers, callout options | The authentication protocol, principals and their parameters |
| Referenced in Apex | Yes, as callout:Name | No, only through the named credential |
| Reuse | One endpoint each | Shared by many named credentials |
| Who can use it | Anyone with access to a principal | Granted per principal through permission sets |
| Secrets | None | Stored encrypted, with tokens in user external credentials |
Salesforce introduced this model in Winter '23, per the Named Credentials developer guide. User external credentials hold the encrypted tokens, and Salesforce's glossary says there's "no access to this object's records from SOQL, Apex, or the APIs." Your code can make an authenticated call without ever being able to read the secret behind it.
Making the callout from Apex
In Apex, a callout through a named credential uses the scheme callout:, the named credential's name and an optional path, per the Apex Developer Guide.
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Vendor_API/v1/orders?status=open');
req.setMethod('GET');
HttpResponse res = new Http().send(req);Salesforce adds the authorization header, refreshes OAuth tokens and resolves the host. The same code works whether the external credential uses OAuth, JWT or a custom header. You also skip the remote site setting, because Salesforce says "If the callout specifies a named credential as the endpoint, you don't need to configure remote site settings."
Merge fields such as {!$Credential.OAuthToken} exist for APIs that want the token in an unusual place. They only work after an admin enables Allow Merge Fields in HTTP Header or Body, which default to off. For a vendor API key sent in a header, a custom header formula on the external credential is the cleaner route.
Giving users access to a principal
A callout fails unless the running user can reach a principal on the external credential. Principals are "mapped in external credentials to a permission set, profile, or permission set group," per the glossary. In metadata that's externalCredentialPrincipalAccesses on the permission set, available from API 59.0, and a packaged principal is named namespacePrefix__myExternalCredential-myPrincipal.
The principal type decides whose identity the external system sees. A named principal shares one credential across every user in the org, which suits a sync your product runs on behalf of the customer. A per-user principal has each user authenticate once and suits calls that must act as a specific person. Switching from named to per-user later means every user has to authenticate for the first time, so decide before customers install.
Guest users are the exception to default access. Most profiles can already read the User External Credentials object, but for guest users "you must grant Read access to the User External Credentials object manually," per Create an OAuth Named Credential.
What ships in the package and what customers set up
Salesforce's packaging guide lists four components to include. They are the named credential, the external credential, an external auth identity provider for OAuth browser flow, and the permission set that grants principal access. Named credentials aren't added to packages automatically, so leaving one out only shows up when a customer's first callout fails.
The secrets never ship. "External credential certificates and access tokens aren't packageable," so after install the customer's admin authenticates the named principal or enters the key. Your setup screen can do it through the Connect API, per Populate External Credential Principals. JWT bearer flow needs a signing certificate created in the customer's org, so your install guide has to cover it.
Since February 2026, a packaged named credential defaults to developer control. The customer "can't edit the named credential's settings, such as the URL or authentication parameters." That protects your endpoint, but it breaks per-customer URLs. If each customer has their own subdomain or hosts an on-premises gateway, set subscriber control with the ManagedByNamespace parameter, which Salesforce documents for exactly those two cases.
Three more rules affect releases. Upgrades don't "overwrite or delete the populated principals," so customers don't re-authenticate after an update, per the upgrade guide. If package code updates a named credential, Salesforce disables callouts on it until the customer's admin turns Enabled for Callouts back on. And if your package calls a named credential it didn't ship, the customer has to add your namespace to that credential's allowed namespaces.
Where your own API key belongs
Two kinds of secret show up in an ISV package, and Salesforce's secure coding guide treats them differently. A customer's own credential belongs in the external credential, where tokens are encrypted and unreadable from code. A secret common to every customer, such as your API key, "must be stored in Managed Protected Custom Metadata Types."
The same guide notes that "Users with customized application permissions can view named credentials." If a value must stay hidden from customer admins, keep it in protected custom metadata and read it only from your package's Apex. Hardcoded endpoints and tokens in Apex are what Code Analyzer flags as ApexSuggestUsingNamedCred, and they come up in what the Salesforce security review checks.
Legacy named credentials are deprecated
Salesforce now says "Legacy named credentials are deprecated and will be discontinued in a future release." No date has been announced. The Connect API can't create the legacy type at all, and the Metadata API marks legacy-only fields such as endpoint, username and password as deprecated from API 56.0.
For a package, plan the move in a normal release rather than waiting for a cutoff. Create the new named and external credential, ship the permission set, and give customers a short re-authentication step in your release notes. Salesforce's upgrade guidance recommends a new external credential when the authentication protocol changes.
Callout errors customers see after install
When a managed package's callouts fail in a customer's org, the cause is usually a setup step that didn't happen there. The messages below are the ones one ISV's install guide lists for its customers, per SaaSify's Salesforce documentation.
| What the customer sees | Usual cause |
|---|---|
| "We couldn't access the credential(s)." | The user's permission set doesn't grant the principal |
| "Callout blocked for named credential." | Enabled for Callouts is off, often after package code updated the credential |
| "The callout couldn't access the endpoint." | The named principal was never authenticated, or the key wasn't entered |
| A field "does not exist" error | A custom header or merge field references a parameter name with the wrong case |
Two causes don't produce a clear message. A callout to a credential your package didn't ship fails until your namespace is allowed, and merge fields return nothing until Allow Merge Fields is on. Put both in your install guide.
Outbound callouts vs inbound API access
Named credentials only cover Salesforce calling out to your service. When your service calls into the customer's Salesforce org, it authenticates against an OAuth app on the Salesforce side. "Starting in the Spring '26 release, you can't create new Connected Apps. Use ECAs instead," per Salesforce's ISVforce guide. Our guide to the external client app for inbound calls covers that half. A two-way integration needs both, and they're configured separately.
Frequently Asked Questions
What is the difference between a named credential and an external credential?
The named credential holds the endpoint and callout options. The external credential holds the authentication and the principals users are granted through permission sets.
What doesn't ship when you package a named credential?
Access tokens and certificates. The customer's admin authenticates the principal or enters the key after install, through the UI or your setup screen using the Connect API.
Can customers edit a packaged named credential?
Not by default since February 2026. Packaged named credentials default to developer control unless you set subscriber control for per-customer URLs.
Are legacy named credentials deprecated?
Yes. Salesforce says they're deprecated and will be discontinued in a future release, with no date announced yet.
Can Appnigma build our managed package integration?
Yes. Appnigma builds native Salesforce apps for SaaS companies, including the managed package, install documentation and security review preparation. Salesforce decides review outcomes.
Related Articles
- External client apps for inbound calls
- Connected app vs external client app
- Building and versioning the managed package
- Salesforce OAuth errors on the inbound side
Sources
- Get started with named credentials, Salesforce Developers
- Named credentials glossary, Salesforce Developers
- Named credentials as callout endpoints and adding remote site settings, Apex Developer Guide
- Package named credentials, Salesforce Developers
- Populate external credential principals, Salesforce Developers
- Upgrade a named credentials managed package, Salesforce Developers
- Create an OAuth named credential, Salesforce Developers
- Storing sensitive data, Secure Coding Guide
- Secure your connected apps and external client apps, ISVforce Guide
- NamedCredential metadata type, Metadata API Developer Guide