Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Permissions → Delete Multiple

AI-generated

Overview

The Directus (DrWade) n8n node for the resource Permissions with the operation Delete Multiple allows users to delete multiple permission records in a Directus instance at once. This is particularly useful for administrators or automation workflows that need to clean up or manage permissions in bulk, such as removing access rights for deprecated roles or cleaning up after user offboarding.

Practical Example:
Suppose you have a list of permission IDs that are no longer needed. By providing these IDs as an array, this node will send a single request to Directus to remove all specified permissions efficiently, rather than deleting them one by one.


Properties

Name Type Meaning
Keys (JSON) JSON An array of permission primary keys to be deleted. Example: [34, 64]. Required field.

Output

  • The output will be a single object with a json property.
  • The structure of the json field will contain the response from the Directus API after attempting to delete the specified permissions. Typically, this may include:
    • A summary of the deletion result (e.g., number of items deleted, status).
    • If the API returns data about the deleted permissions, it will be included here.
    • In case of error and if "Continue On Fail" is enabled, the output will contain an error field with the error message.

Example Output:

{
  "json": {
    // Response from Directus, e.g.,
    "data": [
      { "id": 34, "status": "deleted" },
      { "id": 64, "status": "deleted" }
    ]
  }
}

Or, on error (with continue on fail):

{
  "json": {
    "error": "Permission not found"
  }
}

Dependencies

  • External Service: Requires access to a Directus instance.
  • Authentication: Needs valid Directus API credentials configured in n8n under the name directusApi.
  • n8n Configuration: No special environment variables beyond standard credential setup.

Troubleshooting

Common Issues:

  • Invalid Keys Format: Ensure the "Keys (JSON)" property is a valid JSON array of numeric IDs. Invalid JSON or wrong data types will cause errors.
  • Non-existent Permission IDs: If any provided ID does not exist, Directus may return an error or partial success depending on its API behavior.
  • Insufficient Permissions: The API credentials used must have permission to delete permissions; otherwise, an authorization error will occur.

Error Messages & Resolutions:

  • "Unexpected token ... in JSON": The input for "Keys (JSON)" is not valid JSON. Double-check your syntax.
  • "Permission not found": One or more IDs do not correspond to existing permissions. Verify the IDs.
  • "Unauthorized" or "Forbidden": The API credentials lack sufficient rights. Update the credentials or their permissions in Directus.

Links and References


Discussion