How to Find Vault Relationships
In order to perform VQL queries on Vault objects or documents, the query must use the exact inbound or outbound relationship name. There are several methods for finding the correct relationship name:
- Find the relationship in the Vault Admin UI
- Use
SHOW RELATIONSHIPS - Use the Vault API metadata endpoints
Before looking for the relationship name, you must first know:
- The primary query target.
- Whether you need the inbound or outbound relationship.
Learn more in About Join Queries.
Refer to the Query Targets documentation for information on relationships when the query target is not documents or a Vault object.
SHOW RELATIONSHIPS
Section link for SHOW RELATIONSHIPSUse the SHOW RELATIONSHIPS clause in a VQL query on the target object to retrieve the queryable relationships on the join target.
For example, the results of aSHOW query on product__v include approved_countries__cr:
{
"name": "approved_countries__cr",
"target": "approved_country__c",
"type": "inbound"
}This indicates that an inbound relationship exists on the Product object from the Approved Country object, and you can create a subquery using the inbound approved_countries__cr relationship name.
The Metadata APIs
Section link for The Metadata APIsThe relationship names to use in queries are exposed in the Document and Object Metadata APIs for fields of type ObjectReference when the objectType is a Vault object.
- Document Metadata API:
/api/{version}/metadata/objects/documents/properties - Object Metadata API:
/api/{version}/metadata/vobjects/{object name}
To find relationships on a document or object, search the metadata response for fields with the following attributes:
| Attribute | Value to Look For | Description |
|---|---|---|
type | ObjectReference | Confirms the field references an object. |
objectType | {object_name__v} | Indicates the target is a Vault object. This includes standard objects (__v) and custom objects (__c), but does not include users, groups, or workflows. |
relationshipType | reference, parent, child, reference_inbound, reference_outbound | Defines the nature of the relationship, which dictates whether you can use a subquery or lookup. |
relationshipName | {relationship_name__vr} or {relationship_name__cr} | The exact name to use in the VQL query. Standard object relationships end in __vr, and custom relationships end in __cr. |