---
title: "IdentityHound API: Grants"
description: "Create a grant, list grants, get a grant, or revoke a grant, with the IdentityHound API."
url: "https://agentpost.tools/docs/identityhound/reference/grants"
kind: reference
---

# 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](/docs/identityhound/concepts/entitlements.md) 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](/docs/platform/api-basics.md). [Who may call](/docs/identityhound/reference.md#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`](/docs/identityhound/errors.md#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](/docs/platform/api-basics.md#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`](/docs/identityhound/reference/grants.md#the-grant-object) | Always |  |

### Errors

-   [`bundle_retired`](/docs/identityhound/errors.md#bundle_retired) (409)
-   [`conflict`](/docs/identityhound/errors.md#conflict) (409)
-   [`entitlement_unknown`](/docs/identityhound/errors.md#entitlement_unknown) (422)
-   [`forbidden`](/docs/identityhound/errors.md#forbidden) (403)
-   [`idempotency_mismatch`](/docs/identityhound/errors.md#idempotency_mismatch) (409)
-   [`not_found`](/docs/identityhound/errors.md#not_found) (404)

Any operation can also answer with the codes [Conventions](/docs/identityhound/reference.md#conventions) lists.

```bash tab="curl"
curl -X POST https://api.agentpost.tools/v1/identity/grants \
  -H "Authorization: Bearer sk_test_…" \
  -H "Idempotency-Key: order_1042" \
  -H "Content-Type: application/json" \
  -d '{
    "target": {
      "kind": "bundle",
      "bundle": "pro"
    },
    "holder": {
      "kind": "workspace",
      "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
    },
    "provenance": {
      "source": "purchase",
      "reference": "order_1042"
    }
  }'
```

```ts tab="SDK"
import { createClient } from '@agentpost-tools/identityhound-sdk';

const client = createClient({ token: 'sk_test_…' });
const { grant } = await client.grants.create(
  {
    target: { kind: 'bundle', bundle: 'pro' },
    holder: { kind: 'workspace', id: 'wsp_01JDGKQN2K4RF0M0Z2HBASFA62' },
    provenance: { source: 'purchase', reference: 'order_1042' },
  },
  { idempotencyKey: 'order_1042' },
);
```

```json title="Response"
{
  "grant": {
    "id": "grt_01JD708CK3K0Y4F83NATYTFGW9",
    "target": {
      "kind": "bundle",
      "bundle": "pro"
    },
    "holder": {
      "kind": "workspace",
      "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
    },
    "provenance": {
      "source": "purchase",
      "reference": "order_1042"
    },
    "startsAt": "2026-11-13T09:30:00.000Z",
    "status": "active",
    "idempotencyKey": "order_1042",
    "grantedBy": "trusted_caller",
    "createdAt": "2026-11-13T09:30:00.000Z"
  }
}
```

## 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](/docs/platform/api-basics.md#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`](/docs/identityhound/reference/grants.md#the-grant-object) array | Always |  |
| `next` | `string` | When set |  |

### Errors

-   [`forbidden`](/docs/identityhound/errors.md#forbidden) (403)

Any operation can also answer with the codes [Conventions](/docs/identityhound/reference.md#conventions) lists.

```bash tab="curl"
curl 'https://api.agentpost.tools/v1/identity/grants?holderKind=workspace&holderId=wsp_01JDGKQN2K4RF0M0Z2HBASFA62' \
  -H "Authorization: Bearer sk_test_…"
```

```ts tab="SDK"
import { createClient } from '@agentpost-tools/identityhound-sdk';

const client = createClient({ token: 'sk_test_…' });
const { grants } = await client.grants.list({
  holderKind: 'workspace',
  holderId: 'wsp_01JDGKQN2K4RF0M0Z2HBASFA62',
});
```

```json title="Response"
{
  "grants": [
    {
      "id": "grt_01JD708CK3K0Y4F83NATYTFGW9",
      "target": {
        "kind": "bundle",
        "bundle": "pro"
      },
      "holder": {
        "kind": "workspace",
        "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
      },
      "provenance": {
        "source": "purchase",
        "reference": "order_1042"
      },
      "startsAt": "2026-11-13T09:30:00.000Z",
      "status": "active",
      "idempotencyKey": "order_1042",
      "grantedBy": "trusted_caller",
      "createdAt": "2026-11-13T09:30:00.000Z"
    }
  ]
}
```

## 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`](/docs/identityhound/reference/grants.md#the-grant-object). |

### Response

`200 OK`, with:

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `grant` | [`Grant`](/docs/identityhound/reference/grants.md#the-grant-object) | Always |  |

### Errors

-   [`forbidden`](/docs/identityhound/errors.md#forbidden) (403)
-   [`not_found`](/docs/identityhound/errors.md#not_found) (404)

Any operation can also answer with the codes [Conventions](/docs/identityhound/reference.md#conventions) lists.

```bash tab="curl"
curl https://api.agentpost.tools/v1/identity/grants/grt_01JD708CK3K0Y4F83NATYTFGW9 \
  -H "Authorization: Bearer sk_test_…"
```

```ts tab="SDK"
import { createClient } from '@agentpost-tools/identityhound-sdk';

const client = createClient({ token: 'sk_test_…' });
const { grant } = await client.grants.get('grt_01JD708CK3K0Y4F83NATYTFGW9');
```

```json title="Response"
{
  "grant": {
    "id": "grt_01JD708CK3K0Y4F83NATYTFGW9",
    "target": {
      "kind": "bundle",
      "bundle": "pro"
    },
    "holder": {
      "kind": "workspace",
      "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
    },
    "provenance": {
      "source": "purchase",
      "reference": "order_1042"
    },
    "startsAt": "2026-11-13T09:30:00.000Z",
    "status": "active",
    "idempotencyKey": "order_1042",
    "grantedBy": "trusted_caller",
    "createdAt": "2026-11-13T09:30:00.000Z"
  }
}
```

## 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](/docs/platform/api-basics.md#retrying-a-write) has the rule.

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | A grant ID, `grt_…`. The `id` of a [`Grant`](/docs/identityhound/reference/grants.md#the-grant-object). |

### 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`](/docs/identityhound/reference/grants.md#the-grant-object) | Always |  |

### Errors

-   [`forbidden`](/docs/identityhound/errors.md#forbidden) (403)
-   [`grant_not_active`](/docs/identityhound/errors.md#grant_not_active) (409)
-   [`not_found`](/docs/identityhound/errors.md#not_found) (404)

Any operation can also answer with the codes [Conventions](/docs/identityhound/reference.md#conventions) lists.

```bash tab="curl"
curl -X POST https://api.agentpost.tools/v1/identity/grants/grt_01JD708CK3K0Y4F83NATYTFGW9/revoke \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "reason": "Refunded"
  }'
```

```ts tab="SDK"
import { createClient } from '@agentpost-tools/identityhound-sdk';

const client = createClient({ token: 'sk_test_…' });
const { grant } = await client.grants.revoke('grt_01JD708CK3K0Y4F83NATYTFGW9', {
  reason: 'Refunded',
});
```

```json title="Response"
{
  "grant": {
    "id": "grt_01JD708CK3K0Y4F83NATYTFGW9",
    "target": {
      "kind": "bundle",
      "bundle": "pro"
    },
    "holder": {
      "kind": "workspace",
      "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
    },
    "provenance": {
      "source": "purchase",
      "reference": "order_1042"
    },
    "startsAt": "2026-11-13T09:30:00.000Z",
    "status": "revoked",
    "idempotencyKey": "order_1042",
    "grantedBy": "trusted_caller",
    "createdAt": "2026-11-13T09:30:00.000Z",
    "revokedAt": "2026-11-13T09:30:00.000Z",
    "revokedBy": "trusted_caller",
    "revokeReason": "Refunded"
  }
}
```

## 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. |

```json title="The Grant object"
{
  "id": "grt_01JD708CK3K0Y4F83NATYTFGW9",
  "target": {
    "kind": "bundle",
    "bundle": "pro"
  },
  "holder": {
    "kind": "workspace",
    "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
  },
  "provenance": {
    "source": "purchase",
    "reference": "order_1042"
  },
  "startsAt": "2026-11-13T09:30:00.000Z",
  "status": "active",
  "idempotencyKey": "order_1042",
  "grantedBy": "trusted_caller",
  "createdAt": "2026-11-13T09:30:00.000Z"
}
```
