Define a Legacy Named Credential
Create a legacy named credential to specify the URL of a callout endpoint and its required authentication parameters in one definition. You can then specify the legacy named credential as a callout endpoint to let Salesforce handle all authentication. You can also skip remote site settings, which are otherwise required for callouts to external sites, for the site defined in the legacy named credential.
Required Editions
| Available in: both Salesforce Classic and Lightning Experience |
| Available in: All Editions |
| User Permissions Needed | |
|---|---|
| To view legacy named credentials: | View Setup and Configuration |
| To create, edit, or delete legacy named credentials: | Manage Named Credentials or Customize Applications |
Legacy named credentials are supported in these types of callout definitions:
- Apex callouts
- External data sources of these types:
- Salesforce Connect: OData 2.0
- Salesforce Connect: OData 4.0
- Salesforce Connect: Custom (developed with the Apex Connector Framework)
- Salesforce Connect: Amazon DynamoDB
- External Services
To set up a legacy named credential:
- From Setup, enter Named Credentials in the Quick Find box, then select Named Credentials.
- To create a legacy named credential, click New Legacy from the dropdown menu. To edit an existing legacy credential, click its link and click Edit.
- Enter information in the fields.
- Select the authentication protocol.
- If you select Password Authentication, enter the username and password for accessing the external system.
- If you select OAuth 2.0, complete the following fields.
Field Description Authentication Provider Choose the provider. See Authentication Providers. Scope Specifies the scope of permissions to request for the access token. Your authentication provider determines the allowed values. See Use the Scope Parameter.
- The value that you enter replaces the Default Scopes value that’s defined in the specified authentication provider.
- Whether scopes are defined can affect whether each OAuth flow prompts the user with a consent screen.
- We recommend that you request a refresh token or offline access. Otherwise, when the token expires, you lose access to the external system.
Start Authentication Flow on Save To authenticate to the external system and obtain an OAuth token, select this checkbox. This authentication process is called an OAuth flow.
When you click Save, the external system prompts you to log in. After successful login, the external system grants you an OAuth token for accessing its data from this org.
Redo the OAuth flow when you need a new token—for example, if the token expires—or if you edit the Scope or Authentication Provider fields. When the token expires, the external system returns a 401 HTTP error status.
- If you select JWT or JWT Token
Exchange, complete the following fields.
Field Description Issuer Specify who issued the JWT using a case-sensitive string. Scope JWT Token Exchange only. Determines the permissions associated with the tokens that you’re requesting. Token Endpoint URL JWT Token Exchange only. The URL of the authorization provider. JSON Web Token requests are sent to the provider in exchange for access tokens. Per User Subject Per User identity type only. Formula string calculating the JWT’s subject. Include API names and constant strings in quotes. Allows a dynamic subject unique per user requesting the token. For example, 'User='+$User.Id. Named Principal Subject Named Principal identity type only. Enter static text, without quotes, that specifies the JWT subject. Audiences External service or other allowed recipients for the JWT. Store each audience as a case-sensitive string on a new line. Token Valid for The length of time that the token is valid to authenticate the user into the external system. JWT Signing Certificate Certificate verifying the JWT’s authenticity to external systems. - If you select AWS Signature Version 4, complete the following fields.
Field Description AWS Access Key ID First part of the access key used to sign programmatic requests to AWS. AWS Secret Access Key Second part of the access key used to sign programmatic requests to AWS. AWS Region The AWS region name for the legacy named credential’s endpoint. For example, us-east-1. AWS Service The AWS utility to access.
- If you want to use custom headers or bodies in the callouts, enable the relevant
options.
Field Description Generate Authorization Header By default, Salesforce generates an authorization header and applies it to each callout that references the legacy named credential.
Deselect this option only if one of the following statements applies.
- The remote endpoint doesn’t support authorization headers.
- The authorization headers are provided by other means. For example, in Apex callouts, the developer can have the code construct a custom authorization header for each callout.
This option is required if you reference the legacy named credential from an external data source.
Allow Merge Fields in HTTP Header
Allow Merge Fields in HTTP Body
In each Apex callout, the code specifies how the HTTP header and request body are constructed. For example, the Apex code can set the value of a cookie in an authorization header.
These options enable the Apex code to use merge fields to populate the HTTP header and request body with org data when the callout is made.
These options aren’t available if you reference the legacy named credential from an external data source.
To reference a legacy named credential from a callout definition, use the legacy named
credential URL. A legacy named credential URL contains the scheme callout:, the name of the legacy named credential, and an
optional path. For example: callout:My_Named_Credential/some_path.
You can append a query string to a legacy named credential URL. Use a question mark (?) as the separator between the legacy named
credential URL and the query string. For example: callout:My_Named_Credential/some_path?format=json.

