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

# Scope Requests to a Teamspace

> Learn how to scope API requests to a different teamspace within your account

Teamspaces isolate resources and data within your organization. By default, API requests are scoped to the teamspace in which the API key was created — its **home teamspace**.

## When you can target a different teamspace

The `Datagrid-Teamspace` header only takes effect for API keys created with **`scopeLevel: "account"`**. For these account-scoped keys, the header may select any teamspace under the **same account** as the key's home teamspace.

For the default **`scopeLevel: "org"`** keys, the header is ignored — the request always runs against the home teamspace. To target a different teamspace with an org-scoped key, mint a new key inside the target teamspace.

| Key `scopeLevel`  | `Datagrid-Teamspace` behavior                                                                                                   |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `"org"` (default) | Header is ignored. Request runs against the key's home teamspace.                                                               |
| `"account"`       | Header selects the target teamspace. Must be under the same account as the home teamspace; otherwise the request returns `404`. |

## Option 1: Initialize the client with a teamspace

Initialize the Datagrid client with a teamspace ID — all subsequent requests will use it automatically (account-scoped keys only).

<CodeGroup>
  ```python Python theme={null}
  from datagrid_ai import Datagrid

  datagrid = Datagrid(
      teamspace="teamspace_id",
  )

  response = datagrid.converse(
      prompt="Hello world!",
  )

  print(response.content[0].text)
  ```

  ```javascript JavaScript theme={null}
  import Datagrid from "datagrid-ai";

  const datagrid = new Datagrid({
    teamspace: "teamspace_id",
  });

  const response = await datagrid.converse({
    prompt: "Hello world!",
  });

  console.log(response.content[0].text);
  ```
</CodeGroup>

## Option 2: Scope individual requests

Pass the `Datagrid-Teamspace` header per request — useful when one client addresses multiple teamspaces in the same account.

<CodeGroup>
  ```python Python theme={null}
  from datagrid_ai import Datagrid

  datagrid = Datagrid()

  response = datagrid.converse(
      prompt="Hello world!",
      extra_headers={
          "Datagrid-Teamspace": "teamspace_id",
      },
  )

  print(response.content[0].text)
  ```

  ```javascript JavaScript theme={null}
  import Datagrid from "datagrid-ai";

  const datagrid = new Datagrid();

  const response = await datagrid.converse(
    {
      prompt: "Hello world!",
    },
    {
      headers: {
        "Datagrid-Teamspace": "teamspace_id",
      },
    }
  );

  console.log(response.content[0].text);
  ```
</CodeGroup>
