Skip to content

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 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 Fields

This 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:

NameDescription
document_id__sysThe ID of the document with the attachment.
document_version_id__sysThe 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__sysThe unique attachment ID.
attachment_external_id__sysThe external ID (external_id__v) value of the attachment, if provided when creating the attachment.
attachment_version__sysThe attachment version.
file_name__sysThe filename of the attachment.
description__sysThe description of the attachment.
md5checksum__sysThe MD5 checksum for the attachment.
latest_version__sysBoolean indicating whether this is the latest version of the attachment.
created_date__sysThe date the attachment was created.
created_by__sysThe ID of the user who created the attachment.
modified_date__sysThe date the attachment was last modified.
modified_by__sysThe ID of the user who last modified the attachment.
format__sysThe file format of the attachment.
size__sysThe size of the attachment in bytes.
unclassified__sysBoolean indicating whether the attachment is unclassified.

Document Attachment Query Examples

Section link for Document Attachment Query Examples

Query: Retrieve All Attachments for a Specific Document Version

Section link for Query: Retrieve All Attachments for a Specific Document Version

The 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 = 101

Vault 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 Fields

The attachments__sysr relationship allows queries on the following fields:

NameDescription
idUnique ID for the attachment.
filename__vThe filename of the attachment.
format__vThe file format of the attachment.
size__vThe size of the attachment in bytes.
description__vThe description of the attachment.
version__vThe attachment version.

Query: Retrieve Attachments for a Specific Object Record

Section link for Query: Retrieve Attachments for a Specific Object Record

The 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