CspTrustedSite defines a named trusted URL for browser security policies. Its Content Security Policy (CSP) directives allow selected resource types to load from that URL for Lightning components, third-party API integrations, and WebSocket connections. Its permissions policy directives can allow camera or microphone access when the corresponding org-level policy is enabled.
The inherited fullName identifies the metadata component; endpointUrl identifies the trusted destination. An active entry is not blanket permission for every use of a domain. Also distinguish this Metadata API type from the similarly named CspTrustedSite sObject used through other Salesforce APIs.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
The metadata component's unique name, inherited from Metadata. This is not the destination URL. |
endpointUrl |
Required trusted destination. Must include a domain name; can include a port or a wildcard such as *.example.com. Third-party API URLs must start with https://; WebSocket URLs must start with wss://. |
isActive |
Required activation flag. Defaults to true, but activation alone does not grant every resource or browser-feature permission. |
context |
Scopes CSP directives. Values are All, Communities, FieldServiceMobileExtension, LEX, VisualForce, and LightningOut. LightningOut is reserved for future use. |
isApplicableToConnectSrc |
Allows URL loading through script interfaces, including third-party API and WebSocket connections. Defaults to false. |
isApplicableToFontSrc |
Allows fonts from the trusted URL. Defaults to false. |
isApplicableToFrameSrc |
Allows external resources loaded within <iframe> elements. Defaults to false. This is not permission for another domain to frame org-served content. |
isApplicableToImgSrc |
Allows images from the trusted URL. Defaults to false. |
isApplicableToMediaSrc |
Allows audio and video from the trusted URL. Defaults to false. |
isApplicableToStyleSrc |
Allows stylesheets from the trusted URL. Defaults to false. |
canAccessCamera |
Allows camera access only when the org's permissions policy settings permit trusted URLs to use the camera. Defaults to false. |
canAccessMicrophone |
Allows microphone access only when the org's permissions policy settings permit trusted URLs to use the microphone. Defaults to false. |
mobileExtension |
Reserved for future use. Do not confuse it with the supported FieldServiceMobileExtension context value. |
Behavior and Constraints
Activation and resource permissions
Effective CSP trust depends on the combination of endpointUrl, isActive, context, and the selected isApplicableTo fields. Each resource permission is independent. For example, allowing images does not allow script-interface connections or iframe content.
All isApplicableTo fields, canAccessCamera, and canAccessMicrophone default to false. At least one of these resource or browser-feature permission fields must be true; an entry cannot leave all of them false.
CSP context
-
Allapplies CSP directives to all supported contexts. -
Communitiesapplies them to Experience Builder sites. -
FieldServiceMobileExtensionapplies them to Field Service Mobile Extensions. -
LEXapplies them to Lightning Experience pages. -
VisualForceapplies them to custom Visualforce pages. -
LightningOutis reserved for future use.
For a custom Visualforce page, content is restricted to trusted URLs only when the page's cspHeader attribute is true. Creating a trusted URL with VisualForce or All does not enable that restriction on the page.
Camera and microphone prerequisites
Camera and microphone permissions depend on SecuritySettings in the destination org:
-
canAccessCameratakes effect only whenenablePermissionsPolicyistrueandgrantCameraAccessisTrustedUrls. -
canAccessMicrophonetakes effect only whenenablePermissionsPolicyistrueandgrantMicrophoneAccessisTrustedUrls.
Deploying either flag as true therefore does not, by itself, establish an effective browser-feature permission.
Effective policy and header size
The trusted-URL component inventory is not the complete effective CSP allowlist. Salesforce includes product-integration URLs in the directives corresponding to the isApplicableTo fields even when those URLs have no CspTrustedSite component. Salesforce updates these URLs as integration requirements change.
When multiple domains are allowed to frame content served by the org, keep the CSP header below the recommended size of 12 KB. Infrastructure limits vary; Salesforce notes customer-reported issues near 16 KB, and third parties can add to the header during processing. This framing scenario is separate from isApplicableToFrameSrc, which controls external content loaded inside iframe elements.
Deployment and Retrieval
In Metadata API format, components are stored in the package's cspTrustedSites directory. The filename matches the trusted URL's unique name and uses the .cspTrustedSite extension. The type supports * as a member wildcard in the package.xml manifest.
Construct parameterized URLs before assigning endpointUrl. This type does not resolve placeholders: https://{subdomain}.example.com fails syntax validation, as does malformed^url.example.com. A domain name is required, and the scheme must match the documented requirements for third-party APIs or WebSocket connections.
Malformed entries that remain in an org are excluded from generated CSP HTTP headers. Their presence in Setup or a retrieved inventory does not establish an effective allowance. Remove malformed entries to keep the inventory accurate. An Apex class can be used to identify malformed URLs.
CspTrustedSite can be included in managed packages, but packaging has security effects beyond the packaged component: third-party API and WebSocket permissions can affect sites and pages across the org. Managed-package guidance discourages including these entries. It recommends customer-managed allowlisting through Setup or Metadata API during package activation, or prominent disclosure of the security change when entries are packaged.
Apex administration through the CspTrustedSite sObject is a separate API path. A REST sObject POST callout is not a Metadata API deployment, and the ability to query the sObject does not establish support for Apex insert DML.
Relationships
SecuritySettings supplies the org-level policy gates for canAccessCamera and canAccessMicrophone through enablePermissionsPolicy, grantCameraAccess, and grantMicrophoneAccess. Custom Visualforce page markup supplies the separate cspHeader prerequisite. These are policy interactions rather than component-name references in endpointUrl.
Documentation Inconsistencies
The usage rule refers to fields starting with grantAccess or isApplicableTo, while the field-level rule refers to canAccess or isApplicable. The defined browser-feature elements are canAccessCamera and canAccessMicrophone, not grantAccess elements. Use the defined fields when satisfying the requirement that at least one permission be true.
Reported Issues
- A managed-package installation may request consent for trusted URLs. In March 2023, a package developer reported a consent popup during installation. The discussion also quotes Salesforce's guidance against packaging these entries because of their broader security effect. The report does not establish consent behavior for every installation mechanism. See the managed-package installation discussion.
-
Direct Apex insert DML was reported as disallowed for the sObject. An August 2023 answer describes creating
CspTrustedSitethrough a Salesforce REST sObject POST callout instead. This concerns sObject administration, not deployment of this Metadata API type. See the Apex creation discussion. -
Apex query availability should not be mistaken for DML support. A 2021 community inventory lists the
CspTrustedSitesObject as queryable in Apex. That finding concerns querying the sObject, not creating or deploying metadata. See the Apex queryability discussion. -
Trusted-URL configuration may be visible through an Experience Cloud site's Aura endpoint. In a 2026 discussion, a respondent reported seeing a
CspTrustedSiteentry during tests of an Aura-based site, including an inactive site. The report distinguishes configuration visibility from access to protected business data and does not establish a general data-access vulnerability. See the Experience Cloud configuration visibility discussion.
Common Questions
Why is a URL still blocked when its CspTrustedSite entry is active?
isActive is only one part of the policy. The destination, context, and resource-specific flag must match the use. Allowing images, for example, does not allow script-interface connections. Malformed entries are excluded from generated CSP headers.
Why do canAccessCamera and canAccessMicrophone have no effect after deployment?
The destination org must have SecuritySettings.enablePermissionsPolicy set to true. The corresponding grantCameraAccess or grantMicrophoneAccess setting must also equal TrustedUrls.
How do I retrieve all CspTrustedSite components?
Use CspTrustedSite as the type and * as the member in package.xml. Metadata API files belong in cspTrustedSites and use the .cspTrustedSite extension. The retrieved components do not represent every URL Salesforce includes in effective CSP directives.
Does a VisualForce trusted URL enable CSP restrictions on a Visualforce page?
No. The page's cspHeader attribute must be true before its content is restricted to trusted URLs. A VisualForce or All entry alone does not enable that restriction.
Can I create CspTrustedSite with Apex insert DML?
Direct insert DML was reported as disallowed for the CspTrustedSite sObject. The reported alternative uses a Salesforce REST sObject POST callout. That is separate from deploying a CspTrustedSite metadata component.