---
title: "IdentityHound API: Principals"
description: "List principals, import principals, create a principal, get a principal, list a principal's identities, list a principal's sessions, get a session, update a principal, suspend a principal, reactivate a principal, or delete a principal, with the IdentityHound API."
url: "https://agentpost.tools/docs/identityhound/reference/principals"
kind: reference
---

# Principals

Principals and their sign-in methods. A principal may declare a kind, `human`, `agent`, or `service`, as a label it can change at any time. Roles, grants, and invitations treat every kind alike.

[Principals](/docs/identityhound/concepts/principals.md) explains optional principal kinds, sign-in methods, guests, and what suspending or deleting one stops.

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.

## List principals

`GET /principals`

Finds principals by kind, status, name or email, or `externalRef`. `kind` matches a declared label, or `guest`.

-   **Who may call:** Your server.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.principals.list(query)`
-   **Pages:** `limit`, 1 to 500, default 100. The answer holds up to `limit` items; narrow the query’s filters to reach others.

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `kind` | `string` | No | A kind: `guest`, which IdentityHound sets, or a label a principal declared itself: `human`, `agent`, or `service`. Every setting treats the declared kinds alike. One of `"human"`, `"guest"`, `"agent"`, or `"service"`. |
| `status` | `string` | No | One of `"active"`, `"suspended"`, or `"deleted"`. |
| `q` | `string` | No | 1–120 characters. |
| `externalRef` | `string` | No | 1–200 characters. |
| `limit` | `integer` | No | 1–500; default `100`. |

### Response

`200 OK`, with:

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

### Errors

-   [`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/principals?kind=agent&limit=20' \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
const { principals } = await client.principals.list({
  kind: 'agent',
  limit: 20,
});
```

```json title="Response"
{
  "principals": [
    {
      "id": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
      "kind": "agent",
      "status": "active",
      "displayName": "Report assistant",
      "projectRoles": [],
      "description": "Drafts the weekly report",
      "metadata": {},
      "createdAt": "2026-11-06T16:40:00.000Z",
      "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
      "updatedAt": "2026-11-06T16:40:00.000Z"
    }
  ]
}
```

## Import principals

`POST /principals/import`

Brings up to 500 existing principals across at once, with their identities, project roles, memberships, and grants. Idempotent by `externalRef`: a re-run adds what is missing and changes nothing else. Each grant has its own `externalRef`, so one principal may hold two grants of the same target. Reusing a grant’s `externalRef` with changed grant fields fails that principal with `idempotency_mismatch`. Each principal commits with its role events or rolls back on failure. A request body is at most 1 MiB, so a batch whose principals carry large `metadata` may need splitting into smaller calls even under 500; a larger body answers `payload_too_large`.

-   **Who may call:** Your server.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.principals.import(input)`
-   **Idempotency-Key:** optional. [Retrying a write](/docs/platform/api-basics.md#retrying-a-write) has the rule.

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `principals` | `object[]` | Yes | 1–500 items. |
| `principals[].kind` | `string` | No | A label the principal chooses for itself. Omit it to leave the kind unset. Roles, grants, and invitations treat every kind alike. One of `"human"`, `"agent"`, or `"service"`. |
| `principals[].externalRef` | `string` | Yes | 1–200 characters. |
| `principals[].displayName` | `string` | No | 1–120 characters. |
| `principals[].avatarUrl` | `string` | No | A URL. |
| `principals[].metadata` | `object` | No |  |
| `principals[].identities` | `object[]` | Yes | At least 1. |
| `principals[].identities[].type` | `"email"` or `"oauth"` | Yes |  |
| `principals[].identities[].email` | `string` | No | With `type: "email"`; up to 254 characters. |
| `principals[].identities[].provider` | `"twitch"` | No | With `type: "oauth"`. |
| `principals[].identities[].subject` | `string` | No | With `type: "oauth"`. |
| `principals[].identities[].profile` | `object` | No | With `type: "oauth"`. |
| `principals[].identities[].profile.login` | `string` | No |  |
| `principals[].identities[].profile.displayName` | `string` | No |  |
| `principals[].identities[].profile.email` | `string` | No |  |
| `principals[].identities[].profile.avatarUrl` | `string` | No |  |
| `principals[].projectRoles` | `string[]` | No | Configured project roles to add. Existing roles stay; repeated roles add nothing. |
| `principals[].memberships` | `object[]` | No |  |
| `principals[].memberships[].workspaceId` | `string` | Yes | A workspace ID, `wsp_…`. |
| `principals[].memberships[].role` | `string` | Yes | A role key from the config, such as “member”. |
| `principals[].grants` | `object[]` | No |  |
| `principals[].grants[].externalRef` | `string` | Yes | Your system’s reference for this grant, such as its row ID. One principal’s grants with the same `externalRef` are one grant, so a re-import adds no second one; 1–200 characters. |
| `principals[].grants[].target` | `object` | Yes |  |
| `principals[].grants[].target.kind` | `string` | Yes | One of `"entitlement"` or `"bundle"`. |
| `principals[].grants[].target.entitlement` | `string` | No | With `kind: "entitlement"`. |
| `principals[].grants[].target.resource` | `object` | No | With `kind: "entitlement"`. |
| `principals[].grants[].target.resource.type` | `string` | Yes |  |
| `principals[].grants[].target.resource.id` | `string` | Yes |  |
| `principals[].grants[].target.bundle` | `string` | No | With `kind: "bundle"`. |
| `principals[].grants[].provenance` | `object` | Yes |  |
| `principals[].grants[].provenance.source` | `string` | Yes | Your app’s label for why the grant exists; 1–100 characters. |
| `principals[].grants[].provenance.reference` | `string` | No | Up to 200 characters. |
| `principals[].grants[].provenance.note` | `string` | No | Up to 1000 characters. |
| `principals[].grants[].metadata` | `object` | No |  |
| `principals[].grants[].startsAt` | `string` | No | An ISO 8601 date and time. |
| `principals[].grants[].expiresAt` | `string` | No | An ISO 8601 date and time. |

### Response

`200 OK`, with [`ImportResponse`](/docs/identityhound/reference/principals.md#the-importresponse-object).

### Errors

-   [`entitlement_unknown`](/docs/identityhound/errors.md#entitlement_unknown) (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/import \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "principals": [
      {
        "externalRef": "user_1001",
        "displayName": "Katherine Johnson",
        "identities": [
          {
            "type": "email",
            "email": "katherine@example.com"
          }
        ],
        "memberships": [
          {
            "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
            "role": "member"
          }
        ],
        "grants": [
          {
            "externalRef": "subscription_88",
            "target": {
              "kind": "entitlement",
              "entitlement": "reports.schedule"
            },
            "provenance": {
              "source": "purchase",
              "reference": "subscription_88"
            }
          }
        ]
      }
    ]
  }'
```

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

const client = createClient({ token: 'sk_test_…' });
const { results, principalIds } = await client.principals.import({
  principals: [
    {
      externalRef: 'user_1001',
      displayName: 'Katherine Johnson',
      identities: [{ type: 'email', email: 'katherine@example.com' }],
      memberships: [
        { workspaceId: 'wsp_01JDGKQN2K4RF0M0Z2HBASFA62', role: 'member' },
      ],
      grants: [
        {
          externalRef: 'subscription_88',
          target: { kind: 'entitlement', entitlement: 'reports.schedule' },
          provenance: { source: 'purchase', reference: 'subscription_88' },
        },
      ],
    },
  ],
});
```

```json title="Response"
{
  "results": [
    {
      "externalRef": "user_1001",
      "principalId": "prn_01JDSJ41R3JK54F6RKD4Y3J1GF",
      "outcome": "created"
    }
  ],
  "principalIds": {
    "user_1001": "prn_01JDSJ41R3JK54F6RKD4Y3J1GF"
  }
}
```

## Create a principal

`POST /principals`

Creates a principal and answers with its first API key. The token is shown once.

-   **Who may call:** Your server or a signed-in principal.
-   **Access:** A signed-in principal or your server may create one.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.principals.create(input)`
-   **Idempotency-Key:** optional. [Retrying a write](/docs/platform/api-basics.md#retrying-a-write) has the rule.

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `kind` | `string` | No | A label the principal chooses for itself. Omit it to leave the kind unset. Roles, grants, and invitations treat every kind alike. One of `"human"`, `"agent"`, or `"service"`. |
| `displayName` | `string` | No | 1–120 characters. |
| `avatarUrl` | `string` | No | A URL. |
| `description` | `string` | No | Up to 1000 characters. |
| `externalRef` | `string` | No | 1–200 characters. |
| `metadata` | `object` | No |  |

### Response

`201 Created`, with [`PrincipalCreated`](/docs/identityhound/reference/principals.md#the-principalcreated-object).

### Errors

-   [`conflict`](/docs/identityhound/errors.md#conflict) (409)
-   [`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 -X POST https://api.agentpost.tools/v1/identity/principals \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "agent",
    "displayName": "Report assistant",
    "description": "Drafts the weekly report"
  }'
```

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

const client = createClient({ token: 'sk_test_…' });
const { principal, token, apiKey } = await client.principals.create({
  kind: 'agent',
  displayName: 'Report assistant',
  description: 'Drafts the weekly report',
});
```

```json title="Response"
{
  "principal": {
    "id": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
    "kind": "agent",
    "status": "active",
    "displayName": "Report assistant",
    "projectRoles": [],
    "description": "Drafts the weekly report",
    "metadata": {},
    "createdAt": "2026-11-06T16:40:00.000Z",
    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "updatedAt": "2026-11-06T16:40:00.000Z"
  },
  "token": "agp_ak_…",
  "apiKey": {
    "id": "key_01JD3F215PNGEK0WH9BSJZRD81",
    "principalId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
    "name": "Initial key",
    "prefix": "agp_ak_acme_3f9a1c2b7d4e",
    "status": "active",
    "createdAt": "2026-11-06T16:40:00.000Z",
    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
  }
}
```

## Get a principal

`GET /principals/:id`

One principal.

-   **Who may call:** Your server or a signed-in principal.
-   **Access:** A principal may read only itself.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.principals.get(id)`

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

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

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/principals/prn_01JDWRHCP925GR1HC5AP0MCFKH \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
const { principal } = await client.principals.get(
  'prn_01JDWRHCP925GR1HC5AP0MCFKH',
);
```

```json title="Response"
{
  "principal": {
    "id": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
    "kind": "agent",
    "status": "active",
    "displayName": "Report assistant",
    "projectRoles": [],
    "description": "Drafts the weekly report",
    "metadata": {},
    "createdAt": "2026-11-06T16:40:00.000Z",
    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "updatedAt": "2026-11-06T16:40:00.000Z"
  }
}
```

## List a principal’s identities

`GET /principals/:id/identities`

A principal’s sign-in identities.

-   **Who may call:** Your server.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.principals.identities(id)`

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

### Response

`200 OK`, with:

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `identities` | [`Identity`](/docs/identityhound/reference/me.md#the-identity-object) array | Always |  |

### 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 https://api.agentpost.tools/v1/identity/principals/prn_01JDG9X6KH1ZEF2ZWP185VMW9D/identities \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
const { identities } = await client.principals.identities(
  'prn_01JDG9X6KH1ZEF2ZWP185VMW9D',
);
```

```json title="Response"
{
  "identities": [
    {
      "id": "idn_01JD574H5SQYRFZHDKFXZNEYTQ",
      "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
      "type": "email",
      "provider": "email",
      "subject": "ada@example.com",
      "verifiedAt": "2026-11-02T14:05:00.000Z",
      "createdAt": "2026-11-02T14:05:00.000Z",
      "lastUsedAt": "2026-11-13T09:30:00.000Z"
    },
    {
      "id": "idn_01JDG344JJGW867DQ6EJ5WGCY2",
      "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
      "type": "oauth",
      "provider": "twitch",
      "subject": "91234567",
      "verifiedAt": "2026-11-03T08:20:00.000Z",
      "profile": {
        "login": "ada_codes",
        "displayName": "ada_codes"
      },
      "createdAt": "2026-11-03T08:20:00.000Z"
    }
  ]
}
```

## List a principal’s sessions

`GET /principals/:id/sessions`

A principal’s live sessions, direct and delegated, newest first. A server that keeps data per session checks its copies against this.

-   **Who may call:** Your server.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.principals.sessions(id)`

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

### Response

`200 OK`, with:

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `sessions` | [`Session`](/docs/identityhound/reference/principals.md#the-session-object) array | Always |  |

### 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 https://api.agentpost.tools/v1/identity/principals/prn_01JDG9X6KH1ZEF2ZWP185VMW9D/sessions \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
const { sessions } = await client.principals.sessions(
  'prn_01JDG9X6KH1ZEF2ZWP185VMW9D',
);
```

```json title="Response"
{
  "sessions": [
    {
      "id": "ses_01JD2EQP0GCGZMSCG7GMDVCFJ6",
      "kind": "direct",
      "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
      "authMethods": ["email_code"],
      "client": {
        "ip": "203.0.113.24",
        "userAgent": "Mozilla/5.0",
        "platform": "web"
      },
      "createdAt": "2026-11-13T09:30:00.000Z",
      "lastSeenAt": "2026-11-13T09:30:00.000Z",
      "idleExpiresAt": "2026-11-20T09:30:00.000Z",
      "expiresAt": "2026-12-13T09:30:00.000Z"
    },
    {
      "id": "ses_01JD8JJY6V2MPY54HKBGHM1676",
      "kind": "direct",
      "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
      "authMethods": ["oauth:twitch"],
      "client": {
        "ip": "198.51.100.7",
        "userAgent": "Mozilla/5.0",
        "platform": "ios"
      },
      "createdAt": "2026-11-10T19:02:00.000Z",
      "lastSeenAt": "2026-11-12T21:15:00.000Z",
      "idleExpiresAt": "2026-11-19T21:15:00.000Z",
      "expiresAt": "2026-12-10T19:02:00.000Z"
    }
  ]
}
```

## Get a session

`GET /sessions/:id`

One session, live or ended. An ended session has `revokedAt` and `revokeReason`, or an `expiresAt` or `idleExpiresAt` that has passed. It is kept until 30 days after its `expiresAt`, then answers `not_found`.

-   **Who may call:** Your server.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.sessions.get(id)`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | A session ID, `ses_…`. The `id` of a [`Session`](/docs/identityhound/reference/principals.md#the-session-object). |

### Response

`200 OK`, with:

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

### 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 https://api.agentpost.tools/v1/identity/sessions/ses_01JD8JJY6V2MPY54HKBGHM1676 \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
const { session } = await client.sessions.get('ses_01JD8JJY6V2MPY54HKBGHM1676');
```

```json title="Response"
{
  "session": {
    "id": "ses_01JD8JJY6V2MPY54HKBGHM1676",
    "kind": "direct",
    "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "authMethods": ["oauth:twitch"],
    "client": {
      "ip": "198.51.100.7",
      "userAgent": "Mozilla/5.0",
      "platform": "ios"
    },
    "createdAt": "2026-11-10T19:02:00.000Z",
    "lastSeenAt": "2026-11-12T21:15:00.000Z",
    "idleExpiresAt": "2026-11-19T21:15:00.000Z",
    "expiresAt": "2026-12-10T19:02:00.000Z",
    "revokedAt": "2026-11-13T08:00:00.000Z",
    "revokeReason": "self"
  }
}
```

## Update a principal

`PATCH /principals/:id`

Changes a principal’s kind, name, avatar, description, or metadata. Send null to clear the kind. A kind is a label, and roles, grants, and invitations treat every kind alike.

-   **Who may call:** Your server or a signed-in principal.
-   **Access:** Only the principal or your server.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.principals.patch(id, patch)`
-   **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 |
| --- | --- | --- | --- |
| `kind` | `string` or `null` | No | One of `"human"`, `"agent"`, or `"service"`. |
| `displayName` | `string` or `null` | No | A supplied name, 1 to 120 characters. Send null to clear it. |
| `avatarUrl` | `string` or `null` | No |  |
| `description` | `string` or `null` | No |  |
| `metadata` | `object` | No |  |

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

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

```bash tab="curl"
curl -X PATCH https://api.agentpost.tools/v1/identity/principals/prn_01JDWRHCP925GR1HC5AP0MCFKH \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Drafts and sends the weekly report"
  }'
```

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

const client = createClient({ token: 'sk_test_…' });
const { principal } = await client.principals.patch(
  'prn_01JDWRHCP925GR1HC5AP0MCFKH',
  { description: 'Drafts and sends the weekly report' },
);
```

```json title="Response"
{
  "principal": {
    "id": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
    "kind": "agent",
    "status": "active",
    "displayName": "Report assistant",
    "projectRoles": [],
    "description": "Drafts and sends the weekly report",
    "metadata": {},
    "createdAt": "2026-11-06T16:40:00.000Z",
    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "updatedAt": "2026-11-13T09:30:00.000Z"
  }
}
```

## Suspend a principal

`POST /principals/:id/suspend`

Suspends a principal. Its sessions and delegated tokens end at once, its API keys stop working while it is suspended, and every delegation it is a party to is revoked.

-   **Who may call:** Your server or a signed-in principal.
-   **Access:** Only the principal or your server.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.principals.suspend(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 principal ID, `prn_…`. The `id` of a [`Principal`](/docs/identityhound/reference/principals.md#the-principal-object). |

### Response

`200 OK`, with:

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

### Errors

-   [`conflict`](/docs/identityhound/errors.md#conflict) (409)
-   [`forbidden`](/docs/identityhound/errors.md#forbidden) (403)
-   [`last_owner`](/docs/identityhound/errors.md#last_owner) (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/principals/prn_01JDWRHCP925GR1HC5AP0MCFKH/suspend \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
const { principal } = await client.principals.suspend(
  'prn_01JDWRHCP925GR1HC5AP0MCFKH',
);
```

```json title="Response"
{
  "principal": {
    "id": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
    "kind": "agent",
    "status": "suspended",
    "displayName": "Report assistant",
    "projectRoles": [],
    "description": "Drafts the weekly report",
    "metadata": {},
    "createdAt": "2026-11-06T16:40:00.000Z",
    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "updatedAt": "2026-11-13T09:30:00.000Z",
    "suspendedAt": "2026-11-13T09:30:00.000Z"
  }
}
```

## Reactivate a principal

`POST /principals/:id/reactivate`

Lifts a suspension. Its live API keys work again. Its ended sessions and delegations stay revoked.

-   **Who may call:** Your server or a signed-in principal.
-   **Access:** Only the principal or your server.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.principals.reactivate(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 principal ID, `prn_…`. The `id` of a [`Principal`](/docs/identityhound/reference/principals.md#the-principal-object). |

### Response

`200 OK`, with:

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `principal` | [`Principal`](/docs/identityhound/reference/principals.md#the-principal-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)

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_01JDWRHCP925GR1HC5AP0MCFKH/reactivate \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
const { principal } = await client.principals.reactivate(
  'prn_01JDWRHCP925GR1HC5AP0MCFKH',
);
```

```json title="Response"
{
  "principal": {
    "id": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
    "kind": "agent",
    "status": "active",
    "displayName": "Report assistant",
    "projectRoles": [],
    "description": "Drafts the weekly report",
    "metadata": {},
    "createdAt": "2026-11-06T16:40:00.000Z",
    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "updatedAt": "2026-11-13T09:30:00.000Z"
  }
}
```

## Delete a principal

`DELETE /principals/:id`

Deletes a principal with its identities, sessions, keys, and connections, and revokes the connections’ tokens at the provider.

-   **Who may call:** Your server or a signed-in principal.
-   **Access:** Only the principal or your server.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.principals.delete(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 principal ID, `prn_…`. The `id` of a [`Principal`](/docs/identityhound/reference/principals.md#the-principal-object). |

### Response

`204 No Content`, with no body.

### Errors

-   [`conflict`](/docs/identityhound/errors.md#conflict) (409)
-   [`forbidden`](/docs/identityhound/errors.md#forbidden) (403)
-   [`last_owner`](/docs/identityhound/errors.md#last_owner) (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 DELETE https://api.agentpost.tools/v1/identity/principals/prn_01JDWRHCP925GR1HC5AP0MCFKH \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
await client.principals.delete('prn_01JDWRHCP925GR1HC5AP0MCFKH');
```

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

## The Principal object

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `id` | `string` | Always | A principal ID, `prn_…`. |
| `kind` | `string` | When set | A principal’s kind: `guest`, which IdentityHound sets while someone uses a product before signing in, or a label the principal chose for itself (`human`, `agent`, or `service`), or none. A principal can change its label at any time, and every setting treats the declared kinds alike. One of `"human"`, `"guest"`, `"agent"`, or `"service"`. |
| `status` | `string` | Always | One of `"active"`, `"suspended"`, or `"deleted"`. |
| `displayName` | `string` | When set | A supplied name, 1 to 120 characters. Your app decides what to show when absent. |
| `avatarUrl` | `string` | When set |  |
| `projectRoles` | `string[]` | Always |  |
| `description` | `string` | When set |  |
| `guest` | `object` | When set |  |
| `guest.createdIp` | `string` | When set |  |
| `guest.upgradedAt` | `string` | When set | An ISO 8601 date and time. |
| `mergedInto` | `string` | When set | A principal ID, `prn_…`. |
| `lastActiveAt` | `string` | When set | An ISO 8601 date and time. |
| `externalRef` | `string` | When set |  |
| `metadata` | `object` | Always |  |
| `createdAt` | `string` | Always | An ISO 8601 date and time. |
| `createdBy` | `string` | When set | A principal ID, `prn_…`. |
| `updatedAt` | `string` | Always | An ISO 8601 date and time. |
| `suspendedAt` | `string` | When set | An ISO 8601 date and time. |
| `deletedAt` | `string` | When set | An ISO 8601 date and time. |

```json title="The Principal object"
{
  "id": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
  "kind": "human",
  "status": "active",
  "displayName": "Ada Lovelace",
  "projectRoles": [],
  "lastActiveAt": "2026-11-13T09:30:00.000Z",
  "metadata": {},
  "createdAt": "2026-11-02T14:05:00.000Z",
  "updatedAt": "2026-11-13T09:30:00.000Z"
}
```

## The Session object

A session as the API shows it: never with its token or hash.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `id` | `string` | Always | A session ID, `ses_…`. |
| `kind` | `"direct"` or `"delegated"` | Always |  |
| `principalId` | `string` | Always | Whose session it is: for a delegated session, the delegator. |
| `delegateId` | `string` | When set | The delegate holding a delegated session. |
| `delegationId` | `string` | When set | A delegation ID, `dlg_…`. |
| `authMethods` | `string[]` | Always | Each is `oauth:…`, or one of `"email_code"`, `"api_key"`, or `"guest"`. |
| `client` | `object` | When set |  |
| `client.ip` | `string` | When set |  |
| `client.userAgent` | `string` | When set |  |
| `client.platform` | `string` | When set |  |
| `createdAt` | `string` | Always | An ISO 8601 date and time. |
| `lastSeenAt` | `string` | Always | An ISO 8601 date and time. |
| `idleExpiresAt` | `string` | Always | An ISO 8601 date and time. |
| `expiresAt` | `string` | Always | An ISO 8601 date and time. |
| `revokedAt` | `string` | When set | An ISO 8601 date and time. |
| `revokeReason` | `string` | When set | One of `"sign_out"`, `"self"`, `"api_key_revoked"`, `"principal_suspended"`, `"identity_removed"`, `"principal_deleted"`, `"delegation_revoked"`, `"upgraded"`, or `"merged"`. |
| `current` | `boolean` | When set | True for the session the request was made with. |

```json title="The Session object"
{
  "id": "ses_01JD2EQP0GCGZMSCG7GMDVCFJ6",
  "kind": "direct",
  "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
  "authMethods": ["email_code"],
  "client": {
    "ip": "203.0.113.24",
    "userAgent": "Mozilla/5.0",
    "platform": "web"
  },
  "createdAt": "2026-11-13T09:30:00.000Z",
  "lastSeenAt": "2026-11-13T09:30:00.000Z",
  "idleExpiresAt": "2026-11-20T09:30:00.000Z",
  "expiresAt": "2026-12-13T09:30:00.000Z",
  "current": true
}
```

## The ImportResponse object

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `results` | `object[]` | Always |  |
| `results[].externalRef` | `string` | Always |  |
| `results[].principalId` | `string` | When set | A principal ID, `prn_…`. |
| `results[].outcome` | `string` | Always | One of `"created"`, `"existing"`, or `"failed"`. |
| `results[].error` | `object` | When set |  |
| `results[].error.code` | `string` | Always |  |
| `results[].error.message` | `string` | Always |  |
| `principalIds` | `object` | Always | `externalRef` to `principalId` for every item that did not fail. Each value is a `string`. |

```json title="The ImportResponse object"
{
  "results": [
    {
      "externalRef": "user_1001",
      "principalId": "prn_01JDSJ41R3JK54F6RKD4Y3J1GF",
      "outcome": "created"
    }
  ],
  "principalIds": {
    "user_1001": "prn_01JDSJ41R3JK54F6RKD4Y3J1GF"
  }
}
```

## The PrincipalCreated object

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `apiKey` | [`ApiKey`](/docs/identityhound/reference/api-keys.md#the-apikey-object) | Always |  |
| `token` | `string` | Always | The bearer token. Shown once. |
| `principal` | [`Principal`](/docs/identityhound/reference/principals.md#the-principal-object) | Always |  |

```json title="The PrincipalCreated object"
{
  "principal": {
    "id": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
    "kind": "agent",
    "status": "active",
    "displayName": "Report assistant",
    "projectRoles": [],
    "description": "Drafts the weekly report",
    "metadata": {},
    "createdAt": "2026-11-06T16:40:00.000Z",
    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "updatedAt": "2026-11-06T16:40:00.000Z"
  },
  "token": "agp_ak_…",
  "apiKey": {
    "id": "key_01JD3F215PNGEK0WH9BSJZRD81",
    "principalId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
    "name": "Initial key",
    "prefix": "agp_ak_acme_3f9a1c2b7d4e",
    "status": "active",
    "createdAt": "2026-11-06T16:40:00.000Z",
    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
  }
}
```
