📄 Our paper is out: Optimizing Knowledge Graph-LLM Interface🚀 Cognee Cloud: Sign up for Cogwit Beta
Blog>Cognee News

Multi-Tenant Ready: Introducing Dataset Sharing & Role-Based Access

While we’re proud to have built a robust AI memory engine that reliably retains all ingested data, one recurring theme has crystalized in our users’ feedback: the need for a friction-free way to manage who can interact with stored knowledge.

Developers building on cognee often handle sensitive or team-specific data, so simple and intuitive access control is imperative. That’s why the latest version of cognee now includes a built-in user management system which lets users share datasets with precise role-based permissions.

This feature works seamlessly with Kùzu for graphs and LanceDB for vectors, ensuring security integrates naturally into your workflows.

The Permission Model: Scoped, Flexible, and Secure

In cognee, permissions revolve around datasets—self-contained units that bundle documents, metadata, and their graph/vector representations. Granting or revoking access to a dataset effectively controls interactions with its underlying databases.

Permissions are assigned to "principals," which can be:

  • Tenants: Broad containers for organizations or isolated environments, ideal for SaaS providers or agencies managing multiple clients.
  • Roles: Predefined groups like "Analyst," "Contributor," or custom ones you define, with adjustable defaults for efficiency.
  • Users: Individual overrides for targeted access, such as giving a colleague temporary read rights to a prototype dataset.

Each principal supports four core permissions:

  • Read: Query and retrieve from the dataset.
  • Write: Add or update content.
  • Delete: Permanently remove entries.
  • Share: Delegate permission management to others.

This setup lets you start simple—assign to a user—and scale to roles or tenants as your project grows, all while maintaining clear boundaries.

tenant-role-user

Using Permissions Programmatically via the SDK

The SDK provides methods to create users, roles, tenants, and assign permissions.

Note: We've trimmed the full example script here to keep the focus on key steps like user creation, dataset addition, and permission granting. The complete, runnable version is available in our GitHub repo (see the examples folder for the detailed permissions demo).

First, enable backend access control and set up your environment:

Reset and initialize cognee with the necessary databases and tables for user management:

Create users and add datasets (trimmed; full includes paths and error handling):

Then cognify the datasets (extract IDs for later use; the full script includes a helper function):

Demonstrate permission checks (user_1 can query their own but not user_2's initially):

Grant permissions (user_2 gives read access to user_1; full includes write/delete examples):

Now user_1 can query user_2's dataset. For roles/tenants (trimmed; full script shows adding users to them):

This approach keeps your code clean while enforcing access in cases where data ownership matters.

sdk-flow

Using Permissions via the cognee Backend with API Requests

For API-driven control, first make sure to have cognee installed, then configure any environment variables such as:

Then start the cognee backend server:

With the cognee python library installed.

Note: The backend can be used with curl, but you can access Swagger docs at: http://localhost:8000/docs

Below are key curl examples (again, trimmed for brevity).

Here’s how to register users:

An example output of register endpoint (outputs include user IDs; copy and store them for later):

Now, if we login as user1:

The output of this call will give us the API key we need to use for other cognee endpoints:

We need to copy this bearer access_token and include it in our future requests towards cognee.

Add and cognify data as user1 (trimmed; the full example includes file uploads and outputs dataset_id):

Search as user1 succeeds; the full output shows results):

Attempting to search as user2 initially fails, returning an empty array:

User2 can be granted read access for user1’s dataset by user1, with these stipulations:

  1. API key / bearer token has to be from user 1
  2. Id for user 2 needs to be part of the URL of the request

Permission is granted using this command:

Success produces the following response:

With this we can query user1’s dataset as user2 (now using user2’s API key / bearer token) and get proper search output:

Note: Users can also be added to Roles and Tenants and then permission can be assigned on a Role/Tenant level—check the full API demo in the repo for those flows.

This API layer makes cognee adaptable for scripted automation or integration into larger systems, with built-in safeguards.

Secure What Matters, Share What Counts

With this granular control over datasets, tenants, roles, and users, cognee now allows you to handle access with the precision your projects demand—fostering collaboration while safeguarding knowledge.

We're looking forward to hearing how Permissions empower your workflows, from streamlining team access to securing client data.

From the blog