Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

Entitlements

An entitlement is something a principal has been given, such as exporting reports or playing one game, alongside what its role allows. Your product sells, awards, or gifts entitlements; IdentityHound records who holds each one, and access checks can require one before they allow an action.

The catalog

Your config lists every entitlement your product has, each with a key, such as reports.export, a description, and optionally a resourceType, for one given on single resources of that type. A resource type’s requiresEntitlement maps actions to the entitlements they require: with { export: 'reports.export' }, exporting a report needs reports.export on top of a role that allows it, and a check without it answers entitlement_missing.

Bundles

A bundle is a named set of entitlements granted together, such as a plan. Its key is its ID, such as pro.

  • Editing a bundle changes every holder at once. A grant of pro gives whatever pro holds now, and each edit adds 1 to its version.
  • Retiring a bundle makes its grants give nothing. They stay as history, and POST /grants for a new grant of it answers bundle_retired.

Grants

A grant gives one bundle, or one entitlement, to a holder:

  • A principal, such as one that bought a plan.
  • A workspace: its active members hold it whenever a question is asked in that workspace, until the workspace is archived.
  • Every guest, or every principal that is not a guest, for something everyone gets: { kind: 'all', of: 'guest' } or { kind: 'all', of: 'principal' }.

When creating a grant, you can give an entitlement on a single resource of its catalog entry’s resourceType, such as one game. A different type answers invalid_request. Held that way, it covers only that resource; held without a resource, it covers every resource.

Each grant records why it exists: its required provenance.source is your app’s own label, such as purchase or partner, and you can include a reference, such as an order ID. Every grant names its own label, including one you import.

A grant may start later, with startsAt, and end, with expiresAt: past its end it stops counting at once. Revoking it stops it too, and a revoked or expired grant stays as history.

Creating a grant needs an Idempotency-Key, and the grant keeps it with no time limit, so the same key never makes a second grant. Send something that names the reason once, such as the order ID. Create a grant has the rule in full.

Your server or a principal with identity.grant:create can create a grant. Agentpost’s starting roles and the owner role’s built-in permissions leave that permission out. A grant’s optional metadata holds your app’s data, and IdentityHound answers with it as you sent it. For example, use metadata: { usageCounter: 'usage-1001' } to point to where your app counts usage.

Limits

  • A bundle’s name: 1 to 120 characters.
  • A grant’s provenance.source: 1 to 100 characters.
  • A grant’s provenance.reference: 200 characters, and provenance.note: 1,000.
  • A grant’s metadata must be a JSON object with JSON.stringify(metadata).length at most 4,096.

Where to act on it

  • Grant a plan defines a bundle and grants it to a workspace once per order.
  • Bundles, Grants, and Entitlements have every operation; the last checks and lists what a principal holds.
  • The config holds the catalog and each action’s requirement.