Actions100
- Activity Actions
- Asset Actions
- Authentication Actions
- Collection Actions
- Extension Actions
- Field Actions
- File Actions
- Folder Actions
- Item Actions
- Permission Actions
- Preset Actions
- Relation Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
Overview
The Directus - Relation: List All operation in n8n allows you to retrieve all relation definitions from a Directus instance. Relations in Directus define how collections (tables) are linked together, such as one-to-many or many-to-many relationships. This node is useful for:
- Schema introspection: Understanding how your data collections are related.
- Automation: Dynamically generating documentation or building tools that depend on the structure of your database.
- Data migration or integration: Mapping relationships when syncing or transforming data between systems.
Example use cases:
- Fetching all relations to generate an ER diagram.
- Auditing or reporting on schema changes.
- Building dynamic forms or UI components based on relational metadata.
Properties
Name | Type | Meaning |
---|---|---|
Return All | boolean | If enabled, returns all relation records; if disabled, limits the number of results returned according to the "Limit" property. |
Limit | number | The maximum number of relation objects to return. Only used if "Return All" is set to false. Must be between 1 and 100. |
Split Into Items | boolean | If enabled, outputs each relation as a separate item in the workflow. If disabled, returns all relations in a single item. |
JSON/RAW Parameters | boolean | If enabled, allows you to specify query parameters as raw JSON instead of using the UI fields. |
Query Parameters | json | Custom query parameters as a flat JSON object. Only available if "JSON/RAW Parameters" is enabled. |
Additional Fields | collection | Extra options for filtering, aggregating, exporting, and customizing the response. Includes advanced features like aggregation, export format, field selection, sorting, etc. |
└ Aggregate | collection | Aggregation functions (e.g., count, sum, avg) to apply to the result set. |
└ Binary Property for Export Data | string | Name of the binary property to which exported file data will be attached (if exporting). |
└ Deep (JSON) | json | Allows setting nested query parameters for deep relational queries. |
└ Export | options | Format to export the API response: CSV, JSON, or XML. If set, the response will be provided as a downloadable file in the specified format. |
└ Fields | string | Comma-separated list of fields to include in the response. |
└ File Name for Export Data | string | File name (without extension) for the exported data file. |
└ Filter (JSON) | json | Conditions to filter the relations returned. |
└ Group By | string | Field(s) to group the results by, supporting aggregate calculations per group. |
└ Meta | string | Specifies what metadata to include in the response. |
└ Offset | number | Number of items to skip before starting to collect the result set. |
└ Search | string | Search term to filter relations by matching fields. |
└ Sort | string | How to sort the returned items. Accepts comma-separated field names, with optional minus sign for descending order. |
Output
- If "Split Into Items" is enabled:
Each output item contains ajson
property with a single relation object. - If "Split Into Items" is disabled:
A single output item contains ajson
property with an array of relation objects.
Sample output structure:
[
{
"json": {
"collection": "articles",
"field": "author_id",
"related_collection": "users",
"meta": { /* ... */ },
// ...other relation properties
}
},
...
]
- If "Export" is set:
The output will also include abinary
property containing the exported file (CSV, JSON, or XML), with the file name and MIME type as specified.
Dependencies
- Directus API:
Requires access to a running Directus instance. - API Credentials:
You must configure thedirectusApi
credentials in n8n with appropriate permissions to read schema information. - n8n Environment:
No special environment variables required beyond standard n8n and Directus setup.
Troubleshooting
Common issues:
- Authentication errors:
Ensure your Directus API credentials are correct and have permission to access relations. - Empty results:
If no relations are returned, verify that your Directus instance has defined relations and that any filters or search terms are correct. - Invalid JSON in parameters:
When using JSON/RAW Parameters, ensure your JSON syntax is valid to avoid parsing errors. - Export errors:
If exporting, make sure the file name and binary property name are valid and not conflicting with other nodes.
Error messages:
"Cannot parse JSON"
: Check your JSON input for syntax errors."Request failed with status code 401"
: Authentication issue—check credentials."Request failed with status code 403"
: Insufficient permissions—update user role in Directus."Request failed with status code 404"
: Endpoint not found—ensure the Directus API URL is correct.