Document represents a file and its descriptive and access-related metadata stored in a Salesforce document folder. Documents can supply shared images, branding resources, email attachments, and portal content to other metadata components. Every document must belong to a document folder.
This type extends MetadataWithContent, inheriting content and fullName. Its component identity is distinct from its filename: fullName includes the folder name but excludes the file extension, while a retrieved content file can retain its extension.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
The unique, folder-qualified component name, such as sampleFolder/TestDocument, without the file extension. The document-name portion must begin with a letter and contain only alphanumeric characters and underscores. Spaces, a trailing underscore, and consecutive underscores are not allowed. |
content |
The document's binary content, represented as base64-encoded data in API calls. Inherited from MetadataWithContent. |
internalUseOnly |
Required boolean. true marks the document as confidential. It cannot be true when public is also true. |
public |
Required boolean. true makes an image available for HTML email templates without requiring Salesforce authentication to view it in an email. Set it to false for a custom application logo or custom tab icon. |
description |
Descriptive text that distinguishes the document from other documents. |
keywords |
Words describing the document. Searches check this field for matching words. |
Behavior and Constraints
internalUseOnly and public are separate settings, not opposites. Both are required, and their values must be considered together:
-
internalUseOnly=trueandpublic=false: the document is marked confidential. -
internalUseOnly=falseandpublic=true: an image can be available for HTML email without Salesforce authentication. - Both values can be
false. - Both values cannot be
true.
The public setting is documented for externally viewable images. It is not a general anonymous file-sharing setting for PDFs, Word documents, or other non-image files.
Images used as a custom application logo or custom tab icon require Salesforce authentication. For those uses, set public=false; do not enable it merely because the document is an image.
Deployment and Retrieval
Manifest entries and folder discovery
Document does not support the wildcard * in package.xml, the retrieval and deployment manifest. Identify each document explicitly by its folder-qualified fullName, such as sampleFolder/TestDocument, under the Document type.
Use listMetadata() with type DocumentFolder to discover folders when assembling explicit retrieval entries. Do not rely on describeMetadata() to return DocumentFolder as a separate type: it returns Document with inFolder=true. For this folder-based type, appending Folder to the component type name gives the folder metadata type name.
Content files and component names
The file-based package representation contains separate content and metadata files. For example, a document can have all three of these identifiers:
- Component
fullName:sampleFolder/TestDocument - Content file:
documents/sampleFolder/TestDocument.png - Accompanying metadata file:
documents/sampleFolder/TestDocument.png-meta.xml
The extension remains part of the filename in this example, but not the component's fullName. Documents do not require a file extension.
In API calls, clients must encode binary content as base64 before sending it and decode returned base64 content back to binary. SOAP clients commonly handle that conversion. This transport representation does not mean that the content file in a retrieved package is stored as base64 text.
Folder deletion and the Recycle Bin
Deleting a document folder can permanently delete recycled documents. Salesforce permits deletion of a folder containing documents that were moved to the Recycle Bin. Deleting that folder permanently removes those related documents from the Recycle Bin.
Relationships
DocumentFolder is the folder container for documents; folder membership is reflected in fullName, not in an outgoing reference element. The elements below belong to consuming metadata types and point to Document. A single document can serve several branding or communication configurations, so the impact of changing its content or deleting it depends on its actual references.
Referenced By
-
ChatterExtension:icon -
Community:emailHeaderDocument,emailFooterDocument -
CustomApplication:logo -
CustomTab:icon -
EmailTemplate:attachedDocuments -
Letterhead:logo -
Network:emailFooterLogo,smallImage -
NetworkBranding:loginLogo,pageHeader,pageFooter -
Portal:headerDocument,footerDocument,loginHeaderDocument,logoDocument,stylesheetDocument -
WaveApplication:assetIcon
Reported Issues
-
A non-image login redirect does not by itself indicate a failed metadata deployment. In September 2015, an admin reported that an image opened anonymously through
servlet.ImageServer, while PDF and Word documents redirected to Salesforce login. All three documents had "Externally Available Image" selected. The reported distinction is consistent with the image-specific scope ofpublic, rather than a general anonymous-download setting. Read the anonymous document access discussion.
Common Questions
Can I retrieve all Documents with a wildcard in package.xml?
No. Document does not support * in the manifest. Use explicit folder-qualified names. For folder discovery, call listMetadata() with type DocumentFolder, even though describeMetadata() does not list that folder type separately.
Does public=true make a PDF or Word document anonymously accessible?
It is not documented to do so. public controls externally viewable images for HTML email templates. A community report described PDF and Word documents redirecting to login even when "Externally Available Image" was selected.
Should a Document fullName include the file extension?
No. Use a folder-qualified name such as sampleFolder/TestDocument. The retrieved content file can still be named TestDocument.png, with accompanying metadata in TestDocument.png-meta.xml.
What happens to recycled documents when I delete their folder?
Salesforce permanently deletes the related documents from the Recycle Bin when you delete their document folder.