> ## Documentation Index
> Fetch the complete documentation index at: https://docs.formal.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Spaces

> Logical groupings for network segmentation and access control

## What are Spaces?

Spaces represent logical groupings of Connectors, Satellites, and Resources that can communicate with each other. They enable network segmentation and access isolation that mirrors your infrastructure's connectivity patterns.

Think of Spaces as virtual network boundaries for Formal objects.

## How Spaces Work

> [card] Isolation
>
> Objects in different Spaces cannot communicate with each other

> [card] Flexibility
>
> Objects without a Space can access any Resource that is not in a Space

## Space Rules

### Assignment Rules

* **Each object can belong to at most ONE Space**
* **Objects without a Space** can access any Resource without a Space
* **Objects with a Space** can only access Resources in the same Space

### Connectivity Matrix

| Connector | Resource | Can Connect? |
| - | - | - |
| No Space | No Space | ✅ Yes |
| No Space | Space A | ❌ No |
| Space A | No Space | ❌ No |
| Space A | Space A | ✅ Yes |
| Space A | Space B | ❌ No |

The same rules apply to Satellites and Resources.

## Use Cases

### Environment Segmentation

Create Spaces for each environment to prevent cross-environment access:

```text theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
Production Space:
  - production-connector
  - production-postgres
  - production-snowflake

Staging Space:
  - staging-connector
  - staging-postgres

Development Space:
  - dev-connector
  - dev-postgres
```

Now a user connecting through `production-connector` can only reach production databases, even if they have credentials for staging.

### Geographic Isolation

Separate resources by region for compliance or latency requirements:

```text theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
US-East Space:
  - us-east-connector
  - us-east-postgres
  - us-east-s3

EU-West Space:
  - eu-west-connector
  - eu-west-postgres
  - eu-west-s3
```

### Team-Based Access

Create Spaces for different teams or projects:

```text theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
Engineering Space:
  - eng-connector
  - production-db
  - analytics-warehouse

Analytics Space:
  - analytics-connector
  - analytics-warehouse (shared)
  - data-lake
```

## Creating and Managing Spaces

> [tab] Control Plane
>
> **1. Navigate to Spaces**
>
> Go to [Spaces](https://app.formal.ai/spaces) in the Control Plane
>
> **2. Create Space**
>
> Click **Create Space** and provide a name
>
> **3. Assign objects**
>
> Edit Connectors, Satellites, or Resources to assign them to the Space

> [tab] Terraform
>
> ```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
> # Create a Space
> resource "formal_space" "production" {
>   name = "production"
> }
>
> # Assign Connector to Space
> resource "formal_connector" "prod_connector" {
>   name     = "production-connector"
>   space_id = formal_space.production.id
> }
>
> # Assign Resource to Space
> resource "formal_resource" "prod_db" {
>   name       = "production-postgres"
>   technology = "postgres"
>   hostname   = "prod-db.rds.amazonaws.com"
>   port       = 5432
>   space_id   = formal_space.production.id
> }
> ```

## Updating Spaces

### Changing an Object's Space

When you change a Connector, Satellite, or Resource's Space assignment:

> [!WARNING]
>
> You must **restart the Connector or Satellite** for the change to take effect.
> This is a connectivity change that requires reinitialization.

For Resources, the change is immediate—new connections will respect the new Space assignment.

### Testing Space Changes

Before applying Space changes in production:

1. Create a test Connector in the new Space
2. Verify connectivity to intended Resources
3. Update the production Connector's Space
4. Restart the Connector
5. Verify connectivity

## Deleting Spaces

Spaces cannot be deleted if they contain any objects.

**1. Remove all objects**

Reassign or delete all Connectors, Satellites, and Resources in the Space

**2. Verify empty**

Confirm the Space shows 0 objects

**3. Delete Space**

Click **Delete** in the Space details page

## Spaces vs. Policies

| Aspect | Spaces | Policies |
| - | - | - |
| **Purpose** | Network segmentation | Access control |
| **Enforced at** | Infrastructure layer | Request layer |
| **Use for** | Environment isolation | Permission rules |

**Best practice:** Use Spaces for infrastructure segmentation and Policies for user-level access control. They complement each other.

## Best Practices

> [accordion] Mirror Your Infrastructure
>
> Create Spaces that match your actual network topology and environment
> boundaries. This makes Space assignments intuitive.

> [accordion] Start with Environments
>
> At minimum, create Spaces for production, staging, and development. This
> prevents accidental prod access from lower environments.

> [accordion] Use Policies for User Access
>
> Don't create Spaces per user or team. Use Policies for user-level access
> control and Spaces for infrastructure segmentation.

> [accordion] Test Space Changes
>
> Always test connectivity after changing Space assignments, especially in
> production. Deploy a test Connector first.

> [accordion] Document Space Purpose
>
> Use clear names and maintain documentation of what each Space represents and
> which teams use it.

## Next Steps

> [card] [Deploy Connectors](https://docs.formal.ai/docs/guides/core-concepts/connectors/introduction.md)
>
> Create Connectors in your Spaces

> [card] [Add Resources](https://docs.formal.ai/docs/guides/core-concepts/resources/introduction.md)
>
> Assign Resources to Spaces

> [card] [Deploy Satellites](https://docs.formal.ai/docs/guides/core-concepts/satellites.md)
>
> Add Satellites to your Spaces

> [card] [Write Policies](https://docs.formal.ai/docs/guides/policies/introduction.md)
>
> Control access within Spaces


## Related topics

- [Create space](https://docs.formal.ai/api-reference/corev1spaceservice/create-space.md)
- [Delete space](https://docs.formal.ai/api-reference/corev1spaceservice/delete-space.md)
- [Get space](https://docs.formal.ai/api-reference/corev1spaceservice/get-space.md)
- [List spaces](https://docs.formal.ai/api-reference/corev1spaceservice/list-spaces.md)
- [Update space](https://docs.formal.ai/api-reference/corev1spaceservice/update-space.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.