We have developed an app and we are using named credentials (now legacy) to access an external API. Based on the those we also get the URL and build slightly changed iframe srces within the APP. At some Part we need to get all named credentials and their endpoints in Apex class like below:

List<NamedCredential> credentials = new List<NamedCredential>([select Id, DeveloperName, Endpoint from NamedCredential where DeveloperName = :namedCredential])

For the new named credentials the endpoint is null. Looking at the object reference for NamedCredential it seems that this field seems to be deprecated w/o any reference what will come next.

For the code it is essential to get the endpoint and as the legacy named credentials are soon out of support we need to use the new named credentials

Is there a way to get the endpoint of new named credentials? Has anybody faced this issue too? For New named credentials it is also possible to set the endpoint/url in the UI so there must be a way.

3 Answers 3


In Customizable Named Credentials, the endpoint is stored in a NamedCredentialParameter with type Url, rather than in the endpoint field of the Named Credential itself.

Per doc,


Type : NamedCredentialParamType (enumeration of type string)

Properties : Nillable Description: Required. The type of the named credential parameter. Valid values are:

Url: Specifies that this parameter configures the URL of the endpoint. Store the actual URL in the ParameterValue field.

  • Thanks Swetha, I missed that. Is there a way via Apex or Soql to retrieve the value for it? If yes do you habe an example for me please
    – Marc Bl.
    Jan 26, 2023 at 8:31
  • 1
    I've checked with our Salesforce team internally on this and got to know that the GET NamedCredential will be available in Connect API in 244(Safe Harbour). Considering that you would want to rewrite this code anyway, it is better to wait for 244(Summer'23) Jan 27, 2023 at 10:34

As Swetha mentioned, it could come to Apex in Summer'23.

I have checked, and I can see getExternalCredential(developerName) available that should give the info needed such as (doc):

  • authenticationProtocol
  • id
  • url

Note: I assume the new External Credential instead of Named Credentials.

  • 1
    Thanks for sharing Aug 2, 2023 at 10:42
  • 1
    Nah, thanks to you, Swetha and the team. In this case, I'm the messenger. Aug 2, 2023 at 10:59

You'll be able to do it starting Winter '24 release:

ConnectApi.NamedCredential nc = ConnectApi.NamedCredentials.getNamedCredential('MyNamedCredential');

The documentation of the new method is here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .