RemoteSiteSetting registers a remote endpoint for outbound access from Salesforce, including Apex callouts and Visualforce integrations. For calls subject to Remote Site Settings authorization, the external site must be registered or the call fails. The setting authorizes access to an endpoint; it does not implement the integration or identify every caller that uses it.
A remote site setting is metadata, not an ordinary Apex-queryable data record. Its metadata name, fullName, is distinct from both the endpoint url and a Tooling API RemoteProxy record ID.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
The component's metadata identity, inherited from Metadata. Required when creating, updating, or deleting through Metadata API. The name must start with a letter, must not end with an underscore, and must not contain consecutive underscores. |
url |
Required. The remote site's URL. Changing this value changes the endpoint registered by this component, not the component's metadata identity. |
isActive |
Required boolean. true activates the setting; false leaves the definition present but inactive. |
disableProtocolSecurity |
Required boolean. true permits access regardless of whether the user's connection uses HTTP or HTTPS, including data transfer between HTTPS and HTTP sessions. This is a relaxation of protocol protection, not an activation switch. |
description |
Explains the setting's intended purpose. It does not establish which integrations currently use the endpoint. |
Behavior and Constraints
Interpret url and isActive together. An inactive definition is not active authorization for its endpoint. Changing the URL, deactivating the setting, or deleting it can affect callers that depend on that registration. Conversely, the presence of an active setting does not prove that any integration still uses it.
disableProtocolSecurity controls a separate security boundary. Setting it to true allows Salesforce code to pass data between HTTP and HTTPS sessions, including from an HTTPS session to an HTTP session. It does not activate an inactive remote site setting. Treat this value as an explicit security decision rather than a way to resolve an authorization failure.
For Salesforce-hosted endpoints, the hostname selected by the calling code can matter. A call made from a Flow execution context can use a different domain from one made through anonymous Apex. The reported Flow case below was diagnosed as endpoint selection, not as a general requirement to register every Salesforce-hosted URL.
Deployment and Retrieval
In Metadata API format, components belong in the remoteSiteSettings directory of the package. The filename matches the remote site's unique name and uses the .remoteSite extension, for example MappingService.remoteSite. The XML root is RemoteSiteSetting. See the Salesforce metadata reference.
In Salesforce DX source format, the corresponding file uses .remoteSite-meta.xml, for example force-app/main/default/remoteSiteSettings/MappingService.remoteSite-meta.xml. A community-supported scratch-org workflow is to create the setting as source metadata, or retrieve an existing setting from an org, and then deploy that file. This keeps the component separate from scratch-org definition settings.
Metadata API create, update, and delete operations identify the component by fullName. Do not substitute the endpoint URL or a RemoteProxy record ID. Include all three required values when defining the setting: url, isActive, and disableProtocolSecurity.
Creating a remote site setting through an Apex call to Metadata API can encounter an authorization prerequisite: the administrative callout may itself need an authorized endpoint. A community discussion identifies an existing remote site setting or a Named Credential as possible routes. Calling Metadata API from Apex does not, by itself, remove that prerequisite.
Managed-package removal and subscriber cleanup are separate concerns. A 2023 report states that deleting a remote site setting in the packaging org removed it from subsequent clean installations, but upgrades left previously installed settings in subscriber orgs. Under that reported behavior, a successful package upgrade does not demonstrate that the old endpoint authorization has disappeared.
Reported Issues
-
Ordinary Apex SOQL is not the reported inventory route. A discussion begun in 2014 reports that
RemoteSiteSettingis not an ordinary Apex-queryable sObject. A 2020 answer gives the Tooling API querySELECT Id, SiteName, EndpointUrl FROM RemoteProxy. Run that query through Tooling API, and keep its recordIdseparate from the metadatafullName. Querying remote site settings. -
An "Unauthorized endpoint" error can be caused by selecting the wrong Salesforce hostname. In a 2022 report, Apex calling Salesforce REST API worked from anonymous Apex but failed when invoked from Flow, where the endpoint used a Visualforce hostname. The answer attributed this to the execution-context domain and recommended
Url.getOrgDomainUrl()to obtain the canonical org domain. This is a context-specific diagnosis, not proof that all Salesforce-hosted calls require another setting. Flow and Salesforce REST endpoint diagnosis. - Apex automation can need authorization before it can create the setting intended to authorize later calls. A 2019 discussion describes this initial authorization problem for Metadata API and Tooling API calls from Apex, identifying an existing remote site setting or a Named Credential as possible authorization routes. Creating a setting from Apex.
- A managed-package upgrade can retain an endpoint registration removed from the package. A 2023 report says that deleting the setting through Setup in the packaging org excluded it from clean installations, while subscriber upgrades retained the previously installed setting. Package removal therefore did not perform subscriber cleanup in that case. Managed-package removal behavior.
-
Scratch-org setup can use a deployable source file rather than an entry in the scratch-org definition. A 2021 answer recommends placing a
.remoteSite-meta.xmlfile underforce-app/main/default/remoteSiteSettings/. It also describes retrieving a setting created in an org and deploying the resulting file to another org. Remote site settings in scratch orgs. -
Query access to
RemoteProxyshould not be treated as an Apex deletion mechanism. In a 2020 discussion about failed deletion attempts, the answer directed the caller to a metadata deployment targetingRemoteSiteSetting, rather than ordinary Apex data operations. It also identified uninstalling the containing package as a removal route. Deleting a remote site setting from Apex. - Success from an external development tool does not demonstrate that an Apex callout is authorized. A 2017 Tooling API discussion distinguishes outbound calls made by Apex from calls made by an external tool's own software stack. The reported Apex call required endpoint authorization even though external tools could access the API without the same Salesforce outbound-call restriction. Tooling API calls from Apex versus external tools.
Common Questions
Can I query RemoteSiteSetting from Apex?
Not as an ordinary Apex sObject, according to the reported behavior. For inventory, the community describes querying RemoteProxy through Tooling API with SELECT Id, SiteName, EndpointUrl FROM RemoteProxy. The returned record ID is not the metadata fullName.
Where does a RemoteSiteSetting file go for deployment?
Metadata API format uses remoteSiteSettings/Name.remoteSite. Salesforce DX source format uses a file such as force-app/main/default/remoteSiteSettings/Name.remoteSite-meta.xml. An existing setting can be retrieved to obtain a source file for deployment.
Does disableProtocolSecurity activate a remote site setting?
No. isActive controls activation. disableProtocolSecurity controls whether access can cross HTTP and HTTPS session boundaries; setting it to true relaxes protocol protection.
Can Apex create a remote site setting automatically?
Apex can call Metadata API to create the component, but the administrative callout can itself require endpoint authorization. The reported authorization routes include an existing remote site setting or a Named Credential.
Does removing a remote site setting from a managed package remove it from subscribers?
Not necessarily. A 2023 report found that clean installations excluded the removed setting, while upgrades retained it in subscriber orgs. Treat package removal and subscriber cleanup as separate actions under that reported behavior.