NewWacht Bench is live — AI-assisted development for Wacht

checkPrincipalAuthz()

Builds and sends an authz request from flattened principal arguments.

Usage

The following example shows a basic usage of the backend client from @wacht/nextjs/server.

import { checkPrincipalAuthz } from '@wacht/backend';export async function canPrincipalWrite(apiKey: string) {  return checkPrincipalAuthz({    principalType: 'api_key',    principalValue: apiKey,    resource: 'users/*',    method: 'POST',  });}

Signature

function checkPrincipalAuthz(  payload: GatewayPrincipalAuthzRequest,  options?: GatewayCheckAuthzOptions,): Promise<AuthzCheckResponse>

Behavior

  • Builds and evaluates a gateway authorization check for a flattened principal payload.
  • Use this helper when callers only have principal type/value rather than a full principal object.

On this page