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

# Organizations

> How to find and use X-Organization-Id for multi-tenant API access.

Grain is multi-tenant: each church is an **organization**. Every API request must include the `X-Organization-Id` header so Grain knows which church's data to return.

## Header format

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
X-Organization-Id: cm123abc456def
```

The value is a UUID-style organization ID (CUID in Grain's database).

## How users get an organization ID

When a user signs in to Grain, they may belong to one or more churches. Your OAuth flow authorizes the **user**, not a specific organization. Your application chooses which organization to access per request.

<Tip>
  If your integration serves a single church, store the organization ID after the user selects their church in your onboarding flow.
</Tip>

## Finding the ID in the Grain app

1. Sign in at [app.grainledger.com](https://app.grainledger.com)
2. Open the organization switcher (top of the sidebar)
3. The organization ID is available in organization settings or from your Grain contact during API onboarding

<Info>
  If you are building a partner integration, the Grain team provides the organization ID when API access is approved. [Request API access](https://grainledger.com/demo).
</Info>

## Multi-organization users

A single user can be a member of multiple churches (for example a bookkeeper serving several clients). Your application should:

1. Let the user pick which church to work with
2. Send that organization's ID in `X-Organization-Id` on every request
3. Switch the header when the user changes churches

Permissions are evaluated per organization. A user with admin access at Church A may have read-only access at Church B.

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X GET "https://api.grainledger.com/api/v1/transactions?page=1&limit=20" \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -H "X-Organization-Id: cm123abc456def"
  ```

  ```javascript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const organizationId = userSelectedOrgId; // from your app's org picker

  const response = await fetch(
    "https://api.grainledger.com/api/v1/transactions?page=1&limit=20",
    {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "X-Organization-Id": organizationId,
      },
    }
  );
  ```
</CodeGroup>

## Related

* [Authentication](/authentication) for OAuth setup
* [Errors](/errors) for `400` and `403` responses when the header is missing or invalid
