API Reference

Complete documentation for every method, parameter, and return type.

Module Functions

syft_perm.open(path)

Opens a file or folder with SyftBox permissions. Returns a SyftFile or SyftFolder object that provides methods for managing permissions.

Parameters
Name Type Description
path str | Path Path to the file or folder. Can be a local path, relative path, or syft:// URL
Returns
SyftFile | SyftFolder SyftFile object if path is a file, SyftFolder object if path is a directory
Raises
ValueError If the path cannot be resolved or doesn't exist
Example
# Open a local file
file = syft_perm.open("data.csv")

# Open a folder
folder = syft_perm.open("my_project/")

# Open a remote file
remote_file = syft_perm.open("syft://alice@datasite.org/data.csv")

Granting Permissions

file.grant_read_access(user)

Grants read-only access to a user. The user can view the file contents but cannot modify or delete it.

Parameters
Name Type Description
user str Email address of the user, or "*" to grant public access
Returns
None This method modifies permissions in-place
Example
# Grant read access to a specific user
file.grant_read_access("bob@company.com")

# Make file publicly readable
file.grant_read_access("*")
file.grant_create_access(user)

Grants create access to a user. Includes read permission plus the ability to create new files in folders. For files, this is equivalent to read access.

Parameters
Name Type Description
user str Email address of the user
Returns
None This method modifies permissions in-place
Example
# Allow user to create files in a folder
folder.grant_create_access("alice@company.com")
file.grant_write_access(user)

Grants write access to a user. Includes read and create permissions plus the ability to modify existing files.

Parameters
Name Type Description
user str Email address of the user
Returns
None This method modifies permissions in-place
Example
# Allow user to edit files
file.grant_write_access("team@company.com")
file.grant_admin_access(user)

Grants admin access to a user. Includes all permissions plus the ability to manage permissions for other users.

Parameters
Name Type Description
user str Email address of the user
Returns
None This method modifies permissions in-place
Example
# Grant full control to admin
file.grant_admin_access("admin@company.com")

Checking Permissions

file.has_read_access(user)

Checks if a user has read access to the file or folder.

Parameters
Name Type Description
user str Email address of the user to check
Returns
bool True if the user has read access, False otherwise
Example
if file.has_read_access("bob@company.com"):
    print("Bob can read this file")
file.has_create_access(user)

Checks if a user has create access. For folders, this means they can create new files.

Parameters
Name Type Description
user str Email address of the user to check
Returns
bool True if the user has create access, False otherwise
file.has_write_access(user)

Checks if a user has write access to modify the file.

Parameters
Name Type Description
user str Email address of the user to check
Returns
bool True if the user has write access, False otherwise
file.has_admin_access(user)

Checks if a user has admin access to manage permissions.

Parameters
Name Type Description
user str Email address of the user to check
Returns
bool True if the user has admin access, False otherwise

Revoking Permissions

file.revoke_read_access(user)

Revokes read access from a user. This removes all permissions for the user.

Parameters
Name Type Description
user str Email address of the user, or "*" to revoke public access
Returns
None This method modifies permissions in-place
file.revoke_create_access(user)

Revokes create access from a user. The user retains read access if they had higher permissions.

Parameters
Name Type Description
user str Email address of the user
Returns
None This method modifies permissions in-place
file.revoke_write_access(user)

Revokes write access from a user. The user retains read and create access if they had higher permissions.

Parameters
Name Type Description
user str Email address of the user
Returns
None This method modifies permissions in-place
file.revoke_admin_access(user)

Revokes admin access from a user. The user retains read, create, and write access.

Parameters
Name Type Description
user str Email address of the user
Returns
None This method modifies permissions in-place

Utility Methods

file.explain_permissions(user)

Provides a detailed explanation of why a user has or doesn't have specific permissions, including inheritance chains and pattern matches.

Parameters
Name Type Description
user str Email address of the user to explain permissions for
Returns
str Human-readable explanation of the user's permissions
Example
explanation = file.explain_permissions("alice@example.com")
print(explanation)
# Output: alice@example.com has the following permissions:
# - read access from: /data/syft.pub.yaml (pattern: '*.csv')
file.move_file_and_its_permissions(new_path)

Moves a file to a new location while preserving its permissions. Creates any necessary syft.pub.yaml files to maintain the same access controls.

Parameters
Name Type Description
new_path str | Path Destination path for the file
Returns
SyftFile New SyftFile object at the destination path
Example
# Move file and keep permissions
new_file = file.move_file_and_its_permissions("archive/data.csv")
file.share

Property that displays an interactive permission sharing widget in Jupyter notebooks. Shows current permissions and allows adding/removing users.

Parameters
This is a property, not a method - no parameters
Returns
IPython.display.HTML Interactive widget (in Jupyter) or None (in console)
Example
# Display sharing widget in Jupyter
file.share  # Note: property, not method call

Files API

syft_perm.files

Global instance providing access to file browsing functionality (files only). In Jupyter notebooks, displays an interactive file browser widget showing only files.

Example
# Display interactive file browser (files only)
syft_perm.files
syft_perm.folders

Global instance providing access to folder browsing functionality (folders only). In Jupyter notebooks, displays an interactive file browser widget showing only folders.

Example
# Display interactive file browser (folders only)
syft_perm.folders
syft_perm.files_and_folders

Global instance providing access to file and folder browsing functionality. In Jupyter notebooks, displays an interactive file browser widget showing both files and folders. This is the original behavior of the old .files API.

Example
# Display interactive file browser (both files and folders)
syft_perm.files_and_folders
syft_perm.files.all()

Returns all files (not folders) with permissions in your SyftBox datasites directory.

Parameters
No parameters
Returns
list[dict] List of file metadata dictionaries containing name, path, permissions, size, etc.
syft_perm.files.get(limit=50, offset=0)

Returns a paginated list of files with permissions.

Parameters
Name Type Description
limit int Number of items per page (default: 50)
offset int Starting index (default: 0)
Returns
dict Dictionary with 'files', 'total_count', 'offset', 'limit', and 'has_more' keys
syft_perm.files.search(query=None, admin=None, filetype=None)

Search files by query string and/or filter by admin user and file type.

Parameters
Name Type Description
query str | None Search term for file names and paths
admin str | None Filter by admin email address
filetype str | None Filter by type: 'file' or 'folder'
Returns
Files Filtered Files instance (displays as widget in Jupyter)
syft_perm.files[start:end]

Slice notation for selecting files by index range.

Parameters
Name Type Description
start int Starting index (inclusive)
end int Ending index (exclusive)
Returns
Files Files instance with selected range
Example
# Get first 10 files
first_ten = syft_perm.files[0:10]

Types & Constants

Permission Levels

SyftPerm uses a hierarchical permission system where each level includes all permissions from lower levels:

Level Value Description
read "read" Can view file contents
create "create" Read + can create new files in folders
write "write" Read + Create + can modify existing files
admin "admin" Read + Create + Write + can manage permissions
Special Users

Special user identifiers with specific meanings:

Identifier Meaning
* Public access (anyone can access)
user@example.com Specific user identified by email