---
title: "IdentityHound API: Workspaces"
description: "Create a workspace, list workspaces, get a workspace, update a workspace, archive a workspace, or leave a workspace, with the IdentityHound API."
url: "https://agentpost.tools/docs/identityhound/reference/workspaces"
kind: reference
---

# Workspaces

Flat groups of principals, such as a team or a customer. The principal who creates one is its owner, and a workspace always keeps an owner.

[Workspaces](/docs/identityhound/concepts/workspaces.md) explains members, owners, and invitations.

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 workspace

`POST /workspaces`

Creates a workspace.

-   **Who may call:** Your server or a signed-in principal.
-   **Access:** A principal becomes the owner of what it creates. A trusted caller names the owner with `ownerId`. Every caller is held to the `workspaces.maxOwnedPerPrincipal` limit when it is set.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.workspaces.create(input)`
-   **Idempotency-Key:** optional. [Retrying a write](/docs/platform/api-basics.md#retrying-a-write) has the rule.

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | `string` | Yes | 1–120 characters. |
| `metadata` | `object` | No |  |
| `ownerId` | `string` | No | A principal ID, `prn_…`. |

### Response

`201 Created`, with [`WorkspaceWithMembership`](/docs/identityhound/reference/workspaces.md#the-workspacewithmembership-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)
-   [`role_not_assignable`](/docs/identityhound/errors.md#role_not_assignable) (422)
-   [`workspace_limit`](/docs/identityhound/errors.md#workspace_limit) (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/workspaces \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme",
    "ownerId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
  }'
```

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

const client = createClient({ token: 'sk_test_…' });
const { workspace, membership } = await client.workspaces.create({
  name: 'Acme',
  ownerId: 'prn_01JDG9X6KH1ZEF2ZWP185VMW9D',
});
```

```json title="Response"
{
  "workspace": {
    "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
    "name": "Acme",
    "status": "active",
    "metadata": {},
    "createdAt": "2026-11-02T14:05:00.000Z",
    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "updatedAt": "2026-11-02T14:05:00.000Z"
  },
  "membership": {
    "id": "mem_01JDXB0ZDTSYYZJNQZJQ1MEA8Y",
    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
    "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "principalKind": "human",
    "role": "owner",
    "status": "active",
    "source": "creator",
    "createdAt": "2026-11-02T14:05:00.000Z",
    "updatedAt": "2026-11-02T14:05:00.000Z"
  }
}
```

## List workspaces

`GET /workspaces`

The caller’s workspaces, with their membership. A trusted caller lists every workspace.

-   **Who may call:** A signed-in principal or your server.
-   **Credential:** the examples send a signed-in principal’s session token, `agp_st_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.workspaces.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. |

### Response

`200 OK`, with:

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `workspaces` | [`WorkspaceWithMembership`](/docs/identityhound/reference/workspaces.md#the-workspacewithmembership-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/workspaces?limit=20' \
  -H "Authorization: Bearer agp_st_…"
```

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

const client = createClient({ token: 'agp_st_…' });
const { workspaces } = await client.workspaces.list({ limit: 20 });
```

```json title="Response"
{
  "workspaces": [
    {
      "workspace": {
        "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
        "name": "Acme",
        "status": "active",
        "metadata": {},
        "createdAt": "2026-11-02T14:05:00.000Z",
        "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
        "updatedAt": "2026-11-02T14:05:00.000Z"
      },
      "membership": {
        "id": "mem_01JDXB0ZDTSYYZJNQZJQ1MEA8Y",
        "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
        "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
        "principalKind": "human",
        "role": "owner",
        "status": "active",
        "source": "creator",
        "createdAt": "2026-11-02T14:05:00.000Z",
        "updatedAt": "2026-11-02T14:05:00.000Z"
      }
    }
  ]
}
```

## Get a workspace

`GET /workspaces/:id`

One workspace, with the caller’s membership.

-   **Who may call:** A signed-in principal or your server.
-   **Access:** Needs `identity.workspace:view` in the workspace.
-   **Credential:** the examples send a signed-in principal’s session token, `agp_st_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.workspaces.get(id)`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | A workspace ID, `wsp_…`. The `id` of a [`Workspace`](/docs/identityhound/reference/workspaces.md#the-workspace-object). |

### Response

`200 OK`, with [`WorkspaceWithMembership`](/docs/identityhound/reference/workspaces.md#the-workspacewithmembership-object).

### 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/workspaces/wsp_01JDGKQN2K4RF0M0Z2HBASFA62 \
  -H "Authorization: Bearer agp_st_…"
```

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

const client = createClient({ token: 'agp_st_…' });
const { workspace, membership } = await client.workspaces.get(
  'wsp_01JDGKQN2K4RF0M0Z2HBASFA62',
);
```

```json title="Response"
{
  "workspace": {
    "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
    "name": "Acme",
    "status": "active",
    "metadata": {},
    "createdAt": "2026-11-02T14:05:00.000Z",
    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "updatedAt": "2026-11-02T14:05:00.000Z"
  },
  "membership": {
    "id": "mem_01JDXB0ZDTSYYZJNQZJQ1MEA8Y",
    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
    "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "principalKind": "human",
    "role": "owner",
    "status": "active",
    "source": "creator",
    "createdAt": "2026-11-02T14:05:00.000Z",
    "updatedAt": "2026-11-02T14:05:00.000Z"
  }
}
```

## Update a workspace

`PATCH /workspaces/:id`

Renames a workspace or changes its metadata.

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

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | `string` | No | 1–120 characters. |
| `metadata` | `object` | No |  |

### Response

`200 OK`, with:

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `workspace` | [`Workspace`](/docs/identityhound/reference/workspaces.md#the-workspace-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 PATCH https://api.agentpost.tools/v1/identity/workspaces/wsp_01JDGKQN2K4RF0M0Z2HBASFA62 \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme Inc."
  }'
```

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

const client = createClient({ token: 'sk_test_…' });
const { workspace } = await client.workspaces.patch(
  'wsp_01JDGKQN2K4RF0M0Z2HBASFA62',
  { name: 'Acme Inc.' },
);
```

```json title="Response"
{
  "workspace": {
    "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
    "name": "Acme Inc.",
    "status": "active",
    "metadata": {},
    "createdAt": "2026-11-02T14:05:00.000Z",
    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "updatedAt": "2026-11-13T09:30:00.000Z"
  }
}
```

## Archive a workspace

`POST /workspaces/:id/archive`

Archives a workspace. Its memberships, its grants, and the delegations and resource roles in it stop granting anything; a project role still applies. It can’t be renamed and takes no new members, invitations, grants, or delegations. Your server, or a project role that allows it, can still change or remove its members, and any member may leave it. It can’t be undone, so ask the principal to confirm it on your own screen first.

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

### Response

`200 OK`, with:

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `workspace` | [`Workspace`](/docs/identityhound/reference/workspaces.md#the-workspace-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/workspaces/wsp_01JDGKQN2K4RF0M0Z2HBASFA62/archive \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
const { workspace } = await client.workspaces.archive(
  'wsp_01JDGKQN2K4RF0M0Z2HBASFA62',
);
```

```json title="Response"
{
  "workspace": {
    "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
    "name": "Acme",
    "status": "archived",
    "metadata": {},
    "createdAt": "2026-11-02T14:05:00.000Z",
    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "updatedAt": "2026-11-13T09:30:00.000Z",
    "archivedAt": "2026-11-13T09:30:00.000Z"
  }
}
```

## Leave a workspace

`POST /workspaces/:id/leave`

The caller leaves a workspace. The last owner can’t.

-   **Who may call:** A signed-in principal.
-   **Credential:** the examples send a signed-in principal’s session token, `agp_st_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.workspaces.leave(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 workspace ID, `wsp_…`. The `id` of a [`Workspace`](/docs/identityhound/reference/workspaces.md#the-workspace-object). |

### Response

`204 No Content`, with no body.

### Errors

-   [`forbidden`](/docs/identityhound/errors.md#forbidden) (403)
-   [`last_owner`](/docs/identityhound/errors.md#last_owner) (409)
-   [`not_a_member`](/docs/identityhound/errors.md#not_a_member) (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/workspaces/wsp_01JDGKQN2K4RF0M0Z2HBASFA62/leave \
  -H "Authorization: Bearer agp_st_…"
```

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

const client = createClient({ token: 'agp_st_…' });
await client.workspaces.leave('wsp_01JDGKQN2K4RF0M0Z2HBASFA62');
```

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

## The WorkspaceWithMembership object

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `workspace` | [`Workspace`](/docs/identityhound/reference/workspaces.md#the-workspace-object) | Always |  |
| `membership` | [`Membership`](/docs/identityhound/reference/members.md#the-membership-object) | When set |  |

```json title="The WorkspaceWithMembership object"
{
  "workspace": {
    "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
    "name": "Acme",
    "status": "active",
    "metadata": {},
    "createdAt": "2026-11-02T14:05:00.000Z",
    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "updatedAt": "2026-11-02T14:05:00.000Z"
  },
  "membership": {
    "id": "mem_01JDXB0ZDTSYYZJNQZJQ1MEA8Y",
    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
    "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
    "principalKind": "human",
    "role": "owner",
    "status": "active",
    "source": "creator",
    "createdAt": "2026-11-02T14:05:00.000Z",
    "updatedAt": "2026-11-02T14:05:00.000Z"
  }
}
```

## The Workspace object

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `id` | `string` | Always | A workspace ID, `wsp_…`. |
| `name` | `string` | Always |  |
| `status` | `"active"` or `"archived"` | Always |  |
| `metadata` | `object` | Always |  |
| `createdAt` | `string` | Always | An ISO 8601 date and time. |
| `createdBy` | `string` | Always | A principal ID, `prn_…`, or `"trusted_caller"`. |
| `updatedAt` | `string` | Always | An ISO 8601 date and time. |
| `archivedAt` | `string` | When set | An ISO 8601 date and time. |

```json title="The Workspace object"
{
  "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
  "name": "Acme",
  "status": "active",
  "metadata": {},
  "createdAt": "2026-11-02T14:05:00.000Z",
  "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
  "updatedAt": "2026-11-02T14:05:00.000Z"
}
```
