ExternalCredential defines how Salesforce authenticates to an external system: the authentication protocol, principals, and authentication parameters. A principal identifies a shared or per-user authentication context. A NamedCredential references this definition through externalCredential. The external credential supplies authentication, not the external service's callout endpoint. An authentication-provider URL inside an external credential serves a different purpose from that callout endpoint.
Stored credentials are encrypted using automatically created, org-specific keys. The authentication definition, access to its principals, and provisioning of credential values are separate administrative concerns. Creating the definition does not by itself establish that users can use its principals or that credential values have been populated.
Key Elements
Except for authenticationProtocol, label, and externalCredentialParameters, the elements below belong to entries inside externalCredentialParameters.
| Element | What the Element Controls |
|---|---|
authenticationProtocol |
Required. Documented values are AwsSv4, Basic, Custom, Jwt, JwtExchange, NoAuthentication, Oauth, and Password. Some are reserved or inconsistently documented; enum membership alone does not establish a supported flow. |
label |
Required. The external credential's display name. |
externalCredentialParameters |
Nested parameter entries that configure principals, providers, claims, headers, and other authentication settings. Interpret each entry's type, name, value, and lookup fields together. |
parameterType |
Required for each entry. Selects its behavior, such as NamedPrincipal, PerUserPrincipal, AuthParameter, AuthHeader, AuthProviderUrl, or SigningCertificate. |
parameterName |
Required for each entry. Identifies the setting, claim key, header name, or principal name, depending on parameterType. |
parameterValue |
Supplies the value appropriate to the parameter type. It can be a literal value, an endpoint URL, a claim value, or a runtime formula. It is not uniformly a literal credential value. |
parameterGroup |
Associates settings with a principal. Defaults to parameterName for named and per-user principals, and to DEFAULT_GROUP for other parameters. |
sequenceNumber |
Sets named-principal selection priority when a user qualifies for multiple principals; lower numbers have higher priority. The documentation conflicts about its use for custom-header ordering. |
authProvider |
References an AuthProvider when parameterType is AuthProvider. |
externalAuthIdentityProvider |
References an ExternalAuthIdentityProvider when parameterType is ExternalAuthIdentityProvider. Salesforce recommends this provider type to simplify authentication-provider configuration for named credentials. |
certificate |
References a separate Certificate by name when parameterType is SigningCertificate. It does not embed certificate material. |
Behavior and Constraints
Principal selection and access
NamedPrincipal uses the same set of user credentials for users accessing the external system through that principal. PerUserPrincipal provides access control at the individual-user level. In both cases, the principal's name is its parameterName.
For NamedPrincipal, sequenceNumber determines which principal has priority when a user qualifies for more than one. Lower numbers take priority. This is principal-selection priority, not a sequence of authentication operations.
parameterGroup changes which settings apply to a principal. For example, a dynamic-scope AuthParameter can apply only when authentication uses a principal with a matching parameterGroup. Grouping is therefore functional, not merely organizational. Omitting the group can leave a non-principal parameter in DEFAULT_GROUP rather than in the principal's group.
PermissionSet and MutingPermissionSet reference external-credential principals through externalCredentialPrincipal. These are access-policy relationships; permission sets are not contained in ExternalCredential. There are no additional Metadata API access requirements specific to this type, but that does not imply unrestricted runtime use of its principals.
Authentication parameter combinations
-
Authentication providers: Use
parameterType=AuthProviderwithauthProvider, orparameterType=ExternalAuthIdentityProviderwithexternalAuthIdentityProvider. Both reference a service that handles login and approves access to the external system. -
Authentication endpoints:
AuthProviderUrlsupplies the authentication endpoint URL. For OAuth with JWT Bearer Flow, itsparameterValueis the token endpoint, not the external service's callout endpoint. -
Signing certificates:
SigningCertificateusescertificateto select a certificate by name. It is used forOauthwith JWT Bearer Flow and forAwsSv4STS with RolesAnywhere authentication. -
JWT claims: A JWT is a JSON Web Token.
JwtBodyClaimandJwtHeaderClaimuseparameterNameas the claim key andparameterValueas its value. Examples includeaudfor a body audience claim andkidfor a header key identifier. -
AWS Signature Version 4: Select
AwsSv4as the protocol.AuthParameterentries can supply settings such asAwsRegionandAwsService. These names identify settings; example region and service values are not defaults. -
AWS Security Token Service (STS):
AuthProtocolVariantcan select STS usingparameterName=AwsSv4andparameterValue=AwsSv4_STS. AnAwsStsPrincipalentry usesparameterName=AwsStsPrincipalwithout aparameterValue. -
AWS STS query parameters:
AuthProviderUrlQueryParameteris supported only for AWS Signature V4 with STS. The allowed query-parameter names areAwsExternalIdandAwsDuration. -
Custom authentication:
Customsupports user-defined authentication settings. For Simple URL data sources, the documented configuration isCustomwith no parameters.
Runtime headers and token refresh
AuthHeader adds a custom authentication header at callout time. Its parameterName must be the header name, and its parameterValue must be a formula evaluated at runtime. A retrieved formula is authentication logic, not necessarily the final header value sent to the external system.
AdditionalRefreshStatusCode extends the responses that trigger refresh of expired or invalid access tokens beyond the standard HTTP 401 response. It allows specified status codes in the 4xx, 6xx, 7xx, 8xx, and 9xx ranges. This setting changes token-refresh behavior, not just error labeling.
Deployment and Retrieval
ExternalCredential components use the .externalCredential suffix and reside in the externalCredentials folder. The type inherits fullName from Metadata. A package.xml manifest can select ExternalCredential members using the * wildcard. The nested parameter entries belong to the external credential definition, rather than being separate manifest members.
The configured references determine the dependency scope. A NamedCredential selects an ExternalCredential, whose parameters can select an authentication provider or signing certificate. Do not treat every possible parameter type as a dependency of every external credential.
Principal access is deployed separately from the authentication definition. A community PermissionSet example places enabled and externalCredentialPrincipal inside externalCredentialPrincipalAccesses, with enabled set to true. The principal reference has the form <ExternalCredentialName>-<ExternalCredentialParameterName>. The value after the hyphen is the principal's parameterName, not a record ID and not merely the credential name.
Credential-value provisioning can also require a separate operation. Reported ConnectApi patterns use ConnectApi.NamedCredentials.createCredential() after creating an OAuth client-credentials definition and principal, or patchCredential() to update an encrypted Custom authentication parameter. These operations provision values; they are not additional ExternalCredential metadata elements, and their inputs are not universal across protocols.
Keep ConnectApi request behavior separate from Metadata API deployment behavior. The reported requirement to create an external credential separately and pass only its developer name to createNamedCredential() concerns the shape of that ConnectApi request. It does not establish a universal Metadata API deployment-order rule.
Likewise, an empty parameter list returned by ConnectApi is not conclusive evidence that no values are configured. Reports about getExternalCredential() do not establish a universal Metadata API retrieval limitation.
Relationships
The authentication provider and certificate references are conditional on the parameter entries actually configured. Incoming references connect the definition to callout configuration and principal-access policies.
References
-
AuthProvider:authProvider. -
Certificate:certificate. -
ExternalAuthIdentityProvider:externalAuthIdentityProvider.
Referenced By
-
MutingPermissionSet:externalCredentialPrincipal. -
NamedCredential:externalCredential. -
PermissionSet:externalCredentialPrincipal.
Documentation Inconsistencies
-
Custom-header ordering is ambiguous. The
AuthHeaderdescription sayssequenceNumberorders headers from lower to higher numbers. ThesequenceNumberdefinition says that the field can be set only forNamedPrincipal. Those statements do not resolve whether or how header order can be configured. -
Some protocol values have conflicting support descriptions. The
authenticationProtocoldocumentation labelsJwtandPasswordas reserved for future use, but also directs readers to useJwtfor direct-token connections andPasswordfor on-premises Files Connect systems. It directs cloud-based Files Connect systems toOauth.JwtExchangeandNoAuthenticationare also documented as reserved. The enum alone is not confirmation that a particular flow is supported.
Reported Issues
-
Permission-set principal access can be represented separately from the credential definition. A 2023 community example deploys access through
externalCredentialPrincipalAccesses, containingenabledand the compositeexternalCredentialPrincipalname. The example identifies the principal using itsparameterNameafter the credential-name prefix. See the permission-set deployment example. -
Creating an OAuth definition and principal may leave client credentials to be provisioned separately. An April 2024 report uses
ConnectApi.NamedCredentials.createCredential()aftercreateExternalCredential()to populateclientIdandclientSecretfor OAuth client-credentials authentication. This is a reported provisioning pattern for that flow, not a universal parameter recipe. See the client-credential provisioning example. -
An encrypted Custom authentication value can be updated through a separate ConnectApi operation. A 2024 answer demonstrates
patchCredential()for a Custom external credential with aNamedPrincipaland an encrypted authentication parameter. See the authentication-parameter update example. -
An embedded, fully populated external-credential input can cause NamedCredential creation to fail. In a 2024 discussion,
createNamedCredential()returned "Provide only the developer name of the external credential." The reported resolution was to create the external credential separately, then pass anExternalCredentialInputcontaining only itsdeveloperName. See the ConnectApi creation discussion. -
Empty ConnectApi parameter lists do not reliably diagnose missing configuration. A May 2024 report describes
getExternalCredential()returning empty parameter lists for both the credential and its principals despite configured principal parameters. The discussion has no confirmed resolution and does not establish a universal retrieval limitation. See the parameter-retrieval report. - Managed-package creation was reported to fail when principal-access references were included. A 2025 second-generation managed-package report received "Invalid Cross Reference ID" while packaging a permission set containing external-credential principal access, despite including both credential definitions. Removing the access references avoided the reported error. The unanswered discussion does not establish the cause or a general packaging restriction. See the package-creation report.
Common Questions
What is the difference between ExternalCredential and NamedCredential?
ExternalCredential defines authentication protocols, principals, and authentication parameters. NamedCredential references it through externalCredential for callout authentication. An external credential's authentication-provider URL is distinct from the external service's callout endpoint.
How do I deploy External Credential Principal Access in a permission set?
The reported PermissionSet structure uses externalCredentialPrincipalAccesses with enabled set to true and an externalCredentialPrincipal value formatted as <ExternalCredentialName>-<ExternalCredentialParameterName>. Use the principal's parameterName after the hyphen, not a record ID.
How do I set an external credential's client ID and client secret from Apex?
For the reported OAuth client-credentials case, create the external credential and principal first, then use ConnectApi.NamedCredentials.createCredential() to populate clientId and clientSecret. This provisioning pattern does not establish the inputs for every authentication protocol.
Why does getExternalCredential return an empty parameters list?
A community report describes empty credential and principal parameter lists despite configured values, but it has no confirmed resolution. An empty ConnectApi response list alone does not prove that the principal has no configured values.
Does sequenceNumber control the order of authentication steps?
No. For NamedPrincipal, it sets selection priority when a user qualifies for multiple principals; lower numbers have higher priority. The documentation separately conflicts about its use for custom-header ordering.