Skip to main content
This page covers the catalog setup you make as the vendor through the Stigg TypeScript SDK. Most of these are one-time or infrequent operations. The Check and Ingest calls happen per request at runtime. Prerequisites: a metered feature in a plan the customer is subscribed to, or a credit currency the customer has credits in. A feature check for a customer with no active subscription is denied with NoActiveSubscription.

Core setup

1

Install and initialize the client

Install the Stigg TypeScript client and initialize it with your server-side API key.
All examples in the governance docs use this client instance.
2

Define entity types

Entity types are the categories of resource you want to govern, such as department, team, user, and agent. Define them once per environment. The attributionKeys are the dimension keys your ingest events carry to identify instances of each type.
The upsert is idempotent, so re-submitting the same payload is safe. You can send up to 100 types per request.
3

Provision entities per customer

When a customer creates a department, team, or user in your product, provision the matching entity in governance. Entities belong to a Stigg customer, so pass the customer ID as the first argument.
  • You can send up to 100 entities per request. The upsert is idempotent, so it’s safe to re-run during re-syncs.
  • Keys in metadata merge over existing values. Set a key to "" to delete it. Omit metadata to leave the stored metadata unchanged.
4

Create entity entitlements

An entity entitlement sets the usage limit for an entity on a feature or credit. Entity entitlements appear as columns in the customer’s Governance tab in the Stigg app. Your customers usually create them through an in-app interface you build, but you can also set them in code.
  • Set either featureId for a feature budget or currencyId for a credit budget, never both.
  • An upsert updates the existing entity entitlement with the same entityId, featureId or currencyId, and scopeEntityIds. Any other combination creates a new one.
  • On re-upsert, omitting usageLimit or cadence keeps the existing value. On first create, both are required.
  • Set usageLimit to null to track usage without a limit. Usage still counts and appears in check responses, but never blocks. This is useful for observing usage before you enforce it.

Place entities in a hierarchy

The parentId field places an entity under a parent in the governance hierarchy. Check evaluates every budget on the path from the entity up to the root, and grants a request only when all of them allow it. parentId is sent on an entity entitlement, but the parent belongs to the entity. An entity has one parent across all its features and credit currencies.
parentId has three states. Omitting it leaves the current parent unchanged, and new entities start at the root. null detaches the entity to the root. An entity ID sets or changes the parent. Only leaf entities can move, so an entity with children stays put.

Add dimension-scoped sub-budgets

Set scopeEntityIds to add a tighter budget for a specific context. The scoped budget applies only when every listed entity is in the request’s resolved set.

List and manage

List entity types

List entities

Get a single entity

Archive entities

Archiving is a soft delete. The entity drops out of the list but you can still fetch it by ID. To restore it, upsert it again.
The response lists the archived IDs: { data: { ids: ['old-project'] } }.

List entity entitlements

What’s next

Check and ingest

Gate access before consumption and record usage after

Query the governance tree

Fetch usage and budget data for dashboards and admin UIs