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...)


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.

| improve this answer | |
  • How do add the API key from the named credential password? – Monish Nov 7 '18 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.