---
title: "IdentityHound API: Resource roles"
description: "Assign a resource role, list resource roles, or remove a resource role, with the IdentityHound API."
url: "https://agentpost.tools/docs/identityhound/reference/resource-roles"
kind: reference
---

# Resource roles

A role on one resource, such as editor of one report, held by a principal, by every principal that is not a guest, or by every guest.

[Roles](/docs/identityhound/concepts/roles.md) explains resource roles beside project and workspace roles.

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.

## Assign a resource role

`POST /resource-roles`

Gives a principal, every principal that is not a guest, or every guest a role on a resource.

-   **Who may call:** Your server or a signed-in principal.
-   **Access:** Needs `identity.resource_role:assign` in the resource’s workspace. Without a workspace, only a trusted caller.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.resourceRoles.assign(input)`
-   **Idempotency-Key:** optional. [Retrying a write](/docs/platform/api-basics.md#retrying-a-write) has the rule.

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `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. |
| `holder` | `object` | Yes |  |
| `holder.kind` | `"principal"` or `"all"` | Yes |  |
| `holder.id` | `string` | No | With `kind: "principal"`. A principal ID, `prn_…`. |
| `holder.of` | `"principal"` or `"guest"` | No | With `kind: "all"`. `principal`: every principal that is not a guest. `guest`: every guest. |
| `role` | `string` | Yes | A role key from the config, such as “member”. |
| `expiresAt` | `string` | No | An ISO 8601 date and time. |

### Response

`201 Created`, with:

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `resourceRole` | [`ResourceRole`](/docs/identityhound/reference/resource-roles.md#the-resourcerole-object) | Always |  |

### Errors

-   [`conflict`](/docs/identityhound/errors.md#conflict) (409)
-   [`forbidden`](/docs/identityhound/errors.md#forbidden) (403)
-   [`not_found`](/docs/identityhound/errors.md#not_found) (404)
-   [`role_not_assignable`](/docs/identityhound/errors.md#role_not_assignable) (422)
-   [`trusted_caller_required`](/docs/identityhound/errors.md#trusted_caller_required) (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/resource-roles \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "resource": {
      "type": "report",
      "id": "q3-revenue",
      "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
    },
    "holder": {
      "kind": "principal",
      "id": "prn_01JD1F7TG1SVVEHCFCS56KF78R"
    },
    "role": "editor"
  }'
```

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

const client = createClient({ token: 'sk_test_…' });
const { resourceRole } = await client.resourceRoles.assign({
  resource: {
    type: 'report',
    id: 'q3-revenue',
    workspaceId: 'wsp_01JDGKQN2K4RF0M0Z2HBASFA62',
  },
  holder: { kind: 'principal', id: 'prn_01JD1F7TG1SVVEHCFCS56KF78R' },
  role: 'editor',
});
```

```json title="Response"
{
  "resourceRole": {
    "id": "rro_01JD2FKSRJGD9ZJD5JHCA24JM8",
    "resource": {
      "type": "report",
      "id": "q3-revenue"
    },
    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
    "holder": {
      "kind": "principal",
      "id": "prn_01JD1F7TG1SVVEHCFCS56KF78R"
    },
    "role": "editor",
    "assignedBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "createdAt": "2026-11-13T09:30:00.000Z"
  }
}
```

## List resource roles

`GET /resource-roles`

The roles on one resource, or the roles one holder holds.

-   **Who may call:** Your server or a signed-in principal.
-   **Access:** By resource, needs `identity.resource_role:view`. By holder, a principal may list only its own.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.resourceRoles.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. |
| `resourceType` | `string` | No |  |
| `resourceId` | `string` | No |  |
| `workspaceId` | `string` | No | A workspace ID, `wsp_…`. |
| `holder` | `string` | No |  |

### Response

`200 OK`, with:

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `resourceRoles` | [`ResourceRole`](/docs/identityhound/reference/resource-roles.md#the-resourcerole-object) array | Always |  |
| `next` | `string` | When set |  |

### Errors

-   [`forbidden`](/docs/identityhound/errors.md#forbidden) (403)
-   [`trusted_caller_required`](/docs/identityhound/errors.md#trusted_caller_required) (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/resource-roles?resourceType=report&resourceId=q3-revenue' \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
const { resourceRoles } = await client.resourceRoles.list({
  resourceType: 'report',
  resourceId: 'q3-revenue',
});
```

```json title="Response"
{
  "resourceRoles": [
    {
      "id": "rro_01JD2FKSRJGD9ZJD5JHCA24JM8",
      "resource": {
        "type": "report",
        "id": "q3-revenue"
      },
      "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
      "holder": {
        "kind": "principal",
        "id": "prn_01JD1F7TG1SVVEHCFCS56KF78R"
      },
      "role": "editor",
      "assignedBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
      "createdAt": "2026-11-13T09:30:00.000Z"
    }
  ]
}
```

## Remove a resource role

`DELETE /resource-roles/:id`

Removes a resource role.

-   **Who may call:** Your server or a signed-in principal.
-   **Access:** Needs `identity.resource_role:remove`.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.resourceRoles.remove(id)`
-   **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 resource role ID, `rro_…`. The `id` of a [`ResourceRole`](/docs/identityhound/reference/resource-roles.md#the-resourcerole-object). |

### Response

`204 No Content`, with no body.

### Errors

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

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

```bash tab="curl"
curl -X DELETE https://api.agentpost.tools/v1/identity/resource-roles/rro_01JD2FKSRJGD9ZJD5JHCA24JM8 \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
await client.resourceRoles.remove('rro_01JD2FKSRJGD9ZJD5JHCA24JM8');
```

```text title="Response"
204 No Content
```

## The ResourceRole object

A role held on one resource (ih\_resource\_roles).

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `id` | `string` | Always | A resource role ID, `rro_…`. |
| `resource` | `object` | Always |  |
| `resource.type` | `string` | Always |  |
| `resource.id` | `string` | Always |  |
| `workspaceId` | `string` | When set | The resource’s home workspace, if any. Assignments without one are managed by trusted callers. |
| `holder` | `object` | Always | A resource role’s holder: a principal, every guest, or every principal that is not a guest; never a workspace. |
| `holder.kind` | `"principal"` or `"all"` | Always |  |
| `holder.id` | `string` | When set | With `kind: "principal"`. A principal ID, `prn_…`. |
| `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. |
| `role` | `string` | Always |  |
| `assignedBy` | `string` | Always | A principal ID, `prn_…`, or `"trusted_caller"`. |
| `createdAt` | `string` | Always | An ISO 8601 date and time. |
| `expiresAt` | `string` | When set | An ISO 8601 date and time. |

```json title="The ResourceRole object"
{
  "id": "rro_01JD2FKSRJGD9ZJD5JHCA24JM8",
  "resource": {
    "type": "report",
    "id": "q3-revenue"
  },
  "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
  "holder": {
    "kind": "principal",
    "id": "prn_01JD1F7TG1SVVEHCFCS56KF78R"
  },
  "role": "editor",
  "assignedBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
  "createdAt": "2026-11-13T09:30:00.000Z"
}
```
