Spaces

View as Markdown

A Space is the boundary around your automation resources. It groups Runtimes and defines the environment they can use: durable storage, Vault secrets, and AI credentials.

A Runtime inherits the environment of the Space it belongs to. Configure a capability once at the Space boundary when several Runtimes should share it.

Create a Space

The smallest valid request is an empty object:

1const space = await bctrl.spaces.create({});
2console.log(space.id);

Give the Space a name when you want a stable label in your application:

1const space = await bctrl.spaces.create({
2 name: "checkout-automation",
3});

You can configure its environment at creation time:

1const models = await bctrl.ai.models.list({
2 status: "recommended",
3});
4const modelId = models.data[0]?.id;
5if (!modelId) {
6 throw new Error("No recommended Browser Use model is available");
7}
8
9const space = await bctrl.spaces.create({
10 name: "checkout-automation",
11 environment: {
12 storage: { namespace: "checkout" },
13 vault: { allow: ["checkout/"] },
14 ai: {
15 credentialIds: ["openai-production"],
16 default: modelId,
17 },
18 },
19});

Create fields

ParameterTypeRequiredDescription
namestringNoHuman-readable label. The server supplies a default when omitted.
regionstringNoRegion for the Space. The current platform region is "us-east-1".
environmentEnvironmentMountsNoStorage, Vault, and AI capabilities available to Runtimes in the Space.

Space identity

The Space object includes its environment, so one response gives you both the Space identity and the capabilities available to its Runtimes.

FieldTypeAlways presentDescription
idstringYesDurable Space identifier. Pass it as spaceId when creating a Runtime.
namestringYesHuman-readable label.
regionstringYesRegion where the Space runs.
isDefaultbooleanYesWhether this is the caller’s default Space.
environmentEnvironmentMountsYesStorage, Vault, and AI mounts available to the Space.
createdAtstringYesCreation timestamp.
updatedAtstringYesLast update timestamp.

Use the Space ID for resource operations. The literal "default" can be used where the API accepts a Space selector to address the caller’s default Space.

Space environment

An environment is a set of optional mounts. If a mount is omitted, that capability is not mounted into the Space.

FieldTypeAlways presentDescription
storage{ namespace: string }NoDurable file namespace available to the Space.
vaultSpaceVaultMountNoSecret prefixes and direct-read policy available to Vault Tools.
aiEnvironmentAiMountNoSaved AI credentials and default models available to Agents.

Storage

FieldTypeAlways presentDescription
storage.namespacestringYesNamespace used by the Space’s durable file storage.

Vault

FieldTypeAlways presentDescription
vault.allowstring[]NoSecret prefixes Vault Tools may access.
vault.denystring[]NoSecret prefixes that remain inaccessible.
vault.allowRawReadsbooleanNoAllow Tools to read secret values directly.

Keep the allowlist narrow. Leave allowRawReads unset unless the workflow needs the secret value itself; many workflows only need Vault to provide a credential to a Tool.

AI

FieldTypeAlways presentDescription
ai.credentialIdsstring[]NoSaved AI credential IDs that Agents may use in this Space.
ai.defaultstring | AiStoredModelSelectionNoDefault model selection for hosted Conversation turns.

A string is the shorthand model form:

1default: modelId

Use the object form when the selection needs explicit authentication or model controls:

1default: {
2 model: modelId,
3 auth: { credential: "openai-production" },
4 reasoningEffort: "medium",
5}

AiStoredModelSelection has a required model and optional auth, provider, and model controls. auth can be "managed" or { credential: string }. When a saved credential is selected, its provider is used; do not send a separate provider with auth: { credential: ... }. The AI models page explains model selections and credentials in detail.

Read and update the environment

Read the environment from the Space object:

1const current = await bctrl.spaces.get(space.id);
2const environment = current.environment;
3
4console.log(environment.storage?.namespace);
5console.log(environment.vault?.allow);
6console.log(environment.ai?.credentialIds);

Include environment in spaces.update() to patch the Space environment:

  • Omit a mount to leave it unchanged.
  • Send an object to add or replace a mount.
  • Send null to remove a mount.
1await bctrl.spaces.update(space.id, {
2 name: "checkout-production",
3 environment: {
4 storage: { namespace: "checkout" },
5 vault: {
6 allow: ["checkout/"],
7 deny: ["checkout/admin/"],
8 },
9 ai: {
10 credentialIds: ["openai-production"],
11 default: modelId,
12 },
13 },
14});

For nested AI fields, the same patch rules apply. Omit a field to keep it, provide a value to set it, and use null to clear it:

1await bctrl.spaces.update(space.id, {
2 environment: {
3 ai: {
4 default: null,
5 },
6 },
7});

To remove the complete mount:

1await bctrl.spaces.update(space.id, {
2 environment: {
3 vault: null,
4 },
5});

Manage Spaces

1const page = await bctrl.spaces.list({ limit: 50 });
2const current = await bctrl.spaces.get(space.id);
3
4await bctrl.spaces.update(space.id, {
5 name: "checkout-production",
6});
7
8for await (const item of bctrl.spaces.iter()) {
9 console.log(item.id, item.name);
10}

Delete a Space only after its active Runtimes have stopped:

1await bctrl.spaces.delete(space.id);

Use a Space with a Runtime

Pass spaceId when creating a Runtime. If you omit it, the Runtime uses the caller’s default Space.

1const runtime = await bctrl.runtimes.create({
2 spaceId: space.id,
3});

Runtime-specific settings such as browser identity, proxy, and extensions belong in Runtimes.