In order to do something, we need to make call outs to an external server where the URL takes the format:


The external-id would be specific to and stored in individual records and swapped out for each call.

The api-key would normally be a "fixed" value, although it might (of course) occasionally be updated. And our production org would call a different server instance than our sandboxes (which may or may not share the test server) and (of course) this key would be different than production.

(In the medium/long run, we might change the API since putting the key in the URL doesn't seem like a great idea... but til then...)

1 Answer 1


Using a custom authentication scheme negates part of the benefit of using Named Credentials, but you can still do so. Assuming the endpoint is:


Your code would look like:

    new String[] { externalId, apiKey }));

Ideally, you should move to OAuth or even Basic Authentication, which reduces your complexity to just:

    new String[] { externalId }));

And eliminates the need to store the API key in a custom setting/custom label/etc since it will be managed by the system, which is part of the benefit of using Named Credentials.

  • How do add the API key from the named credential password?
    – Monish
    Commented Nov 7, 2018 at 10:45

You must log in to answer this question.

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