System.CalloutException: Unauthorized endpoint: meaning and how to fix it
Quick answer
System.CalloutException: Unauthorized endpoint: Apex called an external URL that is not allowed: the URL is not registered as a Remote Site Setting, or it is not covered by a Named Credential. Start with: Prefer a Named Credential for the callout and use the callout: URL syntax.
Typical message: System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings.
Cause
Apex called an external URL that is not allowed: the URL is not registered as a Remote Site Setting, or it is not covered by a Named Credential.
How to fix System.CalloutException: Unauthorized endpoint
- Prefer a Named Credential for the callout and use the callout: URL syntax.
- Or add the exact base URL as a Remote Site Setting in Setup.
- Check the protocol and host; http and https are different.
Have a different message? Paste it into the error decoder, which matches it against 45 common Salesforce errors in your browser.
Frequently asked questions
What does System.CalloutException: Unauthorized endpoint mean in Salesforce?
Apex called an external URL that is not allowed: the URL is not registered as a Remote Site Setting, or it is not covered by a Named Credential.
How do I fix System.CalloutException: Unauthorized endpoint?
1. Prefer a Named Credential for the callout and use the callout: URL syntax. 2. Or add the exact base URL as a Remote Site Setting in Setup. 3. Check the protocol and host; http and https are different.
More Integration and API errors
SFDX Talk is unofficial documentation. It is not affiliated with, endorsed by, or sponsored by Salesforce, Inc. Message text varies slightly by release and context, so confirm against the official page before relying on it.