Skip to content

TypeScript API / contentia/json-api / AuthorizeDecision

Type Alias: AuthorizeDecision ​

ts
type AuthorizeDecision = 
  | boolean
  | ContentiaError;

The verdict an authorization callback returns for a single API action:

  • true — allow the action.
  • false — deny it with a generic ForbiddenError (HTTP 403).
  • a ContentiaError — deny it with that specific error, so callers can customise the status/message (e.g. return an AuthenticationError for a missing token → 401, or a bespoke ForbiddenError with a reason).

Callbacks may return the decision synchronously or as a Promise (e.g. when they need to look up a token in a database).