> ## Documentation Index
> Fetch the complete documentation index at: https://flatfileinc-remove-rss-json.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Scoping with Namespaces

> narrow down the scope of Spaces, Workbooks, and Sheets

<Snippet file="shared/dxpbanner.mdx" />

## Overview

Namespaces allow you to narrow down the scope of Spaces, Workbooks, and Sheets.
When you're monitoring for specific events, you can set your system to only
respond if the event matches the assigned namespaces.

Namespaces enable you to have:

1. **Global Listeners**: These are listeners set up to monitor activities across
   all your Spaces.

2. **Specific Listeners**: These listeners are restricted to monitor and respond
   only within a certain subset of your spaces defined by the assigned
   namespace.

### Usage

```jsx theme={"system"}
// Create a global listener
listener.on("space:created", event => { ... });

// Create a filter scoped for a specific namespace
listener.namespace(['space:green'], (green) => { ... });
```

## Space-level

Space-level Namespaces are straightforward strings that are established or
modified when you create or update an [App](/learning-center/architecture/apps). This adds an
additional layer of control and specificity to your Space.

### Usage

This listener is established for the 'red' namespace within a 'space'. When a
job titled `space:configure` (clicking create new space button in UI) in the
'red' namespace (type red as namespace in the form) is ready, it triggers the
subsequent block of code.

This code will color your Space red to see that it worked.

<Snippet file="guides/namespaces/block1.mdx" />

## Workbook/Sheet-level

Workbook & Sheet-level Namespaces are straightforward strings that can be
established or modified when you create or update the Workbook. This adds an
additional layer of control and specificity to your Workbook.

### Usage

This code dynamically generates a configuration for a 'Contacts' workbook based
on the provided namespace parameter. Depending on the input namespace to the
ChildWorkbook function, additional fields may be added. If the namespace is
'orange', fields for 'Phone' and 'Meal Choice' are added. If it's 'yellow',
fields for 'Shirt Size' and 'Car Choice' are added.

<Snippet file="guides/namespaces/block2.mdx" />

<CardGroup cols={2}>
  <Card title="typescript" icon="code-merge" href="https://github.com/FlatFilers/flatfile-docs-kitchen-sink/blob/main/typescript/namespaces/index.ts">
    Clone the Namespaces example in Typescript
  </Card>

  <Card title="javascript" icon="js" href="https://github.com/FlatFilers/flatfile-docs-kitchen-sink/blob/main/javascript/namespaces/index.js">
    Clone the Namespaces example in Javascript
  </Card>
</CardGroup>
