I have a callout where we use a Named Credential and it looks something like the following:

public class MyClass
    public MyClass()
        inputHttpHeaders_x = new Map<String, String>
            'Authorization' => 'Basic {!$Credential.AuthorizationHeaderValue}'
    public SomeType makeCallout(/*parameters*/)
            new String[]{
                // other parameters

Notice I am using an endpoint of callout:My_Credential and using $Credential.AuthorizationHeaderValue in my Authorization header.

This callout worked great in the development sandbox. When we deployed it to UAT along with the Named Credential, however, it didn't work. We were getting a 401 response. I changed the header to hard code the token and the callout worked, so it looked like a password issue. I edited the Named Credential record to reset the password to exactly what it was in the development environment, and the problem was resolved.

Do Named Credential records deploy without Password being populated? Or does the $Credential.AuthorizationHeaderValue just not get carried through? Is it possible to deploy a credential with either of these values intact?

  • A named credential metadata retrieve doesn't include the password, but one can be included in the metadata when it's deployed to the target org.
    – Mark Pond
    Aug 14, 2018 at 19:40
  • Possible duplicate of Migrating Named Credential with password
    – Mark Pond
    Aug 14, 2018 at 19:40
  • 1
    I'm not asking about ANT (using Change Sets). Still, I guess the answer is just "no".
    – Adrian Larson
    Aug 14, 2018 at 19:46
  • Yes. Sounds like it needs to be a post-deployment step for your process.
    – Mark Pond
    Aug 14, 2018 at 19:49
  • 1
    The Spring 15 release notes (when Named Credential became packageable and change-set-able) specify that the Credential must be re-authorized after installation from a package. In my experience, the same thing is true for change set deployments, but I've never seen it documented explicitly.
    – David Reed
    Aug 14, 2018 at 20:01

1 Answer 1


A retrieve of Named Credential metadata does not include the sensitive field data, including password.

That said, password data can be included in metadata during the deployment and the password will be set in the target org.

<?xml version="1.0" encoding="UTF-8"?>
<NamedCredential xmlns="http://soap.sforce.com/2006/04/metadata">
    <username>[email protected]</username>

You must log in to answer this question.

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