Skip to main content
The Workspace class represents a Yasumu workspace and provides access to REST, email, and environment modules.

Access workspaces

Access workspaces through the workspaces manager on the Yasumu instance:
// Get active workspace
const workspace = yasumu.workspaces.getActiveWorkspace();

// Create new workspace
const workspace = await yasumu.workspaces.create({
  name: 'My Project',
  path: '/path/to/workspace',
});

// Open existing workspace
const workspace = await yasumu.workspaces.open({
  id: 'workspace-id',
});

// List all workspaces
const workspaces = await yasumu.workspaces.list();

WorkspaceManager

The workspace manager handles workspace lifecycle operations.

create()

Creates a new workspace.
const workspace = await yasumu.workspaces.create({
  name: 'My Project',
  path: '/path/to/workspace',
  metadata: {
    description: 'API testing workspace',
  },
});
options
WorkspaceCreateOptions
required
return
Promise<Workspace>
The created workspace instance

open()

Opens an existing workspace by ID.
const workspace = await yasumu.workspaces.open({
  id: 'workspace-id',
});
options
WorkspaceOpenOptions
required
return
Promise<Workspace>
The opened workspace instance

list()

Lists all available workspaces.
const workspaces = await yasumu.workspaces.list();

// With limit
const recent = await yasumu.workspaces.list({ take: 10 });
options
object
return
Promise<Workspace[]>
Array of workspace instances

getActiveWorkspace()

Returns the currently active workspace.
// Returns null if no workspace is active
const workspace = yasumu.workspaces.getActiveWorkspace();

// Throws error if no workspace is active
const workspace = yasumu.workspaces.getActiveWorkspace(true);
throwIfNotFound
boolean
default:false
If true, throws an error when no workspace is active
return
Workspace | null
The active workspace, or null if none is active (unless throwIfNotFound is true)

close()

Closes a workspace.
await yasumu.workspaces.close(workspace);
workspace
Workspace
required
The workspace to close

delete()

Deletes a workspace by ID.
await yasumu.workspaces.delete('workspace-id');
id
string
required
ID of the workspace to delete

Workspace properties

workspace.id

id
string
Unique identifier for the workspace

workspace.name

name
string
Display name of the workspace

workspace.path

path
string
File system path where the workspace is stored

workspace.metadata

metadata
Record<string, unknown>
Custom metadata associated with the workspace

workspace.createdAt

createdAt
Date
Timestamp when the workspace was created

workspace.updatedAt

updatedAt
Date
Timestamp when the workspace was last updated

workspace.lastOpenedAt

lastOpenedAt
Date | null
Timestamp when the workspace was last opened, or null if never opened

Workspace modules

workspace.rest

rest
RestModule
Module for managing REST API requests and entities.See RestModule for details.
const entity = await workspace.rest.create({
  name: 'Get Users',
  url: 'https://api.example.com/users',
  method: 'GET',
});

workspace.emails

emails
EmailModule
Module for SMTP email testing.See EmailModule for details.
const config = await workspace.emails.getSmtpConfig();
const emails = await workspace.emails.listEmails({ page: 1, limit: 10 });

workspace.environments

environments
EnvironmentManager
Manager for environment variables and secrets.See EnvironmentManager for details.
const env = await workspace.environments.create({
  name: 'Production',
});

await env.setActive();

Workspace methods

synchronize()

Synchronizes the workspace data with the backend.
await workspace.synchronize();
return
Promise<void>
Resolves when synchronization is complete

toJSON()

Converts the workspace to a plain object.
const data = workspace.toJSON();
console.log(data.name, data.path);
return
WorkspaceData
Plain object representation of the workspace

Example usage

// Create and configure a workspace
const workspace = await yasumu.workspaces.create({
  name: 'E-commerce API',
  path: '/projects/ecommerce',
  metadata: {
    version: '1.0',
    team: 'backend',
  },
});

// Create environments
const dev = await workspace.environments.create({
  name: 'Development',
});

const prod = await workspace.environments.create({
  name: 'Production',
});

await dev.setActive();

// Add environment variables
await dev.variables.set('API_URL', 'http://localhost:3000');
await prod.variables.set('API_URL', 'https://api.example.com');

// Create REST entities
const getProducts = await workspace.rest.create({
  name: 'Get Products',
  url: '{{API_URL}}/products',
  method: 'GET',
});

const createOrder = await workspace.rest.create({
  name: 'Create Order',
  url: '{{API_URL}}/orders',
  method: 'POST',
});

// List all REST entities
const entities = await workspace.rest.list();
console.log(`Created ${entities.length} endpoints`);

RestModule

REST API testing

EmailModule

Email testing

EnvironmentManager

Environment variables

Build docs developers (and LLMs) love