Skip to main content
Environments are the primary organizational unit in Tusky. Each environment acts as a secure container for files, with its own encryption settings, access policies, and member list. The tusky.environment module provides full CRUD operations and member management.

Create an Environment

Create a new environment with a name and optional configuration:
const environment = await tusky.environment.create("Project Assets", {
  encrypted: true,
  description: "Design files and brand assets",
  defaultEpochs: 5,
  autoExtend: true,
});

console.log("Created environment:", environment.id);

Options

ParameterTypeDefaultDescription
encryptedbooleantrueEnable client-side encryption for all files in this environment.
descriptionstringHuman-readable description of the environment.
defaultEpochsnumber3Default number of Walrus storage epochs for uploads.
autoExtendbooleanfalseAutomatically renew storage before epoch expiry.
tagsstring[]Tags for filtering and organization.
The encrypted setting is permanent and cannot be changed after the environment is created.

Get an Environment

Retrieve an environment by its ID:
const environment = await tusky.environment.get("env_abc123");

console.log(environment.name);         // "Project Assets"
console.log(environment.encrypted);    // true
console.log(environment.fileCount);    // 42
console.log(environment.totalSize);    // 1073741824 (bytes)
The returned environment object includes metadata such as file count, total size, creation date, and member count.

List Environments

Retrieve all environments in your account:
const environments = await tusky.environment.list();

for (const environment of environments) {
  console.log(`${environment.name}${environment.fileCount} files`);
}
The list is ordered by creation date (newest first) by default. You can use the returned metadata to build environment selectors, dashboards, or migration tools.

Update an Environment

Modify an environment’s mutable settings:
const updated = await tusky.environment.update("env_abc123", {
  name: "Brand Assets 2025",
  description: "Updated brand guidelines and logos",
  defaultEpochs: 10,
  autoExtend: true,
});

console.log("Updated:", updated.name);
You can update the name, description, default epochs, auto-extend setting, and tags. The encryption type and environment ID are immutable.

Delete an Environment

Permanently remove an environment and its Tusky metadata:
await tusky.environment.delete("env_abc123");
console.log("Environment deleted");
Deleting an environment removes all Tusky metadata and access control. Files already published to Walrus remain on the network until their storage epochs expire, but they will no longer be served through your Tusky aggregator.

Complete Example

import { Tusky } from "@tusky-io/ts-sdk";

const tusky = new Tusky({ apiKey: process.env.TUSKY_API_KEY });

// Create
const environment = await tusky.environment.create("Demo Environment", {
  encrypted: false,
  description: "Public demo content",
});

// Read
const fetched = await tusky.environment.get(environment.id);
console.log("Environment:", fetched.name, "| Encrypted:", fetched.encrypted);

// Update
await tusky.environment.update(environment.id, {
  description: "Updated description",
});

// List all
const allDrives = await tusky.environment.list();
console.log("Total environments:", allDrives.length);

// Delete
await tusky.environment.delete(environment.id);
console.log("Cleaned up");

What’s Next