Newer Version Available

This content describes an older version of this product. View Latest

NamedCredential

Represents a named credential, which specifies the URL of a callout endpoint and its required authentication parameters in one definition. A named credential can be specified as an endpoint to simplify the setup of authenticated callouts.

This type extends the Metadata metadata type and inherits its fullName field.

File Suffix and Directory Location

NamedCredential components have the suffix .namedCredential and are stored in the namedCredentials folder.

Version

NamedCredential components are available in API version 33.0 and later.

Fields

Field Name Field Type Description
authProvider string The authentication provider that the AuthProvider component represents.
certificate string If you specify a certificate, your Salesforce org supplies it when establishing each two-way SSL connection with the external system. The certificate is used for digital signatures, which verify that requests are coming from your org.
endpoint string The URL or root URL of the callout endpoint. Corresponds to URL in the user interface.
label string A user-friendly name for the named credential that appears in the Salesforce user interface, such as in list views.
oauthRefreshToken string The OAuth refresh token. Used to obtain new access tokens for an end user when old tokens expire.
oauthScope string Specifies the scope of permissions to request for the access token. Corresponds to Scope in the user interface.
oauthToken string The access token that’s issued by your authorization server.
password string The password to be used by your org to access the external system. Ensure that the credentials have adequate privileges to access the external system. Depending on how you set up access, you might need to provide the administrator password.
principalType External​PrincipalType(enumeration of type string) Determines whether you're using one set or multiple sets of credentials to access the external system. Corresponds to Identity Type in the user interface. The valid values are:
  • Anonymous
  • PerUser
  • NamedUser
protocol Authentication​Protocol(enumeration of type string) The authentication protocol for accessing the external system. The valid values are:
  • NoAuthentication
  • Oauth
  • Password
username string The username to be used by your org to access the external system. Ensure that the credentials have adequate privileges for performing callouts to the external system. Depending on how you set up access, you might need to provide the administrator username.

Declarative Metadata Sample Definition

The following is an example of a NamedCredential component.

1<?xml version="1.0" encoding="UTF-8"?>
2<NamedCredential xmlns="http://soap.sforce.com/2006/04/metadata">
3<endpoint>https://my_endpoint.example.com</endpoint>
4<label>My Named Credential</label>
5<principalType>PerUser</principalType>
6<protocol>NoAuthentication</protocol>
7</NamedCredential>