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

# Query the governance tree

`GET /api/v1-beta/customers/:id/governance`

Returns a paginated, sortable, filterable view of a customer's governance tree. Each node comes with its hierarchy position, budget configuration, and current usage. Use this endpoint to power dashboards, admin UIs, and leaderboards.

> [!NOTE]
>
> Usage figures may lag the live counter by a few seconds. This endpoint never gates — use [Check](https://docs.stigg.io/documentation/governance/check-and-ingest.md#check) for real-time gate decisions.

All calls use the [Stigg REST API](https://docs.stigg.io/api-and-sdks/api-reference/rest/introduction.md) with your server-side API key in the `X-API-KEY` header. In TypeScript, use `client.v1Beta.customers.governance.list(customerId, params)` with the [client from Setting up](https://docs.stigg.io/documentation/governance/setting-up/sdk.md). It pages through the results for you.

***

## Usage mode and tree mode

The `featureIds` and `currencyIds` filters decide what the query returns.

| Mode | Request | Rows returned |
| - | - | - |
| Usage mode | Pass `featureIds`, `currencyIds`, or both | One row per budget on the requested features or currencies, with its limit, cadence, and current usage. Entities with no budget on them, such as scope entities, also appear, with `null` usage fields |
| Tree mode | Omit both `featureIds` and `currencyIds` | One row per entity in the hierarchy, with no usage configuration attached |

Use usage mode for dashboards and leaderboards. Use tree mode to render the hierarchy itself.

### Usage mode

```typescript TypeScript theme={null}
// Auto-paginates through every page
const rows = [];
for await (const row of client.v1Beta.customers.governance.list('cus-acme', { featureIds: ['feature-ai-tokens'] })) {
  rows.push(row);
}
```

```bash curl theme={null}
curl "https://api.stigg.io/api/v1-beta/customers/cus-acme/governance?featureIds=feature-ai-tokens&limit=20" \
  -H "X-API-KEY: <SERVER_API_KEY>"
```

### Tree mode

```typescript TypeScript theme={null}
const rows = [];
for await (const row of client.v1Beta.customers.governance.list('cus-acme')) {
  rows.push(row);
}
```

```bash curl theme={null}
curl "https://api.stigg.io/api/v1-beta/customers/cus-acme/governance?limit=20" \
  -H "X-API-KEY: <SERVER_API_KEY>"
```

In tree mode, `usageLimit`, `currentUsage`, `utilization`, `cadence`, `usagePeriodStart`, and `usagePeriodEnd` are `null`, and rows carry no `featureId` or `currencyId`.

***

## Response shape

A usage-mode response for `featureIds=feature-ai-tokens`:

```json theme={null}
{
  "data": [
    {
      "entityId": "platform",
      "displayName": "Platform",
      "parentId": "engineering",
      "entityTypeId": "team",
      "featureId": "feature-ai-tokens",
      "scopeEntityIds": [],
      "usageLimit": 200000,
      "currentUsage": 164000,
      "utilization": 0.82,
      "cadence": "P1M",
      "usagePeriodStart": "2026-05-12T09:30:00.000Z",
      "usagePeriodEnd": "2026-06-12T09:30:00.000Z"
    },
    {
      "entityId": "platform",
      "displayName": "Platform",
      "parentId": "engineering",
      "entityTypeId": "team",
      "featureId": "feature-ai-tokens",
      "scopeEntityIds": ["gpt-4o"],
      "usageLimit": 10000,
      "currentUsage": 2600,
      "utilization": 0.26,
      "cadence": "P1M",
      "usagePeriodStart": "2026-05-12T09:30:00.000Z",
      "usagePeriodEnd": "2026-06-12T09:30:00.000Z"
    }
  ],
  "pagination": {
    "next": "eyJpZCI6InBsYXRmb3JtIn0=",
    "prev": null
  }
}
```

| Field | Description |
| - | - |
| `entityId` | External ID of the entity (hierarchy node). |
| `displayName` | Human-readable name of the entity, or `null` when none is set. Show `entityId` instead when it is `null`. |
| `parentId` | External ID of the parent entity. `null` means the entity is a root, or has not been placed in the hierarchy yet. An entity is placed through an [entity entitlement](https://docs.stigg.io/documentation/governance/core-concepts.md#hierarchy), so an entity with no entity entitlements has no parent. Use this field to rebuild the tree client-side. |
| `entityTypeId` | External ID of the entity type (e.g., `department`, `team`, `user`). |
| `featureId` | The metered feature this budget governs. Present when the budget is on a feature. |
| `currencyId` | The credit currency this budget governs. Present when the budget is on a currency. |
| `scopeEntityIds` | The configuration scope. `[]` is the node-wide budget; a non-empty set is a dimension-scoped sub-budget. |
| `usageLimit` | Hard usage limit per cadence period. |
| `currentUsage` | Usage consumed in the current cadence period (may lag by a few seconds). |
| `utilization` | `currentUsage / usageLimit`, and `1` when `usageLimit` is `0`. `null` when the node has no usage configuration. |
| `cadence` | ISO-8601 reset cadence (e.g., `P1M`). |
| `usagePeriodStart` | Start of the cadence period in progress now. |
| `usagePeriodEnd` | When usage resets (exclusive). |

***

## Filtering

### Filter by feature or currency

Pass `featureIds` for feature budgets and `currencyIds` for credit budgets. For several values, repeat the parameter (`featureIds=a&featureIds=b`) or comma-separate them (`featureIds=a,b`). You can combine both in one request.

```typescript TypeScript theme={null}
const rows = [];
for await (const row of client.v1Beta.customers.governance.list('cus-acme', { featureIds: ['feature-ai-tokens', 'feature-api-calls'] })) {
  rows.push(row);
}
```

```bash curl theme={null}
curl "https://api.stigg.io/api/v1-beta/customers/cus-acme/governance?featureIds=feature-ai-tokens&featureIds=feature-api-calls" \
  -H "X-API-KEY: <SERVER_API_KEY>"

# Credit budgets
curl "https://api.stigg.io/api/v1-beta/customers/cus-acme/governance?currencyIds=credits" \
  -H "X-API-KEY: <SERVER_API_KEY>"
```

### Filter by entity type

```typescript TypeScript theme={null}
const rows = [];
for await (const row of client.v1Beta.customers.governance.list('cus-acme', { entityTypeIds: ['team', 'user'] })) {
  rows.push(row);
}
```

```bash curl theme={null}
curl "https://api.stigg.io/api/v1-beta/customers/cus-acme/governance?entityTypeIds=team&entityTypeIds=user" \
  -H "X-API-KEY: <SERVER_API_KEY>"
```

### Filter by scope

| `scope` value | Rows included |
| - | - |
| `'all'` (default) | All rows |
| `'nodeWide'` | Only node-wide budgets (`scopeEntityIds: []`) |
| `'scoped'` | Only dimension-scoped sub-budgets |

```typescript TypeScript theme={null}
const rows = [];
for await (const row of client.v1Beta.customers.governance.list('cus-acme', { scope: 'nodeWide' })) {
  rows.push(row);
}
```

```bash curl theme={null}
curl "https://api.stigg.io/api/v1-beta/customers/cus-acme/governance?scope=nodeWide" \
  -H "X-API-KEY: <SERVER_API_KEY>"
```

### Filter by utilization

```typescript TypeScript theme={null}
// Entities at ≥ 80% utilization
const nearLimit = [];
for await (const row of client.v1Beta.customers.governance.list('cus-acme', { minUtilization: 0.8 })) {
  nearLimit.push(row);
}
```

```bash curl theme={null}
curl "https://api.stigg.io/api/v1-beta/customers/cus-acme/governance?minUtilization=0.8" \
  -H "X-API-KEY: <SERVER_API_KEY>"
```

### Search by entity ID or name

`entityIdSearch` is a case-insensitive substring match on the entity ID or its display name. `%` and `_` match literally.

```typescript TypeScript theme={null}
const rows = [];
for await (const row of client.v1Beta.customers.governance.list('cus-acme', { entityIdSearch: 'platform' })) {
  rows.push(row);
}
```

```bash curl theme={null}
curl "https://api.stigg.io/api/v1-beta/customers/cus-acme/governance?entityIdSearch=platform" \
  -H "X-API-KEY: <SERVER_API_KEY>"
```

***

## Sorting

| `sortBy` value | Description |
| - | - |
| `'utilization'` (default) | `currentUsage / usageLimit` |
| `'currentUsage'` | Raw usage count |
| `'usageLimit'` | Configured limit |
| `'scopeSize'` | Node-wide rows first, then scoped by set size |
| `'id'` | Entity ID alphabetical |
| `'createdAt'` | Creation timestamp |

```typescript TypeScript theme={null}
// Teams closest to their limit, descending
const rows = [];
for await (const row of client.v1Beta.customers.governance.list('cus-acme', { featureIds: ['feature-ai-tokens'], entityTypeIds: ['team'], sortBy: 'utilization', order: 'desc' })) {
  rows.push(row);
}
```

```bash curl theme={null}
curl "https://api.stigg.io/api/v1-beta/customers/cus-acme/governance?featureIds=feature-ai-tokens&entityTypeIds=team&sortBy=utilization&order=desc" \
  -H "X-API-KEY: <SERVER_API_KEY>"
```

***

## Pagination

The query endpoint uses cursor pagination. `limit` defaults to 20, up to a maximum of 100.

```typescript TypeScript theme={null}
// The SDK follows pagination.next for you; limit sets the page size
for await (const row of client.v1Beta.customers.governance.list('cus-acme', { limit: 50 })) {
  console.log(row.entityId);
}
```

```bash curl theme={null}
# First page
curl "https://api.stigg.io/api/v1-beta/customers/cus-acme/governance?limit=10" \
  -H "X-API-KEY: <SERVER_API_KEY>"

# Next page — pass pagination.next from the previous response
curl "https://api.stigg.io/api/v1-beta/customers/cus-acme/governance?limit=10&after=<CURSOR>" \
  -H "X-API-KEY: <SERVER_API_KEY>"
```

`pagination.next` is `null` when you have reached the last page. To go back a page, pass `pagination.prev` as `before`; it's `null` on the first page.

***

## Rebuilding the tree client-side

Each row carries `parentId`, so you can reconstruct the full hierarchy from a flat response. Query in tree mode to get one row per entity:

```typescript TypeScript theme={null}
type QueryRow = { entityId: string; parentId: string | null; [key: string]: unknown };
type TreeNode = QueryRow & { children: TreeNode[] };

function buildTree(rows: QueryRow[]): TreeNode[] {
  const byId = new Map<string, TreeNode>(
    rows.map(r => [r.entityId, { ...r, children: [] }])
  );
  const roots: TreeNode[] = [];

  for (const node of byId.values()) {
    if (node.parentId && byId.has(node.parentId)) {
      byId.get(node.parentId)!.children.push(node);
    } else {
      roots.push(node);
    }
  }

  return roots;
}
```


## Related topics

- [Set up governance via the SDK](https://docs.stigg.io/documentation/governance/setting-up/sdk.md)
- [Set up governance via the Stigg app](https://docs.stigg.io/documentation/governance/setting-up/stigg-app.md)
- [Set up governance via the REST API](https://docs.stigg.io/documentation/governance/setting-up/rest-api.md)
- [Overview](https://docs.stigg.io/documentation/governance/overview.md)
- [Get a list of governance nodes](https://docs.stigg.io/api-reference/governance-hierarchy/get-a-list-of-governance-nodes.md)


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