Documents
Use the documents object to query Vault documents.
To retrieve document fields and field properties, use the Retrieve All Document Fields API. To retrieve document and binder relationships, use the Retrieve Document Type Relationships API.
Query results do not include archived documents by default. In v15.0+, you can use the archived_documents object to query archived documents.
Document archive is not available in all Vaults. Learn more in Vault Help
By default, documents and archived_documents queries return the latest document version. To retrieve all versions or retrieve the latest version that meets a condition, use the ALLVERSIONS and LATESTVERSION query target options.
Document Query Examples
Section link for Document Query ExamplesThe following are examples of common document queries.
Query: Retrieve the Latest Version of a Document
Section link for Query: Retrieve the Latest Version of a DocumentThe following query retrieves the ID and latest version number of all documents called “WonderDrug Information”:
SELECT id, minor_version_number__v, major_version_number__v
FROM documents
WHERE name__v = 'WonderDrug Information'Response: Retrieve the Latest Version of a Document
Section link for Response: Retrieve the Latest Version of a DocumentThis response returns the latest version of the document, version 2.2.
{
"responseStatus": "SUCCESS",
"responseDetails": {
"pagesize": 1000,
"pageoffset": 0,
"size": 1,
"total": 1
},
"data": [
{
"id": 534,
"minor_version_number__v": 2,
"major_version_number__v": 2
}
]
}Query: Filter Documents by Redaction Origin
Section link for Query: Filter Documents by Redaction OriginThe redaction__sys version-level document field records whether a document version has associated redaction versions. The field returns null when the document version has no associated redactions. When set, possible values are Source (this version produced a redacted document) and Redacted (this document is a Redacted Document). The field is system-managed and not user-editable.
The following query retrieves all document versions where redaction__sys is Source:
SELECT id, name__v, major_version_number__v, minor_version_number__v, redaction__sys
FROM documents
WHERE redaction__sys = 'Source'Response: Filter Documents by Redaction Origin
Section link for Response: Filter Documents by Redaction Origin{
"responseStatus": "SUCCESS",
"responseDetails": {
"pagesize": 1000,
"pageoffset": 0,
"size": 1,
"total": 1
},
"data": [
{
"id": 1601,
"name__v": "Full Patient Brochure",
"major_version_number__v": 0,
"minor_version_number__v": 1,
"redaction__sys": [
"Source"
]
}
]
}Query: Retrieve Redacted Documents
Section link for Query: Retrieve Redacted DocumentsThe following query retrieves document versions that are themselves redacted documents:
SELECT id, name__v, major_version_number__v, minor_version_number__v, redaction__sys
FROM documents
WHERE redaction__sys = 'Redacted'Response: Retrieve Redacted Documents
Section link for Response: Retrieve Redacted Documents{
"responseStatus": "SUCCESS",
"responseDetails": {
"pagesize": 1000,
"pageoffset": 0,
"size": 1,
"total": 1
},
"data": [
{
"id": 1602,
"name__v": "Redacted - Full Patient Brochure",
"major_version_number__v": 1,
"minor_version_number__v": 0,
"redaction__sys": [
"Redacted"
]
}
]
}