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

# Project roles

Roles a principal holds across the project. Only your server assigns or removes them. Read them in the principal’s `projectRoles`.

[Roles](/docs/identityhound/concepts/roles.md) explains the three places a role is held, and how a check tries them.

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 project role

`POST /principals/:id/project-roles`

Gives an active principal a configured role with `scope: "project"`, when the role’s `assignableTo` opens it to the principal: a guest only where it lists `guest`. Answers with the principal. Assigning a role it already holds changes nothing.

-   **Who may call:** Your server.
-   **Access:** Emits `project_role.assigned` with `principalId` and `role` only when the role is added.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.projectRoles.assign(principalId, 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 principal ID, `prn_…`. The `id` of a [`Principal`](/docs/identityhound/reference/principals.md#the-principal-object). |

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `role` | `string` | Yes | A configured project role, such as “support”. |

### Response

`200 OK`, with:

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `principal` | [`Principal`](/docs/identityhound/reference/principals.md#the-principal-object) | Always |  |

### Errors

-   [`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/principals/prn_01JD1F7TG1SVVEHCFCS56KF78R/project-roles \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "role": "support"
  }'
```

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

const client = createClient({ token: 'sk_test_…' });
const { principal } = await client.projectRoles.assign(
  'prn_01JD1F7TG1SVVEHCFCS56KF78R',
  { role: 'support' },
);
```

```json title="Response"
{
  "principal": {
    "id": "prn_01JD1F7TG1SVVEHCFCS56KF78R",
    "kind": "human",
    "status": "active",
    "displayName": "Grace Hopper",
    "projectRoles": ["support"],
    "metadata": {},
    "createdAt": "2026-11-05T10:12:00.000Z",
    "updatedAt": "2026-11-13T09:30:00.000Z"
  }
}
```

## Remove a project role

`DELETE /principals/:id/project-roles/:role`

Removes a project role, including from a suspended principal or after the role leaves the config. Removing a role it does not hold changes nothing.

-   **Who may call:** Your server.
-   **Access:** Emits `project_role.removed` with `principalId` and `role` only when the role is removed. A deleted or missing principal answers `not_found`.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.projectRoles.remove(principalId, role)`
-   **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 principal ID, `prn_…`. The `id` of a [`Principal`](/docs/identityhound/reference/principals.md#the-principal-object). |
| `role` | `string` | Yes | A project role: a key of the config’s `roles` whose `scope` is `project`, such as `support`. |

### Response

`204 No Content`, with no body.

### Errors

-   [`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/principals/prn_01JD1F7TG1SVVEHCFCS56KF78R/project-roles/support \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
await client.projectRoles.remove('prn_01JD1F7TG1SVVEHCFCS56KF78R', 'support');
```

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