NamedCredential defines a named connection to a callout endpoint, including the endpoint URL and configuration for authenticated requests. Apex and other integrations can reference the connection by name instead of managing those details independently.
For parameter-based credentials, NamedCredential holds the endpoint and references an ExternalCredential, which controls authentication and permissions. These are separate metadata types: deploying the named connection is not proof that its authentication material or external-service access is ready. The Legacy model instead uses top-level endpoint and authentication fields.
Key Elements
Dotted names below identify fields nested inside namedCredentialParameters. Each entry is a NamedCredentialParameter, not an independently deployable component.
| Element | What the Element Controls |
|---|---|
label |
Required user-friendly name displayed in Salesforce. |
namedCredentialType |
Selects the configuration model: SecuredEndpoint, PrivateEndpoint, or Legacy. Standard is reserved for internal use. |
calloutStatus |
Enabled permits callouts through the credential; Disabled disables them. Enablement does not validate authentication. |
namedCredentialParameters |
Contains the parameter entries used to configure parameter-based credentials, including the URL, authentication reference, headers, certificates, and private connection. |
namedCredentialParameters.parameterName |
Required parameter name. For HttpHeader, this must be the actual HTTP header name. |
namedCredentialParameters.parameterType |
Required discriminator that determines which value or lookup field applies. Administrative values include Url, Authentication, ClientCertificate, HttpHeader, OutboundNetworkConnection, AllowedManagedPackageNamespaces, and ManagedByNamespace. |
namedCredentialParameters.parameterValue |
Stores the literal endpoint for Url. For HttpHeader, stores a formula evaluated at runtime, not merely an unqualified literal header value. For ManagedByNamespace, indicates subscriber-controlled or developer-controlled manageability. |
namedCredentialParameters.externalCredential |
References an ExternalCredential when parameterType is Authentication. The reference is not the authentication secret. |
namedCredentialParameters.certificate |
References a Certificate when parameterType is ClientCertificate. |
namedCredentialParameters.outboundNetworkConnection |
References an OutboundNetworkConnection when the parameter type has that name. Used for PrivateEndpoint. |
namedCredentialParameters.sequenceNumber |
Orders HttpHeader parameters. It does not establish a general authentication execution order. |
generateAuthorizationHeader |
Controls whether Salesforce generates and applies an authorization header to each callout using the credential. Defaults to true. |
allowMergeFieldsInHeader |
Allows Apex to populate request headers with org data through merge fields. Defaults to false. |
allowMergeFieldsInBody |
Allows Apex to populate the request body with org data through merge fields. Defaults to false, independently of the header setting. |
endpoint |
Top-level endpoint URL for Legacy only. Parameter-based credentials store their URL in a Url parameter instead. |
Behavior and Constraints
Setup access is different from callout authorization
Access to this metadata type requires View Setup and Configuration. That setup permission is separate from the authentication and permissions required to use the external service.
calloutStatus is the explicit callout enablement control. Setting it to Enabled does not establish that authentication succeeds or that the external identity has adequate permissions.
Credentials stored within NamedCredential are encrypted using org-specific keys. Encryption protects stored credentials; it does not establish that a metadata deployment reproduces authentication material in another org.
Interpret fields according to the credential type
-
SecuredEndpoint: Uses the extensible parameter model and external credentials for authentication and permissions. The endpoint belongs to the named credential, while anAuthenticationparameter references the external credential. -
PrivateEndpoint: Sends traffic through a private connection, bypassing the public internet. It requires anOutboundNetworkConnectionconfiguration through the nested parameter lookup. -
Legacy: Uses top-level fields such asendpoint,authProvider,protocol,principalType,username, andpassword. Do not interpret these as authentication configuration forSecuredEndpoint. -
Standard: Reserved for internal use.
The location of outboundNetworkConnection matters. The top-level field is valid only for Legacy. A PrivateEndpoint definition uses a namedCredentialParameters entry whose parameterType is OutboundNetworkConnection and whose nested outboundNetworkConnection field holds the reference.
For a parameter-based credential, an absent top-level endpoint does not mean the URL is missing. Locate the parameter whose parameterType is Url and read its parameterValue.
Headers and merge fields have separate controls
A merge field inserts org data into a request. allowMergeFieldsInHeader and allowMergeFieldsInBody independently enable that substitution in headers and the body. They control data sent to the external system; they are not permission classifications and do not establish that the transmitted data is appropriate.
A custom HttpHeader parameter has different value semantics from a Url parameter. Its parameterName is the header name, and its parameterValue must be a formula evaluated at runtime. Use sequenceNumber to order header parameters, not to infer an authentication sequence.
Deployment and Retrieval
NamedCredential components use the .namedCredential suffix and reside in the namedCredentials folder. The type inherits fullName from Metadata. A package.xml manifest can select named credentials by name or use * for wildcard retrieval. See file-based deployment and retrieval.
Parameter entries deploy inside the parent NamedCredential definition. They are not separate manifest members. Their externalCredential, certificate, and outboundNetworkConnection lookups identify separate configuration dependencies; the parameter entry itself does not contain the referenced component.
A retrieve-and-deploy copy is not proof that Legacy password authentication is ready in the destination. Community reports describe retrieval omitting sensitive values, including password, and a destination callout succeeding only after the password was re-entered. Reports conflict on whether explicitly supplying a password during deployment succeeds. Those reports do not establish a uniform secret-deployment rule and do not describe authentication material behind ExternalCredential.
Managed-package use and manageability
A parameter with parameterType set to AllowedManagedPackageNamespaces identifies managed-package namespaces permitted to use the named credential for callouts. This package-use control is separate from the authentication and permissions supplied through ExternalCredential.
ManagedByNamespace records manageability for a packaged named credential. Its parameterValue indicates subscriber-controlled or developer-controlled manageability, which affects who can administer the installed configuration.
Do not treat parameter types or flags marked for internal use as general-purpose administrative controls. For example, readOnlyNamedCredential, managedFeatureEnabledCallout, globalNamedPrincipalCredential, and systemUserNamedCredential are reserved for internal use.
Relationships
For parameter-based credentials, the main outgoing references are the external credential, client certificate, and private outbound connection. Legacy definitions have additional top-level references and formula-based dependencies. Incoming relationships identify possible consumers, not proof that any particular named credential is used by all of them.
References
-
AuthProvider:authProvider, forLegacyonly. -
Certificate:namedCredentialParameters.certificateforClientCertificateparameters; top-levelcertificateandjwtSigningCertificateforLegacy. -
CustomField: field references embedded in thejwtFormulaSubjectformula, forLegacyonly. -
ExternalCredential:namedCredentialParameters.externalCredentialforAuthenticationparameters. The external credential in turn references authenticated user credentials. -
OutboundNetworkConnection:namedCredentialParameters.outboundNetworkConnectionforPrivateEndpoint; top-leveloutboundNetworkConnectionforLegacy.
Referenced By
-
ApexClass: references embedded infiledata, rather than dedicated lookup elements. -
ApexTrigger: references embedded infiledata, rather than dedicated lookup elements. -
CareBenefitVerifySettings:serviceNamedCredential. -
CMSConnectSource:namedCredential. -
ConversationVendorInfo:namedCredential. -
EventRelayConfig:destinationResourceName. -
ExternalDataSource:namedCredential. -
ExternalServiceRegistration:namedCredential,namedCredentialReference. -
UserProvisioningConfig:namedCredential. -
VirtualVisitConfig:namedCredential.
Reported Issues
-
A null queried endpoint can be a representation issue, not a missing URL. In a 2023 report about parameter-based credentials, querying
NamedCredential.Endpointwith SOQL, Salesforce's query language, returned null. An answer usedConnectApi.NamedCredentials.getNamedCredential(developerName).calloutUrlto inspect the URL instead. Pass the credential's developer name, not its record ID. The queried object and ConnectApi response are separate representations, not additional metadata fields. Endpoint inspection discussion. -
A deployed Legacy credential can still return 401 until its destination password is supplied. In a 2018 migration report, re-entering the same password in the destination resolved the failure. The answer stated that retrieval omits sensitive values, including
password, but reported success deploying an explicitly supplied password. A separate 2019 answer stated that passwords cannot be deployed. These conflicting reports do not establish a general password-deployment rule or a rule for secrets behindExternalCredential. Password retrieval and deployment report; bulk-update discussion. -
A named-credential endpoint does not make a manually supplied Lightning session token valid for API access. In a 2022 report, Apex invoked from Lightning Web Components supplied
UserInfo.getSessionId()as a bearer token and receivedINVALID_SESSION_ID. The answer attributed the failure to a Lightning session that was not enabled for API access and recommended authenticated named-credential callouts rather than extracting an API-enabled session from that context. Lightning session callout discussion. -
An enum fault during Legacy-style create or update can indicate omitted identity and protocol fields. In a 2017 Metadata API report, requests containing only a name, label, and endpoint failed with an empty-value
ExternalPrincipalTypeenum fault. The accepted answer reported successful creation and update after addingprincipalTypeandprotocol, usingNamedUserandNoAuthenticationin that example. This was a top-level Legacy-style definition, not a parameter-based authentication example. Create and update enum-fault discussion. -
A packaged OAuth connection can still require subscriber completion of its authentication provider. A 2023 answer described packaging a named credential, an external credential for the parameter-based model, and an authentication provider, then having the subscriber admin supply the provider's client key and secret. It distinguished the direct Legacy
authProviderreference from the parameter-based model, where the external credential links to the provider. The answer also reported that updating the consumer secret of a partially packaged provider was not allowed through the API. Partially configured OAuth package discussion.
Common Questions
Why is my named credential endpoint null in SOQL?
Parameter-based credentials store the URL in a namedCredentialParameters entry of type Url, not in the top-level Legacy endpoint field. Community reports describe using ConnectApi.NamedCredentials.getNamedCredential(developerName).calloutUrl to inspect it at runtime.
Does deploying a named credential copy its password?
A retrieved Legacy definition is not proof that the destination has its password. Reports describe retrieval omitting sensitive values and disagree about deploying an explicitly supplied password. Those reports do not establish how authentication material behind ExternalCredential is handled.
Where do I configure the outbound connection for PrivateEndpoint?
Use a namedCredentialParameters entry with parameterType set to OutboundNetworkConnection and populate its nested outboundNetworkConnection lookup. The top-level field with the same name is Legacy-only.
Why does an enabled named credential still fail authentication?
calloutStatus set to Enabled only permits callouts. Authentication must still be configured successfully, and the external identity must have sufficient permissions. For parameter-based credentials, those concerns involve the referenced ExternalCredential.
Does allowing a managed-package namespace grant access to the external service?
No. AllowedManagedPackageNamespaces controls which managed-package namespaces may use the named credential for callouts. Authentication and external-service permissions remain separate, as does the packaged credential's subscriber-controlled or developer-controlled manageability.