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:createfor the holder. - Credential: the examples send your project’s
devsecret key,sk_test_…, asAuthorization: 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, andexpiresAt. Object key order does not count; date strings and omitted fields do. Keep omitted fields omitted on retry: omittingstartsAtagain 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 omittedstartsAtto match the stored start. Retrying a write has the rule every write follows.
Body
| Name | Type | Required | Description |
|---|---|---|---|
target |
object |
Yes | |
target. |
string |
Yes | One of "entitlement" or "bundle". |
target. |
string |
No | With kind: "entitlement". |
target. |
object |
No | With kind: "entitlement". |
target. |
string |
Yes | |
target. |
string |
Yes | |
target. |
string |
No | With kind: "bundle". |
holder |
object |
Yes | |
holder. |
string |
Yes | One of "principal", "workspace", or "all". |
holder. |
string |
No | With kind: "principal" or kind: "workspace". |
holder. |
"principal" or "guest" |
No | With kind: "all". principal: every principal that is not a guest. guest: every guest. |
provenance |
object |
Yes | |
provenance. |
string |
Yes | Your app’s label for why the grant exists; 1–100 characters. |
provenance. |
string |
No | Up to 200 characters. |
provenance. |
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
bundle_retired(409)conflict(409)entitlement_unknown(422)forbidden(403)idempotency_mismatch(409)not_found(404)
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
devsecret key,sk_test_…, asAuthorization: Bearer <token>. - SDK:
client.grants.list(query) - Pages:
limit, 1 to 500, default 100, withnextandafter. 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
forbidden(403)
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
devsecret key,sk_test_…, asAuthorization: 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
devsecret key,sk_test_…, asAuthorization: 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
forbidden(403)grant_not_active(409)not_found(404)
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. |
string |
Always | One of "entitlement" or "bundle". |
target. |
string |
When set | With kind: "entitlement". |
target. |
object |
When set | With kind: "entitlement". |
target. |
string |
Always | |
target. |
string |
Always | |
target. |
string |
When set | With kind: "bundle". |
holder |
object |
Always | |
holder. |
string |
Always | One of "principal", "workspace", or "all". |
holder. |
string |
When set | With kind: "principal" or kind: "workspace". |
holder. |
"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. |
string |
Always | Your app’s label for why the grant exists, 1 to 100 characters. |
provenance. |
string |
When set | Opaque, such as an order ID or an achievement ID. |
provenance. |
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. |