---
title: "IdentityHound API: Access checks"
description: "Check access, check access in a batch, or list permissions on a resource, with the IdentityHound API."
url: "https://agentpost.tools/docs/identityhound/reference/access"
kind: reference
---

# Access checks

One decision for “may this principal do this to that resource?”, with a reason an app or an agent can act on. Every answer names its config version.

[Access checks](/docs/identityhound/concepts/access-checks.md) explains the order a check takes and what each reason means.

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.

## Check access

`POST /access/check`

Allowed or denied, with the reason. `explain: true` adds each step; `audit: true` records a denial in the change feed.

-   **Who may call:** Your server or a signed-in principal.
-   **Access:** A principal checks itself, and a principal with a delegated token checks within its delegation. A trusted caller names any `principalId`, and may name a `delegateId` and `delegationId`.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.access.check(request)`
-   **Idempotency-Key:** not taken. A check reads the current permissions, so IdentityHound runs it on every request and it takes no `Idempotency-Key`. With `audit: true`, a retried denial is recorded again.

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `principalId` | `string` | No | A principal ID, `prn_…`. |
| `delegateId` | `string` | No | The delegate that would act for `principalId` under a delegation. The check then holds the delegate to that delegation. |
| `delegationId` | `string` | No | The delegation the delegate acts under, `dlg_…`. Left out, the check uses the newest active delegation from the principal to the `delegateId` that covers the permission, among those for the resource’s workspace or for none. |
| `action` | `string` | Yes | An action of the resource type, such as “edit” or “transaction.view”. |
| `resource` | `object` | Yes |  |
| `resource.type` | `string` | Yes |  |
| `resource.id` | `string` | Yes |  |
| `resource.workspaceId` | `string` | No | The workspace the resource belongs to. Workspace roles count only when it is set, so leave it out only for a resource outside any workspace. |
| `explain` | `boolean` | No |  |
| `audit` | `boolean` | No |  |

### Response

`200 OK`, with [`CheckResponse`](/docs/identityhound/reference/access.md#the-checkresponse-object).

### 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 -X POST https://api.agentpost.tools/v1/identity/access/check \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "principalId": "prn_01JD1F7TG1SVVEHCFCS56KF78R",
    "action": "edit",
    "resource": {
      "type": "report",
      "id": "q3-revenue",
      "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
    }
  }'
```

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

const client = createClient({ token: 'sk_test_…' });
const result = await client.access.check({
  principalId: 'prn_01JD1F7TG1SVVEHCFCS56KF78R',
  action: 'edit',
  resource: {
    type: 'report',
    id: 'q3-revenue',
    workspaceId: 'wsp_01JDGKQN2K4RF0M0Z2HBASFA62',
  },
});
```

```json title="Response"
{
  "allowed": true,
  "reason": "resource_role",
  "matched": {
    "role": "editor",
    "resourceRoleId": "rro_01JD2FKSRJGD9ZJD5JHCA24JM8"
  },
  "configVersion": 3
}
```

## Check access in a batch

`POST /access/check-batch`

Up to 100 checks in one call, answered in order.

-   **Who may call:** Your server or a signed-in principal.
-   **Access:** Each check follows the rules of `POST /access/check`.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.access.checkBatch(checks)`
-   **Idempotency-Key:** not taken. A check reads the current permissions, so IdentityHound runs it on every request and it takes no `Idempotency-Key`. With `audit: true`, a retried denial is recorded again.

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `checks` | `object[]` | Yes | 1–100 items. |
| `checks[].principalId` | `string` | No | A principal ID, `prn_…`. |
| `checks[].delegateId` | `string` | No | The delegate that would act for `principalId` under a delegation. The check then holds the delegate to that delegation. |
| `checks[].delegationId` | `string` | No | The delegation the delegate acts under, `dlg_…`. Left out, the check uses the newest active delegation from the principal to the `delegateId` that covers the permission, among those for the resource’s workspace or for none. |
| `checks[].action` | `string` | Yes | An action of the resource type, such as “edit” or “transaction.view”. |
| `checks[].resource` | `object` | Yes |  |
| `checks[].resource.type` | `string` | Yes |  |
| `checks[].resource.id` | `string` | Yes |  |
| `checks[].resource.workspaceId` | `string` | No | The workspace the resource belongs to. Workspace roles count only when it is set, so leave it out only for a resource outside any workspace. |
| `checks[].explain` | `boolean` | No |  |
| `checks[].audit` | `boolean` | No |  |

### Response

`200 OK`, with [`CheckBatchResponse`](/docs/identityhound/reference/access.md#the-checkbatchresponse-object).

### 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 -X POST https://api.agentpost.tools/v1/identity/access/check-batch \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "checks": [
      {
        "principalId": "prn_01JD1F7TG1SVVEHCFCS56KF78R",
        "action": "edit",
        "resource": {
          "type": "report",
          "id": "q3-revenue",
          "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
        }
      },
      {
        "principalId": "prn_01JD1F7TG1SVVEHCFCS56KF78R",
        "action": "export",
        "resource": {
          "type": "report",
          "id": "q3-revenue",
          "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
        }
      }
    ]
  }'
```

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

const client = createClient({ token: 'sk_test_…' });
const { results } = await client.access.checkBatch([
  {
    principalId: 'prn_01JD1F7TG1SVVEHCFCS56KF78R',
    action: 'edit',
    resource: {
      type: 'report',
      id: 'q3-revenue',
      workspaceId: 'wsp_01JDGKQN2K4RF0M0Z2HBASFA62',
    },
  },
  {
    principalId: 'prn_01JD1F7TG1SVVEHCFCS56KF78R',
    action: 'export',
    resource: {
      type: 'report',
      id: 'q3-revenue',
      workspaceId: 'wsp_01JDGKQN2K4RF0M0Z2HBASFA62',
    },
  },
]);
```

```json title="Response"
{
  "results": [
    {
      "allowed": true,
      "reason": "resource_role",
      "matched": {
        "role": "editor",
        "resourceRoleId": "rro_01JD2FKSRJGD9ZJD5JHCA24JM8"
      },
      "configVersion": 3
    },
    {
      "allowed": false,
      "reason": "entitlement_missing",
      "configVersion": 3
    }
  ]
}
```

## List permissions on a resource

`GET /access/permissions`

Every permission a principal holds on one resource. An agent calls this to find what it may do. An action that would be denied for any reason, including a missing entitlement, is left out; `POST /access/check` says why.

-   **Who may call:** Your server or a signed-in principal.
-   **Access:** A principal asks about itself; a trusted caller names any `principalId`.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.access.permissions(query)`

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `principalId` | `string` | No | A principal ID, `prn_…`. |
| `resourceType` | `string` | Yes |  |
| `resourceId` | `string` | Yes |  |
| `workspaceId` | `string` | No | The workspace the resource belongs to. Workspace roles count only when it is set. |

### Response

`200 OK`, with [`PermissionsResponse`](/docs/identityhound/reference/access.md#the-permissionsresponse-object).

### 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/access/permissions?principalId=prn_01JD1F7TG1SVVEHCFCS56KF78R&resourceType=report&resourceId=q3-revenue&workspaceId=wsp_01JDGKQN2K4RF0M0Z2HBASFA62' \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
const { permissions, configVersion } = await client.access.permissions({
  principalId: 'prn_01JD1F7TG1SVVEHCFCS56KF78R',
  resourceType: 'report',
  resourceId: 'q3-revenue',
  workspaceId: 'wsp_01JDGKQN2K4RF0M0Z2HBASFA62',
});
```

```json title="Response"
{
  "permissions": ["report:view", "report:edit"],
  "configVersion": 3
}
```

## The CheckResponse object

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `allowed` | `boolean` | Always |  |
| `reason` | `string` | Always | One of [`"project_role"`](/docs/identityhound/errors.md#project_role), [`"workspace_role"`](/docs/identityhound/errors.md#workspace_role), [`"resource_role"`](/docs/identityhound/errors.md#resource_role), [`"unknown_permission"`](/docs/identityhound/errors.md#unknown_permission), [`"principal_inactive"`](/docs/identityhound/errors.md#principal_inactive), [`"actor_inactive"`](/docs/identityhound/errors.md#actor_inactive), [`"delegation_missing"`](/docs/identityhound/errors.md#delegation_missing), [`"delegation_expired"`](/docs/identityhound/errors.md#delegation_expired), [`"delegation_scope"`](/docs/identityhound/errors.md#delegation_scope), [`"delegation_workspace"`](/docs/identityhound/errors.md#delegation_workspace), [`"credential_restricted"`](/docs/identityhound/errors.md#credential_restricted), [`"no_access"`](/docs/identityhound/errors.md#no_access), [`"workspace_archived"`](/docs/identityhound/errors.md#workspace_archived), or [`"entitlement_missing"`](/docs/identityhound/errors.md#entitlement_missing). |
| `matched` | `object` | When set |  |
| `matched.role` | `string` | When set |  |
| `matched.membershipId` | `string` | When set | A membership ID, `mem_…`. |
| `matched.resourceRoleId` | `string` | When set | A resource role ID, `rro_…`. |
| `matched.grantId` | `string` | When set | A grant ID, `grt_…`. |
| `matched.delegationId` | `string` | When set | A delegation ID, `dlg_…`. |
| `configVersion` | `number` | Always |  |
| `steps` | `object[]` | When set |  |
| `steps[].step` | `string` | Always |  |
| `steps[].outcome` | `string` | Always | One of `"pass"`, `"fail"`, or `"skip"`. |
| `steps[].detail` | `string` | When set |  |

```json title="The CheckResponse object"
{
  "allowed": true,
  "reason": "resource_role",
  "matched": {
    "role": "editor",
    "resourceRoleId": "rro_01JD2FKSRJGD9ZJD5JHCA24JM8"
  },
  "configVersion": 3
}
```

## The CheckBatchResponse object

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `results` | [`CheckResponse`](/docs/identityhound/reference/access.md#the-checkresponse-object) array | Always |  |

```json title="The CheckBatchResponse object"
{
  "results": [
    {
      "allowed": true,
      "reason": "resource_role",
      "matched": {
        "role": "editor",
        "resourceRoleId": "rro_01JD2FKSRJGD9ZJD5JHCA24JM8"
      },
      "configVersion": 3
    },
    {
      "allowed": false,
      "reason": "entitlement_missing",
      "configVersion": 3
    }
  ]
}
```

## The PermissionsResponse object

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `permissions` | `string[]` | Always |  |
| `configVersion` | `number` | Always |  |

```json title="The PermissionsResponse object"
{
  "permissions": ["report:view", "report:edit"],
  "configVersion": 3
}
```
