Directus icon

Directus

Consume Directus API

Overview

The Directus node for n8n, when configured with the Resource: Users and Operation: Update Me, allows you to update the profile information of the currently authenticated user in a Directus instance. This is particularly useful in workflows where users need to programmatically change their own details, such as updating their job title, contact information, or other personal settings.

Common scenarios:

  • Allowing users to update their own profiles via an automated workflow.
  • Synchronizing user data from another system into Directus for the current user.
  • Enabling self-service updates for user attributes without admin intervention.

Practical example:
A user completes a form to update their job title. The workflow uses this node to patch the user's record in Directus with the new title.


Properties

Name Type Meaning
Data (JSON) json A JSON object containing the fields and values to update for the currently authenticated user. For example:
{"title": "CTO"}

Output

  • The output will be a single item with a json field containing the updated user object as returned by the Directus API.
  • The structure of the output matches the Directus user schema, including all user fields that were updated and any others returned by the API.

Example output:

{
  "id": "123",
  "first_name": "Jane",
  "last_name": "Doe",
  "email": "jane.doe@example.com",
  "title": "CTO",
  ...
}

Note: The actual fields depend on your Directus setup and which fields are present/updated.


Dependencies

  • Directus API: You must have access to a running Directus instance.
  • API Credentials: The node requires valid Directus API credentials (directusApi) configured in n8n.
  • User Authentication: The operation acts on the currently authenticated user; ensure the credentials correspond to the intended user.

Troubleshooting

Common issues:

  • Invalid JSON in Data (JSON): If the input is not valid JSON, the node will throw a parsing error. Double-check your syntax.
  • Insufficient Permissions: If the authenticated user does not have permission to update their own profile, the API will return an error.
  • Field Validation Errors: If you attempt to update fields with invalid values (e.g., wrong data type), Directus may reject the request.

Error messages and resolutions:

  • "Unexpected token ... in JSON": Check your Data (JSON) property for correct JSON formatting.
  • "You do not have permission to perform this action": Ensure the user's role in Directus has permission to update their own user record.
  • "Field 'xyz' does not exist": Make sure you are only updating valid fields defined in your Directus user collection.

Links and References

Discussion