Attachments
You can use the attachments__sysr subquery relationship to query Vault object and document attachments when used as a subquery in the SELECT or WHERE clause of a query.
The attachments__sysr relationship is only supported on objects and documents with attachments enabled.
Document Attachments
Section link for Document AttachmentsDocument and archived document attachments are available for query in v24.1+. You can only query the attachments__sysr relationship as a subquery in the SELECT or WHERE clause.
Document Attachment Queryable Fields
Section link for Document Attachment Queryable FieldsThis metadata is only available via VQL query and cannot be retrieved using the standard metadata API.
The attachments__sysr relationship allows queries on the following fields:
| Name | Description |
|---|---|
document_id__sys | The ID of the document with the attachment. |
document_version_id__sys | The IDs of the document versions with the attachment. For example, ["123_0_1", "123_0_2", "123_1_0"] for a document with ID 123. This field has a value only when version-specific attachments are enabled in your Vault. Learn more in Vault Help |
attachment_id__sys | The unique attachment ID. |
attachment_external_id__sys | The external ID (external_id__v) value of the attachment, if provided when creating the attachment. |
attachment_version__sys | The attachment version. |
file_name__sys | The filename of the attachment. |
description__sys | The description of the attachment. |
md5checksum__sys | The MD5 checksum for the attachment. |
latest_version__sys | Boolean indicating whether this is the latest version of the attachment. |
created_date__sys | The date the attachment was created. |
created_by__sys | The ID of the user who created the attachment. |
modified_date__sys | The date the attachment was last modified. |
modified_by__sys | The ID of the user who last modified the attachment. |
format__sys | The file format of the attachment. |
size__sys | The size of the attachment in bytes. |
unclassified__sys | Boolean indicating whether the attachment is unclassified. |
Document Attachment Query Examples
Section link for Document Attachment Query ExamplesQuery: Retrieve All Attachments for a Specific Document Version
Section link for Query: Retrieve All Attachments for a Specific Document VersionThe following query retrieves attachment metadata for version 0.2 of document 101:
SELECT id,
(SELECT file_name__sys, attachment_id__sys, attachment_version__sys
FROM attachments__sysr
WHERE document_version_id__sys = '101_0_2')
FROM documents
WHERE id = 101Object Attachments
Section link for Object AttachmentsVault object attachments are available for query in v13.0+. You can only query the attachments__sysr relationship as a subquery in the SELECT or WHERE clause.
Object Attachment Queryable Fields
Section link for Object Attachment Queryable FieldsThe attachments__sysr relationship allows queries on the following fields:
| Name | Description |
|---|---|
id | Unique ID for the attachment. |
filename__v | The filename of the attachment. |
format__v | The file format of the attachment. |
size__v | The size of the attachment in bytes. |
description__v | The description of the attachment. |
version__v | The attachment version. |
Object Attachment Query Examples
Section link for Object Attachment Query ExamplesQuery: Retrieve Attachments for a Specific Object Record
Section link for Query: Retrieve Attachments for a Specific Object RecordThe following query retrieves attachment metadata for the record with ID 101 on the product__v object:
SELECT id,
(SELECT filename__v, size__v, version__v
FROM attachments__sysr)
FROM product__v
WHERE id = 101