Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

Grants

What a principal, a workspace, every principal that is not a guest, or every guest has been given: a bundle, or one entitlement.

Entitlements explains bundles, grants, and who holds an entitlement.

Paths are relative to https://api.agentpost.tools/v1/identity, and every request follows the API basics. Who may call explains each kind of caller.

Create a grant

POST /grants

Grants a bundle or an entitlement. One Idempotency-Key identifies one create request with no time limit.

  • Who may call: Your server or a signed-in principal.
  • Access: Needs identity.grant:create for the holder.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.grants.create(input, { idempotencyKey })
  • Idempotency-Key: required. The grant keeps its key with no time limit. An authorized retry with the same key and body answers with the original grant; changing any field answers idempotency_mismatch, even after 24 hours or from another caller. Every field counts: target, holder, provenance, metadata, startsAt, and expiresAt. Object key order does not count; date strings and omitted fields do. Keep omitted fields omitted on retry: omitting startsAt again matches, but supplying the server-filled start time does not. A grant transferred to another holder refuses the original request too. For a grant with no saved request hash, the permanent check compares stored fields, compares explicit dates as instants, and allows an omitted startsAt to match the stored start. Retrying a write has the rule every write follows.

Body

Name Type Required Description
target object Yes
target.kind string Yes One of "entitlement" or "bundle".
target.entitlement string No With kind: "entitlement".
target.resource object No With kind: "entitlement".
target.resource.type string Yes
target.resource.id string Yes
target.bundle string No With kind: "bundle".
holder object Yes
holder.kind string Yes One of "principal", "workspace", or "all".
holder.id string No With kind: "principal" or kind: "workspace".
holder.of "principal" or "guest" No With kind: "all". principal: every principal that is not a guest. guest: every guest.
provenance object Yes
provenance.source string Yes Your app’s label for why the grant exists; 1–100 characters.
provenance.reference string No Up to 200 characters.
provenance.note string No Up to 1000 characters.
metadata object No
startsAt string No An ISO 8601 date and time.
expiresAt string No An ISO 8601 date and time.

Response

201 Created, with:

Name Type Present Description
grant Grant Always

Errors

Any operation can also answer with the codes Conventions lists.

List grants

GET /grants

Grants by holder, bundle, or entitlement.

  • Who may call: Your server or a signed-in principal.
  • Access: A principal lists its own grants, or a holder’s with identity.grant:view.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.grants.list(query)
  • Pages: limit, 1 to 500, default 100, with next and after. Lists has the rule.

Query parameters

Name Type Required Description
limit integer No 1–500; default 100.
after string No 1–64 characters.
holderKind string No One of "principal", "workspace", or "all".
holderId string No
holderOf "principal" or "guest" No With holderKind=all: principal for grants to every principal that is not a guest, or guest for grants to every guest.
bundle string No
entitlement string No
status string No One of "active", "revoked", or "expired".

Response

200 OK, with:

Name Type Present Description
grants Grant array Always
next string When set

Errors

Any operation can also answer with the codes Conventions lists.

Get a grant

GET /grants/:id

One grant.

  • Who may call: Your server or a signed-in principal.
  • Access: Its holder, or anyone with identity.grant:view.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.grants.get(id)

Path parameters

Name Type Required Description
id string Yes A grant ID, grt_…. The id of a Grant.

Response

200 OK, with:

Name Type Present Description
grant Grant Always

Errors

Any operation can also answer with the codes Conventions lists.

Revoke a grant

POST /grants/:id/revoke

Revokes a grant.

  • Who may call: Your server or a signed-in principal.
  • Access: Needs identity.grant:revoke.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.grants.revoke(id, input)
  • Idempotency-Key: optional. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes A grant ID, grt_…. The id of a Grant.

Body

The body is optional.

Name Type Required Description
reason string No Up to 1000 characters.

Response

200 OK, with:

Name Type Present Description
grant Grant Always

Errors

Any operation can also answer with the codes Conventions lists.

The Grant object

What a principal, a workspace, every guest, or every principal that is not a guest has been given (ih_grants). A grant past expiresAt stops counting at once; the sweep then marks it expired and emits the event.

Name Type Present Description
id string Always A grant ID, grt_….
target object Always
target.kind string Always One of "entitlement" or "bundle".
target.entitlement string When set With kind: "entitlement".
target.resource object When set With kind: "entitlement".
target.resource.type string Always
target.resource.id string Always
target.bundle string When set With kind: "bundle".
holder object Always
holder.kind string Always One of "principal", "workspace", or "all".
holder.id string When set With kind: "principal" or kind: "workspace".
holder.of "principal" or "guest" When set With kind: "all". What a role, a grant, a resource role, or an invitation may say about who holds or accepts it: guest for a guest, or principal for every principal that is not a guest. A declared kind never counts.
provenance object Always
provenance.source string Always Your app’s label for why the grant exists, 1 to 100 characters.
provenance.reference string When set Opaque, such as an order ID or an achievement ID.
provenance.note string When set
metadata object When set Your app’s data, at most 4 KB. IdentityHound answers with it as you sent it.
startsAt string Always An ISO 8601 date and time.
expiresAt string When set An ISO 8601 date and time.
status string Always One of "active", "revoked", or "expired".
idempotencyKey string Always
grantedBy string Always A principal ID, prn_…, or "trusted_caller".
createdAt string Always An ISO 8601 date and time.
revokedAt string When set An ISO 8601 date and time.
revokedBy string When set A principal ID, prn_…, or "trusted_caller".
revokeReason string When set
expiredAt string When set An ISO 8601 date and time.