Directus icon

Directus

Consume Directus API

Overview

The Directus node for n8n, when configured with the Resource: Revisions and Operation: List, retrieves a list of revision records from a Directus instance. This operation is useful for tracking changes made to items in your Directus collections, auditing historical modifications, or building features that require version history (e.g., rollback, change logs).

Practical scenarios:

  • Displaying a changelog of edits for content items.
  • Auditing who changed what and when in your data.
  • Exporting revision histories for compliance or backup purposes.

Properties

Name Type Meaning
Return All boolean If enabled, returns all available revision records; if disabled, limits the number of results based on the "Limit" property.
Limit number The maximum number of revision records to return (only shown if "Return All" is false). Must be between 1 and 100.
Split Into Items boolean If enabled, outputs each revision as a separate item in the n8n workflow; otherwise, returns all revisions 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 shown if "JSON/RAW Parameters" is true).
Additional Fields collection Extra options to refine the query, such as aggregation, export format, filtering, sorting, grouping, and more. See below for details.

Additional Fields options include:

  • Aggregate: Apply aggregation functions (count, sum, avg, min, max, etc.) to specific fields.
  • Binary Property for Export Data: Name of the binary property to store exported file data.
  • Deep (JSON): Set nested relational query parameters.
  • Export: Choose to export the API response as a file (CSV, JSON, XML).
  • Fields: Specify which fields to return in the response.
  • File Name for Export Data: File name (without extension) for exported data.
  • Filter (JSON): Filter conditions as JSON.
  • Group By: Group results by specified fields.
  • Meta: Specify metadata to include in the response.
  • Offset: Number of items to skip (for pagination).
  • Search: Search string to filter items.
  • Sort: Sorting instructions (CSV of fields, use - for descending, ? for random).

Output

  • Standard Output:

    • If "Split Into Items" is false:
      • A single item with a json field containing an array of revision objects or a result object as returned by Directus.
    • If "Split Into Items" is true:
      • Each revision is output as a separate item, each with its own json field.
  • When Export is used (CSV, JSON, XML):

    • The output includes a binary property containing the exported file data under the specified binary property name (default: "data").
    • The json field still contains the parsed response or summary.

Example output structure:

[
  {
    "json": {
      // Revision object fields as returned by Directus
      "id": "...",
      "activity": "...",
      "collection": "...",
      "item": "...",
      "parent": "...",
      "revision": "...",
      "user": "...",
      "date_created": "...",
      // ...other fields
    }
  },
  ...
]

Or, if exporting:

[
  {
    "json": { /* summary or metadata */ },
    "binary": {
      "data": {
        "data": "<Buffer ...>",
        "fileName": "export.csv",
        "mimeType": "text/csv"
      }
    }
  }
]

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n with appropriate permissions to read revisions.
  • n8n Environment: No special environment variables required beyond standard n8n and credential setup.

Troubleshooting

  • Authentication errors: Ensure your Directus API credentials are correct and have permission to access revisions.
  • Empty results: Check your filters, search, or limit settings. If "Return All" is off and "Limit" is low, you may not see all data.
  • Invalid JSON in parameters: When using JSON/RAW input, ensure your JSON syntax is valid to avoid parsing errors.
  • Export issues: If the export file is missing or empty, verify the export type and that there is data to export.
  • Common error messages:
    • Error: Unexpected token ... in JSON at position ...: Indicates malformed JSON in one of the JSON input fields.
    • 401 Unauthorized or 403 Forbidden: Check your API credentials and user permissions.
    • 400 Bad Request: Likely due to invalid query parameters or filters.

Links and References

Discussion