Skip to content

Consuming Fabric

Fabric is the canonical source of truth for identity, tenancy, and authorization. All services must defer to Fabric for permission decisions, tenant state, and canonical IDs.

Use Fabric as the canonical source for:

  • Organizations
  • Teams
  • Memberships
  • Invitations
  • Effective permissions
  1. Authenticate user (JWT or API key)
  2. Fetch GET /v1/me to get the current principal
  3. Fetch memberships, orgs, and teams
  4. Fetch effective permissions for the active context
  5. Cache only for UX convenience
  6. Never trust frontend-only authorization
import { FabricClient } from "@fabric-platform/sdk";
const fabric = new FabricClient({ apiKey: "fab_xxx" });
// Get current user
const me = await fabric.getMe();
// Get their organizations
const orgs = await fabric.getMyOrganizations();
// Check a permission
const result = await fabric.checkPermission({
resource: `organization:${orgId}`,
action: "read",
});

Backend services should:

  • Call Fabric for authz checks or embed a trusted decision token
  • Use Fabric org/team IDs as canonical
  • Avoid duplicating org/team/role truth
  • Use API keys or service account tokens for service-to-service calls
// Check permission before a sensitive action
const allowed = await fabric.checkPermission({
resource: `organization:${orgId}`,
action: "invite",
});
if (!allowed) throw new Error("Forbidden");

Fabric also provides a GraphQL API at POST /graphql (enabled with --features graphql). GraphQL is useful when:

  • You need nested data in one request (e.g., organizations with their teams and members)
  • You want client-driven field selection to reduce over-fetching
  • You need real-time subscriptions for workflow events via WebSocket

GraphQL uses the same authentication (JWT / API key), RBAC, ACL, and audit logging as REST. See the API Endpoints reference for the full schema and API Examples for query samples.

# One request instead of multiple REST calls
{
me { principalId }
myOrganizations {
id
name
teams(first: 10) { id name }
}
}

Every REST response conforms to a consistent envelope structure:

FieldDescription
metarequest_id, trace_id, timestamp, status, version
contextprincipal_id, organization_id, team_id
dataThe response payload
errorError details (if applicable)
linksPagination and related resource links

This applies uniformly across REST, SSE, WebSockets, and webhooks. GraphQL uses its own standard response format ({ data, errors, extensions }) instead of the envelope.

SSE payloads emit serialized envelope JSON in the data field of the event.