> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://platform.bctrl.ai/llms.txt.
> For full documentation content, see https://platform.bctrl.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://platform.bctrl.ai/_mcp/server.

# Spaces

> The boundary that scopes which storage, secrets, and AI credentials a runtime can use.

A **space** controls which resources the runtimes inside it can reach: a storage namespace, vault secrets, and AI provider credentials. Mount what a space needs once, and every runtime you launch inside it inherits that environment.

## Create a space

```ts
const space = await bctrl.spaces.create({ name: "invoice-agent" });
```

Pass `environment` to mount resources at creation time:

```ts
const space = await bctrl.spaces.create({
  name: "invoice-agent",
  environment: {
    storage: { namespace: "acme-invoices" },
    vault: { allow: ["clients/acme/"] },
  },
});
```

* `storage.namespace` - the storage namespace runtimes read and write.
* `vault.allow` - key prefixes runtimes may decrypt from the [vault](/sdk/vault).
* `ai` - the [AI providers](/sdk/ai-providers) runtimes may use; shaped as `{ aiProviderIds, defaults: { stagehand, browserUse } }`.

## List and read

```ts
const { data } = await bctrl.spaces.list();

for await (const space of bctrl.spaces.iter()) {
  console.log(space.id, space.name);
}

const one = await bctrl.spaces.get(space.id);
```

`list` returns one page with a cursor; `iter` walks every page for you. See [Pagination](/sdk/essentials).

## Update and delete

```ts
await bctrl.spaces.update(space.id, { name: "invoice-agent-prod" });
await bctrl.spaces.delete(space.id);
```

## Manage the environment

Read or change a space's mounts after creation:

```ts
const env = await bctrl.spaces.environment.get(space.id);

await bctrl.spaces.environment.update(space.id, {
  vault: { allow: ["clients/acme/", "shared/"] },
});
```

## Launch runtimes in a space

Pass `spaceId` when creating a runtime so it inherits the space environment:

```ts
const runtime = await bctrl.runtimes.create({
  spaceId: space.id,
  type: "browser",
  name: "main",
});
```

## Next

* [Runtimes](/sdk/runtimes) - launch and configure cloud browsers
* [Vault](/sdk/vault) - secrets a space can mount
* [Subaccounts](/sdk/account) - isolate spaces per customer