{
  "openapi": "3.1.1",
  "info": {
    "title": "IdentityHound API",
    "version": "v1",
    "description": "Every operation of the IdentityHound API, generated with its [API reference](https://agentpost.tools/docs/identityhound/reference) from the code that serves it, so the two agree.\n\n- **Base URL:** every path starts with `https://api.agentpost.tools/v1/identity`.\n- **Credentials:** send one as `Authorization: Bearer <token>`. Each operation lists the ones it takes, and [Platform credentials](https://agentpost.tools/docs/platform/concepts/credentials) explains each.\n- **Idempotency:** Every write (`POST`, `PUT`, `PATCH`, `DELETE`) takes `Idempotency-Key`, except [Validate a config](https://agentpost.tools/docs/identityhound/reference/config#validate-a-config), [Introspect a token](https://agentpost.tools/docs/identityhound/reference/auth#introspect-a-token), [Preview an invitation](https://agentpost.tools/docs/identityhound/reference/invitations#preview-an-invitation), [Check an entitlement](https://agentpost.tools/docs/identityhound/reference/entitlements#check-an-entitlement), [Check access](https://agentpost.tools/docs/identityhound/reference/access#check-access), and [Check access in a batch](https://agentpost.tools/docs/identityhound/reference/access#check-access-in-a-batch), whose entries say why. A key's first answer is kept for 24 hours. One operation adds its own rule, which its entry states: [Create a grant](https://agentpost.tools/docs/identityhound/reference/grants#create-a-grant). It is required on [Create a grant](https://agentpost.tools/docs/identityhound/reference/grants#create-a-grant). [Retrying a write](https://agentpost.tools/docs/platform/api-basics#retrying-a-write) has the rule, with the codes [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch) and [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict) it answers with.\n- **Lists:** Every list takes `limit`, 1 to 500, default 100. [List workspaces](https://agentpost.tools/docs/identityhound/reference/workspaces#list-workspaces), [List members](https://agentpost.tools/docs/identityhound/reference/members#list-members), [List invitations](https://agentpost.tools/docs/identityhound/reference/invitations#list-invitations), [List resource roles](https://agentpost.tools/docs/identityhound/reference/resource-roles#list-resource-roles), and [List grants](https://agentpost.tools/docs/identityhound/reference/grants#list-grants) page with `next` and `after`. [Read the change feed](https://agentpost.tools/docs/identityhound/reference/events#read-the-change-feed) is a feed. [List principals](https://agentpost.tools/docs/identityhound/reference/principals#list-principals) and [List delegations](https://agentpost.tools/docs/identityhound/reference/delegations#list-delegations) answer with no cursor. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.\n- **IDs:** Each ID starts with its kind's prefix, such as `prn_…`. [IdentityHound's ID prefixes](https://agentpost.tools/docs/identityhound/reference#ids) lists them.\n- **Errors:** An error's `docs` link goes to its code's entry on [IdentityHound errors](https://agentpost.tools/docs/identityhound/errors). Any operation can answer with [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request), [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large), [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated), or [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error); each operation lists the other codes it can answer with. [Errors](https://agentpost.tools/docs/platform/api-basics#errors) describes the body.\n- **Rules every API shares:** [API basics](https://agentpost.tools/docs/platform/api-basics).",
    "termsOfService": "https://agentpost.tools/terms"
  },
  "servers": [
    {
      "url": "https://api.agentpost.tools/v1/identity"
    }
  ],
  "externalDocs": {
    "description": "The IdentityHound API reference",
    "url": "https://agentpost.tools/docs/identityhound/reference"
  },
  "tags": [
    {
      "name": "Config",
      "description": "The project's one versioned config: resource types and their actions, roles, entitlements, sign-in and sign-up, providers, and URLs.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/config"
      }
    },
    {
      "name": "Sign-in",
      "description": "Emailed codes, OAuth providers, guests, sign-out, and introspection. The session-start operations, and an invitation's preview, are the only ones a publishable key reaches.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/auth"
      }
    },
    {
      "name": "The signed-in principal",
      "description": "The caller's own profile, sign-in identities, and sessions. Of these, a delegated token reaches only `GET /me` and sign-out: a delegate acting for a principal never reaches the principal's account. Elsewhere it acts within its delegation, such as in `POST /access/check` and `GET /access/permissions`.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/me"
      }
    },
    {
      "name": "Principals",
      "description": "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.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/principals"
      }
    },
    {
      "name": "API keys",
      "description": "A signed-in principal's own credential. A key may be restricted to workspaces and permissions, which caps what it can do.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/api-keys"
      }
    },
    {
      "name": "Connected accounts",
      "description": "A principal's accounts at OAuth providers, such as Twitch, held so a trusted caller or a delegate can act for it there. Connect one with `auth.oauthStart` and `purpose: connect`.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/connections"
      }
    },
    {
      "name": "Workspaces",
      "description": "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.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/workspaces"
      }
    },
    {
      "name": "Members",
      "description": "A workspace's memberships and their roles.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/members"
      }
    },
    {
      "name": "Invitations",
      "description": "Invitations into a workspace, by email or by a code you pass on yourself. A principal previews an invitation, then accepts it.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/invitations"
      }
    },
    {
      "name": "Project roles",
      "description": "Roles a principal holds across the project. Only your server assigns or removes them. Read them in the principal's `projectRoles`.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/project-roles"
      }
    },
    {
      "name": "Resource roles",
      "description": "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.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/resource-roles"
      }
    },
    {
      "name": "Bundles",
      "description": "Named sets of entitlements, such as a plan, granted together.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/bundles"
      }
    },
    {
      "name": "Grants",
      "description": "What a principal, a workspace, every principal that is not a guest, or every guest has been given: a bundle, or one entitlement.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/grants"
      }
    },
    {
      "name": "Entitlements",
      "description": "Whether a principal holds an entitlement, through any grant to it, its workspace, or every principal that is not a guest (every guest, for a guest).",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/entitlements"
      }
    },
    {
      "name": "Delegations",
      "description": "Permission for one principal to act for another, within listed permissions, a workspace, and an expiry. The delegate exchanges its API key or session for short-lived delegated tokens, and every check and event keeps both identities.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/delegations"
      }
    },
    {
      "name": "Access checks",
      "description": "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.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/access"
      }
    },
    {
      "name": "Change feed",
      "description": "Read IdentityHound’s retained changes after a cursor, in order, as CloudEvents. Each event keeps who acted and for whom. [Change feed retention](https://agentpost.tools/docs/identityhound/concepts/change-feed#limits) explains how long the feed keeps changes and what happens when they expire.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/identityhound/reference/events"
      }
    }
  ],
  "paths": {
    "/config": {
      "get": {
        "operationId": "config.get",
        "summary": "Get the config",
        "description": "The current config and its version.\n\n- **Who may call:** Your server.",
        "tags": ["Config"],
        "externalDocs": {
          "description": "Get the config, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/config#get-the-config"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "config": {
                      "$ref": "#/components/schemas/IamConfig"
                    }
                  },
                  "required": ["config"]
                },
                "example": {
                  "config": {
                    "version": 3,
                    "signUp": {
                      "mode": "invite_only"
                    },
                    "signIn": {
                      "emailCode": {
                        "enabled": true,
                        "codeTtl": "10m",
                        "resendAfter": "30s"
                      },
                      "providers": {}
                    },
                    "sessions": {
                      "idleTtl": "7d",
                      "maxTtl": "30d"
                    },
                    "guests": {
                      "enabled": false,
                      "idleTtl": "30d",
                      "createPerIpPerHour": 30
                    },
                    "accounts": {
                      "merge": "off",
                      "mergeTicketTtl": "10m"
                    },
                    "workspaces": {},
                    "invitations": {
                      "ttl": "7d"
                    },
                    "delegations": {
                      "maxTtl": "30d",
                      "tokenTtl": "15m"
                    },
                    "urls": {
                      "signInLink": "https://app.example.com/sign-in",
                      "invitationAccept": "https://app.example.com/invitations",
                      "oauthReturn": ["https://app.example.com/auth/callback"]
                    },
                    "resourceTypes": {
                      "report": {
                        "actions": ["view", "edit", "export"]
                      }
                    },
                    "roles": {
                      "admin": {
                        "name": "Admin",
                        "scope": "workspace",
                        "permissions": [
                          "identity.workspace:view",
                          "identity.member:*",
                          "identity.invitation:*",
                          "identity.resource_role:*",
                          "identity.grant:view"
                        ]
                      },
                      "member": {
                        "name": "Member",
                        "scope": "workspace",
                        "permissions": [
                          "identity.workspace:view",
                          "identity.member:view",
                          "identity.invitation:view",
                          "report:view"
                        ]
                      },
                      "editor": {
                        "name": "Editor",
                        "scope": "resource",
                        "assignableTo": ["principal", "guest"],
                        "permissions": ["report:view", "report:edit"]
                      },
                      "support": {
                        "name": "Support",
                        "scope": "project",
                        "permissions": ["report:view"]
                      }
                    },
                    "entitlements": {
                      "reports.export": {
                        "description": "Export reports",
                        "resourceType": "report"
                      },
                      "reports.schedule": {
                        "description": "Schedule reports by email"
                      }
                    },
                    "updatedAt": "2026-11-13T09:30:00.000Z",
                    "updatedBy": "trusted_caller"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "config.put",
        "summary": "Replace the config",
        "description": "Read the config, change your settings, and send the whole config back. Any read-only fields you send must match the current config. Omitting an existing provider app's client secret keeps it. Send the version you read in `If-Match` to get `stale_version` if the config changed before your update.\n\n- **Who may call:** Your server.\n- **Idempotency-Key:** optional. ",
        "tags": ["Config"],
        "externalDocs": {
          "description": "Replace the config, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/config#replace-the-config"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "description": "Optional. The config `version` you read, such as `3` or `\"3\"`: a whole number from 1. Anything else is `invalid_request`.",
            "schema": {
              "type": "string"
            },
            "example": "3"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "signUp": {
                    "type": "object",
                    "properties": {
                      "mode": {
                        "type": "string",
                        "enum": ["open", "invite_only", "closed"]
                      }
                    },
                    "required": ["mode"],
                    "additionalProperties": false
                  },
                  "signIn": {
                    "type": "object",
                    "properties": {
                      "emailCode": {
                        "type": "object",
                        "properties": {
                          "enabled": {
                            "type": "boolean"
                          },
                          "codeTtl": {
                            "type": "string",
                            "description": "A duration, such as \"10m\" or \"7d\""
                          },
                          "resendAfter": {
                            "type": "string",
                            "description": "A duration, such as \"10m\" or \"7d\""
                          }
                        },
                        "required": ["enabled", "codeTtl", "resendAfter"],
                        "additionalProperties": false
                      },
                      "providers": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9_.-]*$"
                        },
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "provider": {
                              "type": "string",
                              "enum": ["twitch"]
                            },
                            "enabled": {
                              "type": "boolean"
                            },
                            "clientId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "clientSecret": {
                              "type": "string",
                              "minLength": 1
                            },
                            "signIn": {
                              "type": "boolean"
                            },
                            "signInScopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "connectScopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "provider",
                            "enabled",
                            "clientId",
                            "signIn",
                            "signInScopes",
                            "connectScopes"
                          ],
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": ["emailCode", "providers"],
                    "additionalProperties": false
                  },
                  "sessions": {
                    "type": "object",
                    "properties": {
                      "idleTtl": {
                        "type": "string",
                        "description": "A duration, such as \"10m\" or \"7d\""
                      },
                      "maxTtl": {
                        "type": "string",
                        "description": "A duration, such as \"10m\" or \"7d\""
                      }
                    },
                    "required": ["idleTtl", "maxTtl"],
                    "additionalProperties": false
                  },
                  "guests": {
                    "type": "object",
                    "properties": {
                      "enabled": {
                        "type": "boolean"
                      },
                      "idleTtl": {
                        "type": "string",
                        "description": "A duration, such as \"10m\" or \"7d\""
                      },
                      "createPerIpPerHour": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      },
                      "maxActive": {
                        "description": "The most guests the project holds at once. Unset, there is no limit.",
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "required": ["enabled", "idleTtl", "createPerIpPerHour"],
                    "additionalProperties": false
                  },
                  "accounts": {
                    "type": "object",
                    "properties": {
                      "merge": {
                        "type": "string",
                        "enum": ["off", "on"],
                        "description": "With `on`, a principal who links a sign-in method another principal holds gets a merge ticket, and `POST /me/merge` merges that account into its own. With `off`, linking it fails with no ticket and the merge is refused."
                      },
                      "mergeTicketTtl": {
                        "type": "string",
                        "description": "How long a merge ticket lasts once issued."
                      }
                    },
                    "required": ["merge", "mergeTicketTtl"],
                    "additionalProperties": false
                  },
                  "workspaces": {
                    "type": "object",
                    "properties": {
                      "maxOwnedPerPrincipal": {
                        "description": "The most active workspaces one principal may own. Unset, there is no limit.",
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "additionalProperties": false
                  },
                  "invitations": {
                    "type": "object",
                    "properties": {
                      "ttl": {
                        "type": "string",
                        "description": "A duration, such as \"10m\" or \"7d\""
                      }
                    },
                    "required": ["ttl"],
                    "additionalProperties": false
                  },
                  "delegations": {
                    "type": "object",
                    "properties": {
                      "maxTtl": {
                        "type": "string",
                        "description": "A duration, such as \"10m\" or \"7d\""
                      },
                      "tokenTtl": {
                        "type": "string",
                        "description": "A duration, such as \"10m\" or \"7d\""
                      }
                    },
                    "required": ["maxTtl", "tokenTtl"],
                    "additionalProperties": false
                  },
                  "urls": {
                    "type": "object",
                    "properties": {
                      "signInLink": {
                        "description": "The page a sign-in code notification links to, with `email` and `code` added. Unset, the notification carries no link.",
                        "type": "string",
                        "format": "uri"
                      },
                      "invitationAccept": {
                        "description": "The page an invitation notification links to, with `token` added. Unset, the notification carries no link.",
                        "type": "string",
                        "format": "uri"
                      },
                      "oauthReturn": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "uri"
                        }
                      }
                    },
                    "required": ["oauthReturn"],
                    "additionalProperties": false
                  },
                  "resourceTypes": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_.-]*$"
                    },
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "actions": {
                          "minItems": 1,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^[a-z][a-z0-9_-]*(\\.[a-z][a-z0-9_-]*)*$"
                          }
                        },
                        "requiresEntitlement": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "pattern": "^[a-z][a-z0-9_-]*(\\.[a-z][a-z0-9_-]*)*$"
                          },
                          "additionalProperties": {
                            "type": "string",
                            "pattern": "^[a-z][a-z0-9_.-]*$"
                          }
                        }
                      },
                      "required": ["actions"],
                      "additionalProperties": false
                    }
                  },
                  "roles": {
                    "description": "Keyed by role. Ordinary roles require `name`, `scope`, and `permissions`. For `owner`, send the permissions it adds to its fixed ones, or omit the entry to add none. Its name, scope, assignee kinds, and built-in marker can be sent back as read.",
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_.-]*$"
                    },
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "minLength": 1
                        },
                        "scope": {
                          "type": "string",
                          "enum": ["project", "workspace", "resource"]
                        },
                        "permissions": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "description": "A permission, such as \"report:edit\" or \"report:*\""
                          }
                        },
                        "assignableTo": {
                          "description": "Who may hold the role: `[\"principal\"]`, `[\"guest\"]`, or both. `principal` covers every principal that is not a guest, whatever kind it declares. Without a list, any principal that is not a guest may hold it.",
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": ["principal", "guest"],
                            "description": "`principal`: every principal that is not a guest. `guest`: every guest."
                          }
                        },
                        "builtIn": {
                          "type": "boolean"
                        }
                      },
                      "required": ["permissions"],
                      "additionalProperties": false
                    }
                  },
                  "entitlements": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_.-]*$"
                    },
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "description": {
                          "type": "string"
                        },
                        "resourceType": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9_.-]*$"
                        }
                      },
                      "required": ["description"],
                      "additionalProperties": false
                    }
                  },
                  "version": {
                    "description": "If sent, the version must match the current config.",
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "updatedAt": {
                    "description": "If sent, the update time must match the current config.",
                    "type": "string",
                    "format": "date-time"
                  },
                  "updatedBy": {
                    "description": "If sent, the updater must match the current config.",
                    "type": "string"
                  }
                },
                "required": [
                  "signUp",
                  "signIn",
                  "sessions",
                  "guests",
                  "accounts",
                  "workspaces",
                  "invitations",
                  "delegations",
                  "urls",
                  "resourceTypes",
                  "roles",
                  "entitlements"
                ],
                "additionalProperties": false
              },
              "example": {
                "signUp": {
                  "mode": "invite_only"
                },
                "signIn": {
                  "emailCode": {
                    "enabled": true,
                    "codeTtl": "10m",
                    "resendAfter": "30s"
                  },
                  "providers": {}
                },
                "sessions": {
                  "idleTtl": "7d",
                  "maxTtl": "30d"
                },
                "guests": {
                  "enabled": false,
                  "idleTtl": "30d",
                  "createPerIpPerHour": 30
                },
                "accounts": {
                  "merge": "off",
                  "mergeTicketTtl": "10m"
                },
                "workspaces": {},
                "invitations": {
                  "ttl": "7d"
                },
                "delegations": {
                  "maxTtl": "30d",
                  "tokenTtl": "15m"
                },
                "urls": {
                  "signInLink": "https://app.example.com/sign-in",
                  "invitationAccept": "https://app.example.com/invitations",
                  "oauthReturn": ["https://app.example.com/auth/callback"]
                },
                "resourceTypes": {
                  "report": {
                    "actions": ["view", "edit", "export"]
                  }
                },
                "roles": {
                  "admin": {
                    "name": "Admin",
                    "scope": "workspace",
                    "permissions": [
                      "identity.workspace:view",
                      "identity.member:*",
                      "identity.invitation:*",
                      "identity.resource_role:*",
                      "identity.grant:view"
                    ]
                  },
                  "member": {
                    "name": "Member",
                    "scope": "workspace",
                    "permissions": [
                      "identity.workspace:view",
                      "identity.member:view",
                      "identity.invitation:view",
                      "report:view"
                    ]
                  },
                  "editor": {
                    "name": "Editor",
                    "scope": "resource",
                    "assignableTo": ["principal", "guest"],
                    "permissions": ["report:view", "report:edit"]
                  },
                  "support": {
                    "name": "Support",
                    "scope": "project",
                    "permissions": ["report:view"]
                  }
                },
                "entitlements": {
                  "reports.export": {
                    "description": "Export reports",
                    "resourceType": "report"
                  },
                  "reports.schedule": {
                    "description": "Schedule reports by email"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "config": {
                      "$ref": "#/components/schemas/IamConfig"
                    }
                  },
                  "required": ["config"]
                },
                "example": {
                  "config": {
                    "version": 4,
                    "signUp": {
                      "mode": "invite_only"
                    },
                    "signIn": {
                      "emailCode": {
                        "enabled": true,
                        "codeTtl": "10m",
                        "resendAfter": "30s"
                      },
                      "providers": {}
                    },
                    "sessions": {
                      "idleTtl": "7d",
                      "maxTtl": "30d"
                    },
                    "guests": {
                      "enabled": false,
                      "idleTtl": "30d",
                      "createPerIpPerHour": 30
                    },
                    "accounts": {
                      "merge": "off",
                      "mergeTicketTtl": "10m"
                    },
                    "workspaces": {},
                    "invitations": {
                      "ttl": "7d"
                    },
                    "delegations": {
                      "maxTtl": "30d",
                      "tokenTtl": "15m"
                    },
                    "urls": {
                      "signInLink": "https://app.example.com/sign-in",
                      "invitationAccept": "https://app.example.com/invitations",
                      "oauthReturn": ["https://app.example.com/auth/callback"]
                    },
                    "resourceTypes": {
                      "report": {
                        "actions": ["view", "edit", "export"]
                      }
                    },
                    "roles": {
                      "admin": {
                        "name": "Admin",
                        "scope": "workspace",
                        "permissions": [
                          "identity.workspace:view",
                          "identity.member:*",
                          "identity.invitation:*",
                          "identity.resource_role:*",
                          "identity.grant:view"
                        ]
                      },
                      "member": {
                        "name": "Member",
                        "scope": "workspace",
                        "permissions": [
                          "identity.workspace:view",
                          "identity.member:view",
                          "identity.invitation:view",
                          "report:view"
                        ]
                      },
                      "editor": {
                        "name": "Editor",
                        "scope": "resource",
                        "assignableTo": ["principal", "guest"],
                        "permissions": ["report:view", "report:edit"]
                      },
                      "support": {
                        "name": "Support",
                        "scope": "project",
                        "permissions": ["report:view"]
                      }
                    },
                    "entitlements": {
                      "reports.export": {
                        "description": "Export reports",
                        "resourceType": "report"
                      },
                      "reports.schedule": {
                        "description": "Schedule reports by email"
                      }
                    },
                    "updatedAt": "2026-11-13T09:30:00.000Z",
                    "updatedBy": "trusted_caller"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`stale_version`](https://agentpost.tools/docs/identityhound/errors#stale_version).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["stale_version"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`config_invalid`](https://agentpost.tools/docs/identityhound/errors#config_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["config_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/config/validate": {
      "post": {
        "operationId": "config.validate",
        "summary": "Validate a config",
        "description": "Checks the settings without saving them. Saving compares any audit fields you send with the stored config and requires a client secret for each new provider app.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Idempotency-Key:** not taken. This operation changes nothing, so IdentityHound runs it on every request and it takes no `Idempotency-Key`.",
        "tags": ["Config"],
        "externalDocs": {
          "description": "Validate a config, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/config#validate-a-config"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "signUp": {
                    "type": "object",
                    "properties": {
                      "mode": {
                        "type": "string",
                        "enum": ["open", "invite_only", "closed"]
                      }
                    },
                    "required": ["mode"],
                    "additionalProperties": false
                  },
                  "signIn": {
                    "type": "object",
                    "properties": {
                      "emailCode": {
                        "type": "object",
                        "properties": {
                          "enabled": {
                            "type": "boolean"
                          },
                          "codeTtl": {
                            "type": "string",
                            "description": "A duration, such as \"10m\" or \"7d\""
                          },
                          "resendAfter": {
                            "type": "string",
                            "description": "A duration, such as \"10m\" or \"7d\""
                          }
                        },
                        "required": ["enabled", "codeTtl", "resendAfter"],
                        "additionalProperties": false
                      },
                      "providers": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9_.-]*$"
                        },
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "provider": {
                              "type": "string",
                              "enum": ["twitch"]
                            },
                            "enabled": {
                              "type": "boolean"
                            },
                            "clientId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "clientSecret": {
                              "type": "string",
                              "minLength": 1
                            },
                            "signIn": {
                              "type": "boolean"
                            },
                            "signInScopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "connectScopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "provider",
                            "enabled",
                            "clientId",
                            "signIn",
                            "signInScopes",
                            "connectScopes"
                          ],
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": ["emailCode", "providers"],
                    "additionalProperties": false
                  },
                  "sessions": {
                    "type": "object",
                    "properties": {
                      "idleTtl": {
                        "type": "string",
                        "description": "A duration, such as \"10m\" or \"7d\""
                      },
                      "maxTtl": {
                        "type": "string",
                        "description": "A duration, such as \"10m\" or \"7d\""
                      }
                    },
                    "required": ["idleTtl", "maxTtl"],
                    "additionalProperties": false
                  },
                  "guests": {
                    "type": "object",
                    "properties": {
                      "enabled": {
                        "type": "boolean"
                      },
                      "idleTtl": {
                        "type": "string",
                        "description": "A duration, such as \"10m\" or \"7d\""
                      },
                      "createPerIpPerHour": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      },
                      "maxActive": {
                        "description": "The most guests the project holds at once. Unset, there is no limit.",
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "required": ["enabled", "idleTtl", "createPerIpPerHour"],
                    "additionalProperties": false
                  },
                  "accounts": {
                    "type": "object",
                    "properties": {
                      "merge": {
                        "type": "string",
                        "enum": ["off", "on"],
                        "description": "With `on`, a principal who links a sign-in method another principal holds gets a merge ticket, and `POST /me/merge` merges that account into its own. With `off`, linking it fails with no ticket and the merge is refused."
                      },
                      "mergeTicketTtl": {
                        "type": "string",
                        "description": "How long a merge ticket lasts once issued."
                      }
                    },
                    "required": ["merge", "mergeTicketTtl"],
                    "additionalProperties": false
                  },
                  "workspaces": {
                    "type": "object",
                    "properties": {
                      "maxOwnedPerPrincipal": {
                        "description": "The most active workspaces one principal may own. Unset, there is no limit.",
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "additionalProperties": false
                  },
                  "invitations": {
                    "type": "object",
                    "properties": {
                      "ttl": {
                        "type": "string",
                        "description": "A duration, such as \"10m\" or \"7d\""
                      }
                    },
                    "required": ["ttl"],
                    "additionalProperties": false
                  },
                  "delegations": {
                    "type": "object",
                    "properties": {
                      "maxTtl": {
                        "type": "string",
                        "description": "A duration, such as \"10m\" or \"7d\""
                      },
                      "tokenTtl": {
                        "type": "string",
                        "description": "A duration, such as \"10m\" or \"7d\""
                      }
                    },
                    "required": ["maxTtl", "tokenTtl"],
                    "additionalProperties": false
                  },
                  "urls": {
                    "type": "object",
                    "properties": {
                      "signInLink": {
                        "description": "The page a sign-in code notification links to, with `email` and `code` added. Unset, the notification carries no link.",
                        "type": "string",
                        "format": "uri"
                      },
                      "invitationAccept": {
                        "description": "The page an invitation notification links to, with `token` added. Unset, the notification carries no link.",
                        "type": "string",
                        "format": "uri"
                      },
                      "oauthReturn": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "uri"
                        }
                      }
                    },
                    "required": ["oauthReturn"],
                    "additionalProperties": false
                  },
                  "resourceTypes": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_.-]*$"
                    },
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "actions": {
                          "minItems": 1,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^[a-z][a-z0-9_-]*(\\.[a-z][a-z0-9_-]*)*$"
                          }
                        },
                        "requiresEntitlement": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "pattern": "^[a-z][a-z0-9_-]*(\\.[a-z][a-z0-9_-]*)*$"
                          },
                          "additionalProperties": {
                            "type": "string",
                            "pattern": "^[a-z][a-z0-9_.-]*$"
                          }
                        }
                      },
                      "required": ["actions"],
                      "additionalProperties": false
                    }
                  },
                  "roles": {
                    "description": "Keyed by role. Ordinary roles require `name`, `scope`, and `permissions`. For `owner`, send the permissions it adds to its fixed ones, or omit the entry to add none. Its name, scope, assignee kinds, and built-in marker can be sent back as read.",
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_.-]*$"
                    },
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "minLength": 1
                        },
                        "scope": {
                          "type": "string",
                          "enum": ["project", "workspace", "resource"]
                        },
                        "permissions": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "description": "A permission, such as \"report:edit\" or \"report:*\""
                          }
                        },
                        "assignableTo": {
                          "description": "Who may hold the role: `[\"principal\"]`, `[\"guest\"]`, or both. `principal` covers every principal that is not a guest, whatever kind it declares. Without a list, any principal that is not a guest may hold it.",
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": ["principal", "guest"],
                            "description": "`principal`: every principal that is not a guest. `guest`: every guest."
                          }
                        },
                        "builtIn": {
                          "type": "boolean"
                        }
                      },
                      "required": ["permissions"],
                      "additionalProperties": false
                    }
                  },
                  "entitlements": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_.-]*$"
                    },
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "description": {
                          "type": "string"
                        },
                        "resourceType": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9_.-]*$"
                        }
                      },
                      "required": ["description"],
                      "additionalProperties": false
                    }
                  },
                  "version": {
                    "description": "If sent, the version must match the current config.",
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "updatedAt": {
                    "description": "If sent, the update time must match the current config.",
                    "type": "string",
                    "format": "date-time"
                  },
                  "updatedBy": {
                    "description": "If sent, the updater must match the current config.",
                    "type": "string"
                  }
                },
                "required": [
                  "signUp",
                  "signIn",
                  "sessions",
                  "guests",
                  "accounts",
                  "workspaces",
                  "invitations",
                  "delegations",
                  "urls",
                  "resourceTypes",
                  "roles",
                  "entitlements"
                ],
                "additionalProperties": false
              },
              "example": {
                "signUp": {
                  "mode": "invite_only"
                },
                "signIn": {
                  "emailCode": {
                    "enabled": true,
                    "codeTtl": "10m",
                    "resendAfter": "30s"
                  },
                  "providers": {}
                },
                "sessions": {
                  "idleTtl": "7d",
                  "maxTtl": "30d"
                },
                "guests": {
                  "enabled": false,
                  "idleTtl": "30d",
                  "createPerIpPerHour": 30
                },
                "accounts": {
                  "merge": "off",
                  "mergeTicketTtl": "10m"
                },
                "workspaces": {},
                "invitations": {
                  "ttl": "7d"
                },
                "delegations": {
                  "maxTtl": "30d",
                  "tokenTtl": "15m"
                },
                "urls": {
                  "signInLink": "https://app.example.com/sign-in",
                  "invitationAccept": "https://app.example.com/invitations",
                  "oauthReturn": ["https://app.example.com/auth/callback"]
                },
                "resourceTypes": {
                  "report": {
                    "actions": ["view", "edit", "export"]
                  }
                },
                "roles": {
                  "admin": {
                    "name": "Admin",
                    "scope": "workspace",
                    "permissions": [
                      "identity.workspace:view",
                      "identity.member:*",
                      "identity.invitation:*",
                      "identity.resource_role:*",
                      "identity.grant:view"
                    ]
                  },
                  "member": {
                    "name": "Member",
                    "scope": "workspace",
                    "permissions": [
                      "identity.workspace:view",
                      "identity.member:view",
                      "identity.invitation:view",
                      "report:view"
                    ]
                  },
                  "editor": {
                    "name": "Editor",
                    "scope": "resource",
                    "assignableTo": ["principal", "guest"],
                    "permissions": ["report:view", "report:edit"]
                  },
                  "support": {
                    "name": "Support",
                    "scope": "project",
                    "permissions": ["report:view"]
                  }
                },
                "entitlements": {
                  "reports.export": {
                    "description": "Export reports",
                    "resourceType": "report"
                  },
                  "reports.schedule": {
                    "description": "Schedule reports by email"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean"
                    },
                    "issues": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "path": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        },
                        "required": ["path", "message"]
                      }
                    }
                  },
                  "required": ["valid", "issues"]
                },
                "example": {
                  "valid": true,
                  "issues": []
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/auth/email-code": {
      "post": {
        "operationId": "auth.requestCode",
        "summary": "Send a sign-in code",
        "description": "Sends a 6-digit sign-in code to an email address that has an account or that the sign-up mode lets in. Always answers 202 the same way, so the answer never says which.\n\n- **Who may call:** Your server or anyone.\n- **Idempotency-Key:** optional. ",
        "tags": ["Sign-in"],
        "externalDocs": {
          "description": "Send a sign-in code, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/auth#send-a-sign-in-code"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "publishableKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "maxLength": 254,
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  }
                },
                "required": ["email"],
                "additionalProperties": false
              },
              "example": {
                "email": "ada@example.com"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodeRequested"
                },
                "example": {
                  "verificationId": "ver_01JDCXQVC1YRR68NC4NQ58DM0A",
                  "resendAfter": 30
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`sign_in_disabled`](https://agentpost.tools/docs/identityhound/errors#sign_in_disabled).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["sign_in_disabled"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests, with `error.code` [`throttled`](https://agentpost.tools/docs/identityhound/errors#throttled).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["throttled"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/auth/email-code/verify": {
      "post": {
        "operationId": "auth.verifyCode",
        "summary": "Verify a sign-in code",
        "description": "Checks the code and signs the principal in, or signs it up when the sign-up mode allows. Answers with a session token, shown once.\n\n- **Who may call:** Your server or anyone.\n- **Idempotency-Key:** optional. ",
        "tags": ["Sign-in"],
        "externalDocs": {
          "description": "Verify a sign-in code, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/auth#verify-a-sign-in-code"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "publishableKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "maxLength": 254,
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "code": {
                    "type": "string",
                    "pattern": "^\\d{6}$",
                    "description": "The 6-digit code from the email"
                  },
                  "verificationId": {
                    "type": "string",
                    "description": "The verificationId the code request returned"
                  },
                  "kind": {
                    "type": "string",
                    "enum": ["human", "agent", "service"],
                    "description": "A label the principal chooses for itself. Omit it to leave the kind unset. Roles, grants, and invitations treat every kind alike."
                  }
                },
                "required": ["email", "code", "verificationId"],
                "additionalProperties": false
              },
              "example": {
                "email": "ada@example.com",
                "code": "123456",
                "verificationId": "ver_01JDCXQVC1YRR68NC4NQ58DM0A"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionGrant"
                },
                "example": {
                  "token": "agp_st_…",
                  "session": {
                    "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
                  },
                  "principal": {
                    "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"
                  },
                  "signedUp": false
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`code_expired`](https://agentpost.tools/docs/identityhound/errors#code_expired), [`code_invalid`](https://agentpost.tools/docs/identityhound/errors#code_invalid), or [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "code_expired",
                                "code_invalid",
                                "invalid_request"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden) or [`sign_up_closed`](https://agentpost.tools/docs/identityhound/errors#sign_up_closed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "sign_up_closed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict) or [`identity_in_use`](https://agentpost.tools/docs/identityhound/errors#identity_in_use).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict", "identity_in_use"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests, with `error.code` [`throttled`](https://agentpost.tools/docs/identityhound/errors#throttled).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["throttled"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/auth/oauth/{providerKey}/start": {
      "post": {
        "operationId": "auth.oauthStart",
        "summary": "Start an OAuth flow",
        "description": "Starts an OAuth flow with a configured provider. Answers with the provider's authorize URL. `returnTo` must match a configured URL. With `purpose: sign_in`, set `connect: true` to also save this app's connection. Connecting requests the app's `connectScopes` and any extra `scopes`; sign-in also requests `signInScopes`. To keep what the principal's other connections for this app hold, list them and pass their `scopes`.\n\n- **Who may call:** Your server, anyone, or a signed-in principal.\n- **Access:** Signing in needs no credential. Linking or connecting an account needs the signed-in principal.\n- **Idempotency-Key:** optional. ",
        "tags": ["Sign-in"],
        "externalDocs": {
          "description": "Start an OAuth flow, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/auth#start-an-oauth-flow"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "publishableKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "providerKey",
            "in": "path",
            "required": true,
            "description": "A provider key: a key of the config's `signIn.providers`, such as `twitch`.",
            "schema": {
              "type": "string"
            },
            "example": "twitch"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": ["human", "agent", "service"],
                    "description": "A label the principal chooses for itself. Omit it to leave the kind unset. Roles, grants, and invitations treat every kind alike."
                  },
                  "purpose": {
                    "type": "string",
                    "enum": ["sign_in", "link", "connect"]
                  },
                  "returnTo": {
                    "type": "string",
                    "format": "uri"
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "connect": {
                    "description": "With sign_in, also save a connection for this provider app.",
                    "type": "boolean"
                  },
                  "binding": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  }
                },
                "required": ["purpose", "returnTo"],
                "additionalProperties": false
              },
              "example": {
                "purpose": "sign_in",
                "returnTo": "https://app.example.com/auth/callback"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthStartResponse"
                },
                "example": {
                  "authorizeUrl": "https://id.twitch.tv/oauth2/authorize?client_id=your_client_id&response_type=code&scope=user%3Aread%3Aemail&state=…",
                  "state": "oauth_state_…",
                  "expiresAt": "2026-11-13T09:40:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`return_to_not_allowed`](https://agentpost.tools/docs/identityhound/errors#return_to_not_allowed) or [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "return_to_not_allowed",
                                "invalid_request"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden) or [`provider_disabled`](https://agentpost.tools/docs/identityhound/errors#provider_disabled).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "provider_disabled"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found) or [`provider_unknown`](https://agentpost.tools/docs/identityhound/errors#provider_unknown).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found", "provider_unknown"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests, with `error.code` [`throttled`](https://agentpost.tools/docs/identityhound/errors#throttled).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["throttled"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/auth/oauth/{providerKey}/callback": {
      "post": {
        "operationId": "auth.oauthCallback",
        "summary": "Finish an OAuth flow",
        "description": "Finishes an OAuth flow with the provider's `code` and `state`. Signs in, links an identity, or connects an account, depending on how the flow started. A sign-in started with `connect: true` also answers with its connection. If an existing connection needs more scopes, answers with `purpose: reauthorize` with a fresh authorize URL and state, without changing the connection or issuing a session. Send the browser to that URL, authorize the same provider account, and post the new code and state here with the original binding and credential. Repeat until the original purpose completes.\n\n- **Who may call:** Your server, anyone, or a signed-in principal.\n- **Idempotency-Key:** optional. ",
        "tags": ["Sign-in"],
        "externalDocs": {
          "description": "Finish an OAuth flow, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/auth#finish-an-oauth-flow"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "publishableKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "providerKey",
            "in": "path",
            "required": true,
            "description": "A provider key: a key of the config's `signIn.providers`, such as `twitch`.",
            "schema": {
              "type": "string"
            },
            "example": "twitch"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string",
                    "minLength": 1
                  },
                  "state": {
                    "type": "string",
                    "minLength": 1
                  },
                  "binding": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  }
                },
                "required": ["code", "state"],
                "additionalProperties": false
              },
              "example": {
                "code": "provider_code_…",
                "state": "oauth_state_…"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthCallbackResponse"
                },
                "example": {
                  "purpose": "sign_in",
                  "token": "agp_st_…",
                  "session": {
                    "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
                  },
                  "principal": {
                    "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"
                  },
                  "signedUp": false
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`oauth_state_invalid`](https://agentpost.tools/docs/identityhound/errors#oauth_state_invalid) or [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["oauth_state_invalid", "invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden), [`provider_disabled`](https://agentpost.tools/docs/identityhound/errors#provider_disabled), or [`sign_up_closed`](https://agentpost.tools/docs/identityhound/errors#sign_up_closed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "forbidden",
                                "provider_disabled",
                                "sign_up_closed"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found) or [`provider_unknown`](https://agentpost.tools/docs/identityhound/errors#provider_unknown).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found", "provider_unknown"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict) or [`identity_in_use`](https://agentpost.tools/docs/identityhound/errors#identity_in_use).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict", "identity_in_use"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "502": {
            "description": "Bad Gateway, with `error.code` [`provider_error`](https://agentpost.tools/docs/identityhound/errors#provider_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["provider_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/auth/guest": {
      "post": {
        "operationId": "auth.startGuest",
        "summary": "Start a guest session",
        "description": "Creates a guest principal and its session, when the project allows guests. Throttled per IP.\n\n- **Who may call:** Your server or anyone.\n- **Idempotency-Key:** optional. ",
        "tags": ["Sign-in"],
        "externalDocs": {
          "description": "Start a guest session, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/auth#start-a-guest-session"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "publishableKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "displayName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "displayName": "Visitor"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionGrant"
                },
                "example": {
                  "token": "agp_st_…",
                  "session": {
                    "id": "ses_01JD2EQP0GCGZMSCG7GMDVCFJ6",
                    "kind": "direct",
                    "principalId": "prn_01JD8B49FTM5GZ9SVD3SRG7TKD",
                    "authMethods": ["guest"],
                    "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
                  },
                  "principal": {
                    "id": "prn_01JD8B49FTM5GZ9SVD3SRG7TKD",
                    "kind": "guest",
                    "status": "active",
                    "displayName": "Visitor",
                    "projectRoles": [],
                    "guest": {
                      "createdIp": "203.0.113.24"
                    },
                    "metadata": {},
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "updatedAt": "2026-11-13T09:30:00.000Z"
                  },
                  "signedUp": true
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden) or [`guests_disabled`](https://agentpost.tools/docs/identityhound/errors#guests_disabled).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "guests_disabled"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests, with `error.code` [`guest_limit`](https://agentpost.tools/docs/identityhound/errors#guest_limit) or [`throttled`](https://agentpost.tools/docs/identityhound/errors#throttled).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["guest_limit", "throttled"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/auth/sign-out": {
      "post": {
        "operationId": "auth.signOut",
        "summary": "Sign out",
        "description": "Revokes the session or delegated token the call is made with.\n\n- **Who may call:** A signed-in principal.\n- **Idempotency-Key:** optional. ",
        "tags": ["Sign-in"],
        "externalDocs": {
          "description": "Sign out, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/auth#sign-out"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/auth/introspect": {
      "post": {
        "operationId": "auth.introspect",
        "summary": "Introspect a token",
        "description": "Says whether a session, API key, or delegated token is active, and who it acts for. `verifyRequest` in the SDK calls this. It counts as using the token, as a call made with it does: the idle limit of a session or delegated token moves forward, at most once a minute. So a server that checks the token on each request keeps the session alive while it is in use.\n\n- **Who may call:** Your server.\n- **Idempotency-Key:** not taken. A retry only checks the token again, so IdentityHound runs it on every request and it takes no `Idempotency-Key`.",
        "tags": ["Sign-in"],
        "externalDocs": {
          "description": "Introspect a token, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/auth#introspect-a-token"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "minLength": 16,
                    "maxLength": 512
                  }
                },
                "required": ["token"],
                "additionalProperties": false
              },
              "example": {
                "token": "agp_st_your_session_token"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntrospectResponse"
                },
                "example": {
                  "active": true,
                  "credential": {
                    "kind": "session",
                    "id": "ses_01JD2EQP0GCGZMSCG7GMDVCFJ6"
                  },
                  "actor": {
                    "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"
                  },
                  "session": {
                    "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
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/me": {
      "get": {
        "operationId": "me.get",
        "summary": "Get the signed-in principal",
        "description": "The signed-in principal.\n\n- **Who may call:** A signed-in principal.",
        "tags": ["The signed-in principal"],
        "externalDocs": {
          "description": "Get the signed-in principal, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/me#get-the-signed-in-principal"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "principal": {
                      "$ref": "#/components/schemas/Principal"
                    }
                  },
                  "required": ["principal"]
                },
                "example": {
                  "principal": {
                    "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"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "me.patch",
        "summary": "Update the signed-in principal",
        "description": "Changes the display name, avatar, metadata, or declared kind.\n\n- **Who may call:** A signed-in principal.\n- **Idempotency-Key:** optional. ",
        "tags": ["The signed-in principal"],
        "externalDocs": {
          "description": "Update the signed-in principal, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/me#update-the-signed-in-principal"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": ["human", "agent", "service"],
                        "description": "A label the principal chooses for itself. Omit it to leave the kind unset. Roles, grants, and invitations treat every kind alike."
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "displayName": {
                    "description": "A supplied name, 1 to 120 characters. Send null to clear it.",
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 120
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "avatarUrl": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uri"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "metadata": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "avatarUrl": "https://cdn.example.com/avatars/ada.png"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "principal": {
                      "$ref": "#/components/schemas/Principal"
                    }
                  },
                  "required": ["principal"]
                },
                "example": {
                  "principal": {
                    "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",
                    "avatarUrl": "https://cdn.example.com/avatars/ada.png"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/me/identities": {
      "get": {
        "operationId": "me.identities",
        "summary": "List sign-in identities",
        "description": "The sign-in identities linked to the caller.\n\n- **Who may call:** A signed-in principal.",
        "tags": ["The signed-in principal"],
        "externalDocs": {
          "description": "List sign-in identities, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/me#list-sign-in-identities"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "identities": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Identity"
                      }
                    }
                  },
                  "required": ["identities"]
                },
                "example": {
                  "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"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/me/identities/email": {
      "post": {
        "operationId": "me.requestEmailCode",
        "summary": "Send a code to add an email",
        "description": "Sends a code to an email address the caller wants to add.\n\n- **Who may call:** A signed-in principal.\n- **Idempotency-Key:** optional. ",
        "tags": ["The signed-in principal"],
        "externalDocs": {
          "description": "Send a code to add an email, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/me#send-a-code-to-add-an-email"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "maxLength": 254,
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  }
                },
                "required": ["email"],
                "additionalProperties": false
              },
              "example": {
                "email": "ada@work.example.com"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodeRequested"
                },
                "example": {
                  "verificationId": "ver_01JD96D8WS9SFFHA6AZCHN0KZH",
                  "resendAfter": 30
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden) or [`sign_in_disabled`](https://agentpost.tools/docs/identityhound/errors#sign_in_disabled).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "sign_in_disabled"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests, with `error.code` [`throttled`](https://agentpost.tools/docs/identityhound/errors#throttled).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["throttled"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/me/identities/email/verify": {
      "post": {
        "operationId": "me.verifyEmailCode",
        "summary": "Verify an added email",
        "description": "Checks the code and links the email address as an identity.\n\n- **Who may call:** A signed-in principal.\n- **Idempotency-Key:** optional. ",
        "tags": ["The signed-in principal"],
        "externalDocs": {
          "description": "Verify an added email, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/me#verify-an-added-email"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "maxLength": 254,
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "code": {
                    "type": "string",
                    "pattern": "^\\d{6}$",
                    "description": "The 6-digit code from the email"
                  },
                  "verificationId": {
                    "type": "string",
                    "description": "The verificationId the code request returned"
                  }
                },
                "required": ["email", "code", "verificationId"],
                "additionalProperties": false
              },
              "example": {
                "email": "ada@work.example.com",
                "code": "123456",
                "verificationId": "ver_01JD96D8WS9SFFHA6AZCHN0KZH"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "identity": {
                      "$ref": "#/components/schemas/Identity"
                    }
                  },
                  "required": ["identity"]
                },
                "example": {
                  "identity": {
                    "id": "idn_01JDP3W8Q2X7M4R9T6V1B5N0KC",
                    "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                    "type": "email",
                    "provider": "email",
                    "subject": "ada@work.example.com",
                    "verifiedAt": "2026-11-13T09:30:00.000Z",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "lastUsedAt": "2026-11-13T09:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`code_expired`](https://agentpost.tools/docs/identityhound/errors#code_expired), [`code_invalid`](https://agentpost.tools/docs/identityhound/errors#code_invalid), or [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "code_expired",
                                "code_invalid",
                                "invalid_request"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`identity_in_use`](https://agentpost.tools/docs/identityhound/errors#identity_in_use).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["identity_in_use"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests, with `error.code` [`throttled`](https://agentpost.tools/docs/identityhound/errors#throttled).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["throttled"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/me/identities/{id}": {
      "delete": {
        "operationId": "me.removeIdentity",
        "summary": "Remove a sign-in identity",
        "description": "Unlinks a sign-in identity when the principal has another way to sign in. Sessions started with the removed identity end.\n\n- **Who may call:** A signed-in principal.\n- **Idempotency-Key:** optional. ",
        "tags": ["The signed-in principal"],
        "externalDocs": {
          "description": "Remove a sign-in identity, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/me#remove-a-sign-in-identity"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "An identity ID, `idn_…`. The `id` of a [`Identity`](https://agentpost.tools/docs/identityhound/reference/me#the-identity-object).",
            "schema": {
              "type": "string"
            },
            "example": "idn_01JDG344JJGW867DQ6EJ5WGCY2"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`last_sign_in_method`](https://agentpost.tools/docs/identityhound/errors#last_sign_in_method).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["last_sign_in_method"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/me/sessions": {
      "get": {
        "operationId": "me.sessions",
        "summary": "List sessions",
        "description": "The caller's live sessions.\n\n- **Who may call:** A signed-in principal.",
        "tags": ["The signed-in principal"],
        "externalDocs": {
          "description": "List sessions, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/me#list-sessions"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sessions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Session"
                      }
                    }
                  },
                  "required": ["sessions"]
                },
                "example": {
                  "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",
                      "current": true
                    },
                    {
                      "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"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "me.revokeOtherSessions",
        "summary": "End other sessions",
        "description": "Ends every session but the one the call is made with.\n\n- **Who may call:** A signed-in principal.\n- **Idempotency-Key:** optional. ",
        "tags": ["The signed-in principal"],
        "externalDocs": {
          "description": "End other sessions, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/me#end-other-sessions"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "revoked": {
                      "type": "number"
                    }
                  },
                  "required": ["revoked"]
                },
                "example": {
                  "revoked": 1
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/me/sessions/{id}": {
      "delete": {
        "operationId": "me.revokeSession",
        "summary": "End a session",
        "description": "Ends one of the caller's sessions.\n\n- **Who may call:** A signed-in principal.\n- **Idempotency-Key:** optional. ",
        "tags": ["The signed-in principal"],
        "externalDocs": {
          "description": "End a session, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/me#end-a-session"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A session ID, `ses_…`. The `id` of a [`Session`](https://agentpost.tools/docs/identityhound/reference/principals#the-session-object).",
            "schema": {
              "type": "string"
            },
            "example": "ses_01JD8JJY6V2MPY54HKBGHM1676"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/me/merge-guest": {
      "post": {
        "operationId": "me.mergeGuest",
        "summary": "Merge a guest",
        "description": "Moves a guest's grants and resource roles to the signed-in principal, with the guest's session token as proof, then deletes the guest. A role on a resource both hold in different workspaces answers `merge_blocked`.\n\n- **Who may call:** A signed-in principal.\n- **Idempotency-Key:** optional. ",
        "tags": ["The signed-in principal"],
        "externalDocs": {
          "description": "Merge a guest, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/me#merge-a-guest"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "guestSessionToken": {
                    "type": "string",
                    "minLength": 16,
                    "maxLength": 512
                  }
                },
                "required": ["guestSessionToken"],
                "additionalProperties": false
              },
              "example": {
                "guestSessionToken": "agp_st_guest_session_token"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MergeGuestResponse"
                },
                "example": {
                  "principal": {
                    "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"
                  },
                  "guestId": "prn_01JD8B49FTM5GZ9SVD3SRG7TKD",
                  "moved": {
                    "grants": 1,
                    "resourceRoles": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict) or [`merge_blocked`](https://agentpost.tools/docs/identityhound/errors#merge_blocked).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict", "merge_blocked"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/me/merge": {
      "post": {
        "operationId": "me.merge",
        "summary": "Merge another account",
        "description": "Merges another principal's account into the signed-in principal's, with the merge ticket that linking one of its sign-in methods returned. Its sign-in identities, connected accounts, grants, resource roles, project roles, and workspace memberships move over; where both are in one workspace, an active membership stays over a suspended one, then an owner one over any other role, and otherwise the signed-in principal's stays. The other account's sessions end, and it stays with `mergedInto` set, so its ID still resolves. Needs `accounts.merge: on`.\n\n- **Who may call:** A signed-in principal.\n- **Access:** Only the signed-in principal the ticket was issued to, while both accounts are active principals.\n- **Idempotency-Key:** optional. ",
        "tags": ["The signed-in principal"],
        "externalDocs": {
          "description": "Merge another account, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/me#merge-another-account"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "mergeTicket": {
                    "type": "string",
                    "minLength": 16,
                    "maxLength": 512,
                    "description": "The `details.mergeTicket` from the `identity_in_use` error a link returned"
                  }
                },
                "required": ["mergeTicket"],
                "additionalProperties": false
              },
              "example": {
                "mergeTicket": "agp_mt_merge_ticket_from_the_link"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MergeAccountResponse"
                },
                "example": {
                  "principal": {
                    "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"
                  },
                  "mergedId": "prn_01JD9V3K7QH2M5X8R4T6W0B1CE",
                  "moved": {
                    "identities": 1,
                    "connections": 1,
                    "grants": 1,
                    "resourceRoles": 0,
                    "projectRoles": 0,
                    "workspaces": 1
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict) or [`merge_blocked`](https://agentpost.tools/docs/identityhound/errors#merge_blocked).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict", "merge_blocked"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/principals": {
      "get": {
        "operationId": "principals.list",
        "summary": "List principals",
        "description": "Finds principals by kind, status, name or email, or `externalRef`. `kind` matches a declared label, or `guest`.\n\n- **Who may call:** Your server.\n- **Pages:** `limit`, 1 to 500, default 100. The answer holds up to `limit` items; narrow the query's filters to reach others.",
        "tags": ["Principals"],
        "externalDocs": {
          "description": "List principals, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/principals#list-principals"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "description": "A kind: `guest`, which IdentityHound sets, or a label a principal declared itself: `human`, `agent`, or `service`. Every setting treats the declared kinds alike.",
            "schema": {
              "type": "string",
              "enum": ["human", "guest", "agent", "service"]
            },
            "example": "agent"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["active", "suspended", "deleted"]
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "1–120 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            }
          },
          {
            "name": "externalRef",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            },
            "example": 20
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "principals": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Principal"
                      }
                    }
                  },
                  "required": ["principals"]
                },
                "example": {
                  "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"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "principals.create",
        "summary": "Create a principal",
        "description": "Creates a principal and answers with its first API key. The token is shown once.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** A signed-in principal or your server may create one.\n- **Idempotency-Key:** optional. ",
        "tags": ["Principals"],
        "externalDocs": {
          "description": "Create a principal, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/principals#create-a-principal"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": ["human", "agent", "service"],
                    "description": "A label the principal chooses for itself. Omit it to leave the kind unset. Roles, grants, and invitations treat every kind alike."
                  },
                  "displayName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "avatarUrl": {
                    "type": "string",
                    "format": "uri"
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "externalRef": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "metadata": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "kind": "agent",
                "displayName": "Report assistant",
                "description": "Drafts the weekly report"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrincipalCreated"
                },
                "example": {
                  "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"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/principals/import": {
      "post": {
        "operationId": "principals.import",
        "summary": "Import principals",
        "description": "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`.\n\n- **Who may call:** Your server.\n- **Idempotency-Key:** optional. ",
        "tags": ["Principals"],
        "externalDocs": {
          "description": "Import principals, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/principals#import-principals"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "principals": {
                    "minItems": 1,
                    "maxItems": 500,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "enum": ["human", "agent", "service"],
                          "description": "A label the principal chooses for itself. Omit it to leave the kind unset. Roles, grants, and invitations treat every kind alike."
                        },
                        "externalRef": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "displayName": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 120
                        },
                        "avatarUrl": {
                          "type": "string",
                          "format": "uri"
                        },
                        "metadata": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        "identities": {
                          "minItems": 1,
                          "type": "array",
                          "items": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "email"
                                  },
                                  "email": {
                                    "type": "string",
                                    "maxLength": 254,
                                    "format": "email",
                                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                                  }
                                },
                                "required": ["type", "email"],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "oauth"
                                  },
                                  "provider": {
                                    "type": "string",
                                    "enum": ["twitch"]
                                  },
                                  "subject": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "profile": {
                                    "type": "object",
                                    "properties": {
                                      "login": {
                                        "type": "string"
                                      },
                                      "displayName": {
                                        "type": "string"
                                      },
                                      "email": {
                                        "type": "string"
                                      },
                                      "avatarUrl": {
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false
                                  }
                                },
                                "required": ["type", "provider", "subject"],
                                "additionalProperties": false
                              }
                            ]
                          }
                        },
                        "projectRoles": {
                          "description": "Configured project roles to add. Existing roles stay; repeated roles add nothing.",
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^[a-z][a-z0-9_.-]*$",
                            "description": "A role key from the config, such as \"member\""
                          }
                        },
                        "memberships": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "workspaceId": {
                                "type": "string",
                                "description": "A workspace ID, wsp_…"
                              },
                              "role": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_.-]*$",
                                "description": "A role key from the config, such as \"member\""
                              }
                            },
                            "required": ["workspaceId", "role"],
                            "additionalProperties": false
                          }
                        },
                        "grants": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "externalRef": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200,
                                "description": "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."
                              },
                              "target": {
                                "oneOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "entitlement"
                                      },
                                      "entitlement": {
                                        "type": "string",
                                        "pattern": "^[a-z][a-z0-9_.-]*$"
                                      },
                                      "resource": {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "id": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": ["type", "id"],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": ["kind", "entitlement"],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "bundle"
                                      },
                                      "bundle": {
                                        "type": "string",
                                        "pattern": "^[a-z][a-z0-9_.-]*$"
                                      }
                                    },
                                    "required": ["kind", "bundle"],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "provenance": {
                                "type": "object",
                                "properties": {
                                  "source": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 100,
                                    "description": "Your app's label for why the grant exists."
                                  },
                                  "reference": {
                                    "type": "string",
                                    "maxLength": 200
                                  },
                                  "note": {
                                    "type": "string",
                                    "maxLength": 1000
                                  }
                                },
                                "required": ["source"],
                                "additionalProperties": false
                              },
                              "metadata": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              },
                              "startsAt": {
                                "type": "string",
                                "format": "date-time",
                                "description": "An ISO 8601 date and time"
                              },
                              "expiresAt": {
                                "type": "string",
                                "format": "date-time",
                                "description": "An ISO 8601 date and time"
                              }
                            },
                            "required": ["externalRef", "target", "provenance"],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": ["externalRef", "identities"],
                      "additionalProperties": false
                    }
                  }
                },
                "required": ["principals"],
                "additionalProperties": false
              },
              "example": {
                "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"
                        }
                      }
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportResponse"
                },
                "example": {
                  "results": [
                    {
                      "externalRef": "user_1001",
                      "principalId": "prn_01JDSJ41R3JK54F6RKD4Y3J1GF",
                      "outcome": "created"
                    }
                  ],
                  "principalIds": {
                    "user_1001": "prn_01JDSJ41R3JK54F6RKD4Y3J1GF"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`entitlement_unknown`](https://agentpost.tools/docs/identityhound/errors#entitlement_unknown).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["entitlement_unknown"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/principals/{id}": {
      "get": {
        "operationId": "principals.get",
        "summary": "Get a principal",
        "description": "One principal.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** A principal may read only itself.",
        "tags": ["Principals"],
        "externalDocs": {
          "description": "Get a principal, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/principals#get-a-principal"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A principal ID, `prn_…`. The `id` of a [`Principal`](https://agentpost.tools/docs/identityhound/reference/principals#the-principal-object).",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JDWRHCP925GR1HC5AP0MCFKH"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "principal": {
                      "$ref": "#/components/schemas/Principal"
                    }
                  },
                  "required": ["principal"]
                },
                "example": {
                  "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"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "principals.patch",
        "summary": "Update a principal",
        "description": "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.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Only the principal or your server.\n- **Idempotency-Key:** optional. ",
        "tags": ["Principals"],
        "externalDocs": {
          "description": "Update a principal, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/principals#update-a-principal"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A principal ID, `prn_…`. The `id` of a [`Principal`](https://agentpost.tools/docs/identityhound/reference/principals#the-principal-object).",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JDWRHCP925GR1HC5AP0MCFKH"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": ["human", "agent", "service"],
                        "description": "A label the principal chooses for itself. Omit it to leave the kind unset. Roles, grants, and invitations treat every kind alike."
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "displayName": {
                    "description": "A supplied name, 1 to 120 characters. Send null to clear it.",
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 120
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "avatarUrl": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uri"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 1000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "metadata": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "description": "Drafts and sends the weekly report"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "principal": {
                      "$ref": "#/components/schemas/Principal"
                    }
                  },
                  "required": ["principal"]
                },
                "example": {
                  "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"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "principals.delete",
        "summary": "Delete a principal",
        "description": "Deletes a principal with its identities, sessions, keys, and connections, and revokes the connections' tokens at the provider.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Only the principal or your server.\n- **Idempotency-Key:** optional. ",
        "tags": ["Principals"],
        "externalDocs": {
          "description": "Delete a principal, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/principals#delete-a-principal"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A principal ID, `prn_…`. The `id` of a [`Principal`](https://agentpost.tools/docs/identityhound/reference/principals#the-principal-object).",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JDWRHCP925GR1HC5AP0MCFKH"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict) or [`last_owner`](https://agentpost.tools/docs/identityhound/errors#last_owner).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict", "last_owner"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/principals/{id}/identities": {
      "get": {
        "operationId": "principals.identities",
        "summary": "List a principal's identities",
        "description": "A principal's sign-in identities.\n\n- **Who may call:** Your server.",
        "tags": ["Principals"],
        "externalDocs": {
          "description": "List a principal's identities, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/principals#list-a-principals-identities"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A principal ID, `prn_…`. The `id` of a [`Principal`](https://agentpost.tools/docs/identityhound/reference/principals#the-principal-object).",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "identities": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Identity"
                      }
                    }
                  },
                  "required": ["identities"]
                },
                "example": {
                  "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"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/principals/{id}/sessions": {
      "get": {
        "operationId": "principals.sessions",
        "summary": "List a principal's sessions",
        "description": "A principal's live sessions, direct and delegated, newest first. A server that keeps data per session checks its copies against this.\n\n- **Who may call:** Your server.",
        "tags": ["Principals"],
        "externalDocs": {
          "description": "List a principal's sessions, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/principals#list-a-principals-sessions"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A principal ID, `prn_…`. The `id` of a [`Principal`](https://agentpost.tools/docs/identityhound/reference/principals#the-principal-object).",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sessions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Session"
                      }
                    }
                  },
                  "required": ["sessions"]
                },
                "example": {
                  "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"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/sessions/{id}": {
      "get": {
        "operationId": "sessions.get",
        "summary": "Get a session",
        "description": "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`.\n\n- **Who may call:** Your server.",
        "tags": ["Principals"],
        "externalDocs": {
          "description": "Get a session, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/principals#get-a-session"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A session ID, `ses_…`. The `id` of a [`Session`](https://agentpost.tools/docs/identityhound/reference/principals#the-session-object).",
            "schema": {
              "type": "string"
            },
            "example": "ses_01JD8JJY6V2MPY54HKBGHM1676"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "session": {
                      "$ref": "#/components/schemas/Session"
                    }
                  },
                  "required": ["session"]
                },
                "example": {
                  "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"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/principals/{id}/suspend": {
      "post": {
        "operationId": "principals.suspend",
        "summary": "Suspend a principal",
        "description": "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.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Only the principal or your server.\n- **Idempotency-Key:** optional. ",
        "tags": ["Principals"],
        "externalDocs": {
          "description": "Suspend a principal, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/principals#suspend-a-principal"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A principal ID, `prn_…`. The `id` of a [`Principal`](https://agentpost.tools/docs/identityhound/reference/principals#the-principal-object).",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JDWRHCP925GR1HC5AP0MCFKH"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "principal": {
                      "$ref": "#/components/schemas/Principal"
                    }
                  },
                  "required": ["principal"]
                },
                "example": {
                  "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"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict) or [`last_owner`](https://agentpost.tools/docs/identityhound/errors#last_owner).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict", "last_owner"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/principals/{id}/reactivate": {
      "post": {
        "operationId": "principals.reactivate",
        "summary": "Reactivate a principal",
        "description": "Lifts a suspension. Its live API keys work again. Its ended sessions and delegations stay revoked.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Only the principal or your server.\n- **Idempotency-Key:** optional. ",
        "tags": ["Principals"],
        "externalDocs": {
          "description": "Reactivate a principal, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/principals#reactivate-a-principal"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A principal ID, `prn_…`. The `id` of a [`Principal`](https://agentpost.tools/docs/identityhound/reference/principals#the-principal-object).",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JDWRHCP925GR1HC5AP0MCFKH"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "principal": {
                      "$ref": "#/components/schemas/Principal"
                    }
                  },
                  "required": ["principal"]
                },
                "example": {
                  "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"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/principals/{id}/api-keys": {
      "post": {
        "operationId": "apiKeys.create",
        "summary": "Create an API key",
        "description": "Issues an API key. The token is in the response once.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Only the principal or your server.\n- **Idempotency-Key:** optional. ",
        "tags": ["API keys"],
        "externalDocs": {
          "description": "Create an API key, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/api-keys#create-an-api-key"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A principal ID, `prn_…`. The `id` of a [`Principal`](https://agentpost.tools/docs/identityhound/reference/principals#the-principal-object).",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JDWRHCP925GR1HC5AP0MCFKH"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "restrictions": {
                    "type": "object",
                    "properties": {
                      "workspaceIds": {
                        "minItems": 1,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "description": "A workspace ID, wsp_…"
                        }
                      },
                      "permissions": {
                        "minItems": 1,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "description": "A permission, such as \"report:edit\" or \"report:*\""
                        }
                      }
                    },
                    "additionalProperties": false
                  },
                  "expiresAt": {
                    "type": "string",
                    "format": "date-time",
                    "description": "An ISO 8601 date and time"
                  }
                },
                "required": ["name"],
                "additionalProperties": false
              },
              "example": {
                "name": "Report assistant",
                "restrictions": {
                  "workspaceIds": ["wsp_01JDGKQN2K4RF0M0Z2HBASFA62"],
                  "permissions": ["report:view", "report:edit"]
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyCreated"
                },
                "example": {
                  "apiKey": {
                    "id": "key_01JD3F215PNGEK0WH9BSJZRD81",
                    "principalId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                    "name": "Report assistant",
                    "prefix": "agp_ak_acme_3f9a1c2b7d4e",
                    "restrictions": {
                      "workspaceIds": ["wsp_01JDGKQN2K4RF0M0Z2HBASFA62"],
                      "permissions": ["report:view", "report:edit"]
                    },
                    "status": "active",
                    "createdAt": "2026-11-06T16:45:00.000Z",
                    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
                  },
                  "token": "agp_ak_…"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "apiKeys.list",
        "summary": "List API keys",
        "description": "A principal's keys, without their secrets.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Only the principal or your server.",
        "tags": ["API keys"],
        "externalDocs": {
          "description": "List API keys, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/api-keys#list-api-keys"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A principal ID, `prn_…`. The `id` of a [`Principal`](https://agentpost.tools/docs/identityhound/reference/principals#the-principal-object).",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JDWRHCP925GR1HC5AP0MCFKH"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "apiKeys": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    }
                  },
                  "required": ["apiKeys"]
                },
                "example": {
                  "apiKeys": [
                    {
                      "id": "key_01JD3F215PNGEK0WH9BSJZRD81",
                      "principalId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                      "name": "Report assistant",
                      "prefix": "agp_ak_acme_3f9a1c2b7d4e",
                      "restrictions": {
                        "workspaceIds": ["wsp_01JDGKQN2K4RF0M0Z2HBASFA62"],
                        "permissions": ["report:view", "report:edit"]
                      },
                      "status": "active",
                      "createdAt": "2026-11-06T16:45:00.000Z",
                      "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api-keys/{id}/rotate": {
      "post": {
        "operationId": "apiKeys.rotate",
        "summary": "Rotate an API key",
        "description": "Issues a replacement key. Set `grace` from `0s` to `7d` to choose how long the old key keeps working. `0s` stops it at once. A key is replaced once: rotating a key already rotated answers `conflict`.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Only the principal or your server.\n- **Idempotency-Key:** optional. ",
        "tags": ["API keys"],
        "externalDocs": {
          "description": "Rotate an API key, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/api-keys#rotate-an-api-key"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "An API key ID, `key_…`. The `id` of a [`ApiKey`](https://agentpost.tools/docs/identityhound/reference/api-keys#the-apikey-object).",
            "schema": {
              "type": "string"
            },
            "example": "key_01JD3F215PNGEK0WH9BSJZRD81"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "grace": {
                    "type": "string",
                    "description": "How long the old key keeps working, from `0s` to `7d`. Send `0s` to stop it at once."
                  }
                },
                "required": ["grace"],
                "additionalProperties": false
              },
              "example": {
                "grace": "1h"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyCreated"
                },
                "example": {
                  "apiKey": {
                    "id": "key_01JD6MHWDD1MSKST11GBDWDP7K",
                    "principalId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                    "name": "Report assistant",
                    "prefix": "agp_ak_acme_8c1e5f0a9b2d",
                    "restrictions": {
                      "workspaceIds": ["wsp_01JDGKQN2K4RF0M0Z2HBASFA62"],
                      "permissions": ["report:view", "report:edit"]
                    },
                    "status": "active",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                    "rotatedFrom": "key_01JD3F215PNGEK0WH9BSJZRD81"
                  },
                  "token": "agp_ak_…"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api-keys/{id}": {
      "delete": {
        "operationId": "apiKeys.revoke",
        "summary": "Revoke an API key",
        "description": "Revokes a key at once when the principal has another way to sign in.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Only the principal or your server.\n- **Idempotency-Key:** optional. ",
        "tags": ["API keys"],
        "externalDocs": {
          "description": "Revoke an API key, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/api-keys#revoke-an-api-key"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "An API key ID, `key_…`. The `id` of a [`ApiKey`](https://agentpost.tools/docs/identityhound/reference/api-keys#the-apikey-object).",
            "schema": {
              "type": "string"
            },
            "example": "key_01JD3F215PNGEK0WH9BSJZRD81"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict) or [`last_sign_in_method`](https://agentpost.tools/docs/identityhound/errors#last_sign_in_method).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict", "last_sign_in_method"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/principals/{id}/connections": {
      "get": {
        "operationId": "connections.list",
        "summary": "List connected accounts",
        "description": "A principal's connected accounts, without their tokens.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** A principal may list only its own.",
        "tags": ["Connected accounts"],
        "externalDocs": {
          "description": "List connected accounts, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/connections#list-connected-accounts"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A principal ID, `prn_…`. The `id` of a [`Principal`](https://agentpost.tools/docs/identityhound/reference/principals#the-principal-object).",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "connections": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Connection"
                      }
                    }
                  },
                  "required": ["connections"]
                },
                "example": {
                  "connections": [
                    {
                      "id": "con_01JDJGPK8BY9CQ8J097GQDBK74",
                      "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                      "providerKey": "twitch",
                      "subject": "91234567",
                      "identityId": "idn_01JDG344JJGW867DQ6EJ5WGCY2",
                      "scopes": [
                        "user:read:email",
                        "channel:read:subscriptions"
                      ],
                      "accessTokenExpiresAt": "2026-11-13T13:30:00.000Z",
                      "status": "active",
                      "createdAt": "2026-11-03T08:20:00.000Z",
                      "lastRefreshedAt": "2026-11-13T09:30:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/connections/{id}": {
      "delete": {
        "operationId": "connections.remove",
        "summary": "Remove a connected account",
        "description": "Removes a connected account and revokes its tokens at the provider, such as Twitch, so they stop working there too. If the provider doesn't revoke them, the account is still removed.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** A principal may remove only its own.\n- **Idempotency-Key:** optional. ",
        "tags": ["Connected accounts"],
        "externalDocs": {
          "description": "Remove a connected account, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/connections#remove-a-connected-account"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A connection ID, `con_…`. The `id` of a [`Connection`](https://agentpost.tools/docs/identityhound/reference/connections#the-connection-object).",
            "schema": {
              "type": "string"
            },
            "example": "con_01JDJGPK8BY9CQ8J097GQDBK74"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/connections/{id}/token": {
      "post": {
        "operationId": "connections.token",
        "summary": "Get a provider access token",
        "description": "A short-lived access token for the provider, refreshed first when it's about to expire. Each active connection's token is also checked with the provider hourly, and a token the provider rejects is refreshed. A connection becomes `needs_reauth`, with a `connection.needs_reauth` event, only when the provider refuses its refresh token. A timeout, a 5xx, or a 429 from the provider never changes a connection; this call then answers `provider_error`, and a retry may succeed.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Trusted callers, or a principal with a delegated token whose delegation holds `identity.connection:use` for the provider. Not the principal's own session.\n- **Idempotency-Key:** optional. ",
        "tags": ["Connected accounts"],
        "externalDocs": {
          "description": "Get a provider access token, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/connections#get-a-provider-access-token"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A connection ID, `con_…`. The `id` of a [`Connection`](https://agentpost.tools/docs/identityhound/reference/connections#the-connection-object).",
            "schema": {
              "type": "string"
            },
            "example": "con_01JDJGPK8BY9CQ8J097GQDBK74"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionTokenResponse"
                },
                "example": {
                  "accessToken": "provider_access_token_…",
                  "expiresAt": "2026-11-13T13:30:00.000Z",
                  "scopes": ["user:read:email", "channel:read:subscriptions"]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden) or [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`connection_needs_reauth`](https://agentpost.tools/docs/identityhound/errors#connection_needs_reauth).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["connection_needs_reauth"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "502": {
            "description": "Bad Gateway, with `error.code` [`provider_error`](https://agentpost.tools/docs/identityhound/errors#provider_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["provider_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/workspaces": {
      "post": {
        "operationId": "workspaces.create",
        "summary": "Create a workspace",
        "description": "Creates a workspace.\n\n- **Who may call:** Your server or a signed-in principal.\n- **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.\n- **Idempotency-Key:** optional. ",
        "tags": ["Workspaces"],
        "externalDocs": {
          "description": "Create a workspace, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/workspaces#create-a-workspace"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "metadata": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "ownerId": {
                    "type": "string",
                    "description": "A principal ID, prn_…"
                  }
                },
                "required": ["name"],
                "additionalProperties": false
              },
              "example": {
                "name": "Acme",
                "ownerId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceWithMembership"
                },
                "example": {
                  "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"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden) or [`workspace_limit`](https://agentpost.tools/docs/identityhound/errors#workspace_limit).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "workspace_limit"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`role_not_assignable`](https://agentpost.tools/docs/identityhound/errors#role_not_assignable).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["role_not_assignable"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "workspaces.list",
        "summary": "List workspaces",
        "description": "The caller's workspaces, with their membership. A trusted caller lists every workspace.\n\n- **Who may call:** A signed-in principal or your server.\n- **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Workspaces"],
        "externalDocs": {
          "description": "List workspaces, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/workspaces#list-workspaces"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          },
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            },
            "example": 20
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "1–64 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "workspaces": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WorkspaceWithMembership"
                      }
                    },
                    "next": {
                      "type": "string"
                    }
                  },
                  "required": ["workspaces"]
                },
                "example": {
                  "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"
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/workspaces/{id}": {
      "get": {
        "operationId": "workspaces.get",
        "summary": "Get a workspace",
        "description": "One workspace, with the caller's membership.\n\n- **Who may call:** A signed-in principal or your server.\n- **Access:** Needs `identity.workspace:view` in the workspace.",
        "tags": ["Workspaces"],
        "externalDocs": {
          "description": "Get a workspace, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/workspaces#get-a-workspace"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          },
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. The `id` of a [`Workspace`](https://agentpost.tools/docs/identityhound/reference/workspaces#the-workspace-object).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceWithMembership"
                },
                "example": {
                  "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"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "workspaces.patch",
        "summary": "Update a workspace",
        "description": "Renames a workspace or changes its metadata.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.workspace:update`.\n- **Idempotency-Key:** optional. ",
        "tags": ["Workspaces"],
        "externalDocs": {
          "description": "Update a workspace, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/workspaces#update-a-workspace"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. The `id` of a [`Workspace`](https://agentpost.tools/docs/identityhound/reference/workspaces#the-workspace-object).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "metadata": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "name": "Acme Inc."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "workspace": {
                      "$ref": "#/components/schemas/Workspace"
                    }
                  },
                  "required": ["workspace"]
                },
                "example": {
                  "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"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/workspaces/{id}/archive": {
      "post": {
        "operationId": "workspaces.archive",
        "summary": "Archive a workspace",
        "description": "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.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.workspace:archive`.\n- **Idempotency-Key:** optional. ",
        "tags": ["Workspaces"],
        "externalDocs": {
          "description": "Archive a workspace, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/workspaces#archive-a-workspace"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. The `id` of a [`Workspace`](https://agentpost.tools/docs/identityhound/reference/workspaces#the-workspace-object).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "workspace": {
                      "$ref": "#/components/schemas/Workspace"
                    }
                  },
                  "required": ["workspace"]
                },
                "example": {
                  "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"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/workspaces/{id}/leave": {
      "post": {
        "operationId": "workspaces.leave",
        "summary": "Leave a workspace",
        "description": "The caller leaves a workspace. The last owner can't.\n\n- **Who may call:** A signed-in principal.\n- **Idempotency-Key:** optional. ",
        "tags": ["Workspaces"],
        "externalDocs": {
          "description": "Leave a workspace, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/workspaces#leave-a-workspace"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. The `id` of a [`Workspace`](https://agentpost.tools/docs/identityhound/reference/workspaces#the-workspace-object).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_a_member`](https://agentpost.tools/docs/identityhound/errors#not_a_member).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_a_member"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`last_owner`](https://agentpost.tools/docs/identityhound/errors#last_owner).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["last_owner"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/workspaces/{id}/members": {
      "get": {
        "operationId": "members.list",
        "summary": "List members",
        "description": "A workspace's members.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.member:view`.\n- **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Members"],
        "externalDocs": {
          "description": "List members, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/members#list-members"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. The `id` of a [`Workspace`](https://agentpost.tools/docs/identityhound/reference/workspaces#the-workspace-object).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            },
            "example": 20
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "1–64 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "members": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Membership"
                      }
                    },
                    "next": {
                      "type": "string"
                    }
                  },
                  "required": ["members"]
                },
                "example": {
                  "members": [
                    {
                      "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"
                    },
                    {
                      "id": "mem_01JD4CX40XT3YPEZHJ8VY0RG03",
                      "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                      "principalId": "prn_01JD1F7TG1SVVEHCFCS56KF78R",
                      "principalKind": "human",
                      "role": "member",
                      "status": "active",
                      "source": "invitation",
                      "invitationId": "inv_01JD4S9TK4EQEZ4YB4S2GTG2BB",
                      "createdAt": "2026-11-05T10:12:00.000Z",
                      "updatedAt": "2026-11-05T10:12:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "members.add",
        "summary": "Add a member",
        "description": "Adds a principal directly, without an invitation, such as an agent.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.member:add`. Adding an owner past `workspaces.maxOwnedPerPrincipal` is refused for every caller when the limit is set.\n- **Idempotency-Key:** optional. ",
        "tags": ["Members"],
        "externalDocs": {
          "description": "Add a member, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/members#add-a-member"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. The `id` of a [`Workspace`](https://agentpost.tools/docs/identityhound/reference/workspaces#the-workspace-object).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "principalId": {
                    "type": "string",
                    "description": "A principal ID, prn_…"
                  },
                  "role": {
                    "type": "string",
                    "pattern": "^[a-z][a-z0-9_.-]*$",
                    "description": "A role key from the config, such as \"member\""
                  }
                },
                "required": ["principalId", "role"],
                "additionalProperties": false
              },
              "example": {
                "principalId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                "role": "member"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "membership": {
                      "$ref": "#/components/schemas/Membership"
                    }
                  },
                  "required": ["membership"]
                },
                "example": {
                  "membership": {
                    "id": "mem_01JDNPKC9ZP7A94J2F9MBQ4TCH",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "principalId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                    "principalKind": "agent",
                    "role": "member",
                    "status": "active",
                    "source": "direct_add",
                    "addedBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "updatedAt": "2026-11-13T09:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden) or [`workspace_limit`](https://agentpost.tools/docs/identityhound/errors#workspace_limit).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "workspace_limit"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`role_not_assignable`](https://agentpost.tools/docs/identityhound/errors#role_not_assignable).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["role_not_assignable"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/workspaces/{id}/members/{memberId}": {
      "patch": {
        "operationId": "members.patch",
        "summary": "Update a member",
        "description": "Changes a member's role, or suspends or reactivates them.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.member:update`. Making someone an owner past `workspaces.maxOwnedPerPrincipal` is refused for every caller when the limit is set.\n- **Idempotency-Key:** optional. ",
        "tags": ["Members"],
        "externalDocs": {
          "description": "Update a member, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/members#update-a-member"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. The `id` of a [`Workspace`](https://agentpost.tools/docs/identityhound/reference/workspaces#the-workspace-object).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          },
          {
            "name": "memberId",
            "in": "path",
            "required": true,
            "description": "A membership ID, `mem_…`. The `id` of a [`Membership`](https://agentpost.tools/docs/identityhound/reference/members#the-membership-object).",
            "schema": {
              "type": "string"
            },
            "example": "mem_01JD4CX40XT3YPEZHJ8VY0RG03"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string",
                    "pattern": "^[a-z][a-z0-9_.-]*$",
                    "description": "A role key from the config, such as \"member\""
                  },
                  "status": {
                    "type": "string",
                    "enum": ["active", "suspended"]
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "role": "admin"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "membership": {
                      "$ref": "#/components/schemas/Membership"
                    }
                  },
                  "required": ["membership"]
                },
                "example": {
                  "membership": {
                    "id": "mem_01JD4CX40XT3YPEZHJ8VY0RG03",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "principalId": "prn_01JD1F7TG1SVVEHCFCS56KF78R",
                    "principalKind": "human",
                    "role": "admin",
                    "status": "active",
                    "source": "invitation",
                    "invitationId": "inv_01JD4S9TK4EQEZ4YB4S2GTG2BB",
                    "createdAt": "2026-11-05T10:12:00.000Z",
                    "updatedAt": "2026-11-13T09:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden) or [`workspace_limit`](https://agentpost.tools/docs/identityhound/errors#workspace_limit).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "workspace_limit"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_a_member`](https://agentpost.tools/docs/identityhound/errors#not_a_member) or [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_a_member", "not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`last_owner`](https://agentpost.tools/docs/identityhound/errors#last_owner).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["last_owner"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`role_not_assignable`](https://agentpost.tools/docs/identityhound/errors#role_not_assignable).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["role_not_assignable"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "members.remove",
        "summary": "Remove a member",
        "description": "Removes a member. The last owner stays.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.member:remove`.\n- **Idempotency-Key:** optional. ",
        "tags": ["Members"],
        "externalDocs": {
          "description": "Remove a member, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/members#remove-a-member"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. The `id` of a [`Workspace`](https://agentpost.tools/docs/identityhound/reference/workspaces#the-workspace-object).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          },
          {
            "name": "memberId",
            "in": "path",
            "required": true,
            "description": "A membership ID, `mem_…`. The `id` of a [`Membership`](https://agentpost.tools/docs/identityhound/reference/members#the-membership-object).",
            "schema": {
              "type": "string"
            },
            "example": "mem_01JD4CX40XT3YPEZHJ8VY0RG03"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_a_member`](https://agentpost.tools/docs/identityhound/errors#not_a_member).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_a_member"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`last_owner`](https://agentpost.tools/docs/identityhound/errors#last_owner).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["last_owner"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/workspaces/{id}/invitations": {
      "post": {
        "operationId": "invitations.create",
        "summary": "Create an invitation",
        "description": "Invites someone with a role. An email invitation is emailed to the principal; a code invitation answers with its token once.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.invitation:create`. Only an owner, or a trusted caller, invites an owner.\n- **Idempotency-Key:** optional. ",
        "tags": ["Invitations"],
        "externalDocs": {
          "description": "Create an invitation, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/invitations#create-an-invitation"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. The `id` of a [`Workspace`](https://agentpost.tools/docs/identityhound/reference/workspaces#the-workspace-object).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string",
                    "pattern": "^[a-z][a-z0-9_.-]*$",
                    "description": "A role key from the config, such as \"member\""
                  },
                  "channel": {
                    "type": "string",
                    "enum": ["email", "code"]
                  },
                  "email": {
                    "type": "string",
                    "maxLength": 254,
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "openTo": {
                    "description": "Who may accept: `[\"principal\"]`, `[\"guest\"]`, or both. Without it, whoever the role is open to.",
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": ["principal", "guest"],
                      "description": "`principal`: every principal that is not a guest. `guest`: every guest."
                    }
                  }
                },
                "required": ["role", "channel"],
                "additionalProperties": false
              },
              "example": {
                "role": "member",
                "channel": "email",
                "email": "grace@example.com"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvitationCreated"
                },
                "example": {
                  "invitation": {
                    "id": "inv_01JD4S9TK4EQEZ4YB4S2GTG2BB",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "role": "member",
                    "channel": "email",
                    "email": "grace@example.com",
                    "openTo": ["principal"],
                    "status": "pending",
                    "invitedBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                    "createdAt": "2026-11-04T11:00:00.000Z",
                    "expiresAt": "2026-11-11T11:00:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`role_not_assignable`](https://agentpost.tools/docs/identityhound/errors#role_not_assignable).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["role_not_assignable"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "invitations.list",
        "summary": "List invitations",
        "description": "A workspace's invitations.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.invitation:view`.\n- **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Invitations"],
        "externalDocs": {
          "description": "List invitations, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/invitations#list-invitations"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. The `id` of a [`Workspace`](https://agentpost.tools/docs/identityhound/reference/workspaces#the-workspace-object).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "1–64 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["pending", "accepted", "revoked", "expired"]
            },
            "example": "pending"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "invitations": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Invitation"
                      }
                    },
                    "next": {
                      "type": "string"
                    }
                  },
                  "required": ["invitations"]
                },
                "example": {
                  "invitations": [
                    {
                      "id": "inv_01JD4S9TK4EQEZ4YB4S2GTG2BB",
                      "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                      "role": "member",
                      "channel": "email",
                      "email": "grace@example.com",
                      "openTo": ["principal"],
                      "status": "pending",
                      "invitedBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                      "createdAt": "2026-11-04T11:00:00.000Z",
                      "expiresAt": "2026-11-11T11:00:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/invitations/{id}/resend": {
      "post": {
        "operationId": "invitations.resend",
        "summary": "Resend an invitation",
        "description": "Sends a pending invitation again, with a new token.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.invitation:resend`.\n- **Idempotency-Key:** optional. ",
        "tags": ["Invitations"],
        "externalDocs": {
          "description": "Resend an invitation, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/invitations#resend-an-invitation"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "An invitation ID, `inv_…`. The `id` of a [`Invitation`](https://agentpost.tools/docs/identityhound/reference/invitations#the-invitation-object).",
            "schema": {
              "type": "string"
            },
            "example": "inv_01JD4S9TK4EQEZ4YB4S2GTG2BB"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvitationCreated"
                },
                "example": {
                  "invitation": {
                    "id": "inv_01JD4S9TK4EQEZ4YB4S2GTG2BB",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "role": "member",
                    "channel": "email",
                    "email": "grace@example.com",
                    "openTo": ["principal"],
                    "status": "pending",
                    "invitedBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                    "createdAt": "2026-11-04T11:00:00.000Z",
                    "expiresAt": "2026-11-11T11:00:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict) or [`invitation_not_pending`](https://agentpost.tools/docs/identityhound/errors#invitation_not_pending).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict", "invitation_not_pending"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/invitations/{id}": {
      "delete": {
        "operationId": "invitations.revoke",
        "summary": "Revoke an invitation",
        "description": "Revokes a pending invitation.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.invitation:revoke`.\n- **Idempotency-Key:** optional. ",
        "tags": ["Invitations"],
        "externalDocs": {
          "description": "Revoke an invitation, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/invitations#revoke-an-invitation"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "An invitation ID, `inv_…`. The `id` of a [`Invitation`](https://agentpost.tools/docs/identityhound/reference/invitations#the-invitation-object).",
            "schema": {
              "type": "string"
            },
            "example": "inv_01JD4S9TK4EQEZ4YB4S2GTG2BB"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "invitation": {
                      "$ref": "#/components/schemas/Invitation"
                    }
                  },
                  "required": ["invitation"]
                },
                "example": {
                  "invitation": {
                    "id": "inv_01JD4S9TK4EQEZ4YB4S2GTG2BB",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "role": "member",
                    "channel": "email",
                    "email": "grace@example.com",
                    "openTo": ["principal"],
                    "status": "revoked",
                    "invitedBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                    "createdAt": "2026-11-04T11:00:00.000Z",
                    "expiresAt": "2026-11-11T11:00:00.000Z",
                    "revokedAt": "2026-11-13T09:30:00.000Z",
                    "revokedBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`invitation_not_pending`](https://agentpost.tools/docs/identityhound/errors#invitation_not_pending).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invitation_not_pending"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/invitations/preview": {
      "post": {
        "operationId": "invitations.preview",
        "summary": "Preview an invitation",
        "description": "What an invitation token is for: the workspace and the role. Changes nothing.\n\n- **Who may call:** Your server, anyone, or a signed-in principal.\n- **Idempotency-Key:** not taken. This operation changes nothing, so IdentityHound runs it on every request and it takes no `Idempotency-Key`.",
        "tags": ["Invitations"],
        "externalDocs": {
          "description": "Preview an invitation, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/invitations#preview-an-invitation"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "publishableKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "minLength": 16,
                    "maxLength": 512
                  }
                },
                "required": ["token"],
                "additionalProperties": false
              },
              "example": {
                "token": "agp_iv_your_invitation_token"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvitationPreviewResponse"
                },
                "example": {
                  "invitation": {
                    "id": "inv_01JD4S9TK4EQEZ4YB4S2GTG2BB",
                    "role": "member",
                    "channel": "email",
                    "email": "grace@example.com",
                    "openTo": ["principal"],
                    "expiresAt": "2026-11-11T11:00:00.000Z",
                    "status": "pending"
                  },
                  "workspace": {
                    "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "name": "Acme"
                  },
                  "invitedBy": {
                    "id": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                    "displayName": "Ada Lovelace"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`invitation_invalid`](https://agentpost.tools/docs/identityhound/errors#invitation_invalid) or [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invitation_invalid", "not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`invitation_not_pending`](https://agentpost.tools/docs/identityhound/errors#invitation_not_pending).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invitation_not_pending"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/invitations/accept": {
      "post": {
        "operationId": "invitations.accept",
        "summary": "Accept an invitation",
        "description": "The signed-in principal accepts an invitation. An email invitation needs that email as a verified identity. An invitation as owner is refused past `workspaces.maxOwnedPerPrincipal`, and stays pending.\n\n- **Who may call:** A signed-in principal.\n- **Idempotency-Key:** optional. ",
        "tags": ["Invitations"],
        "externalDocs": {
          "description": "Accept an invitation, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/invitations#accept-an-invitation"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "minLength": 16,
                    "maxLength": 512
                  }
                },
                "required": ["token"],
                "additionalProperties": false
              },
              "example": {
                "token": "agp_iv_your_invitation_token"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvitationAccepted"
                },
                "example": {
                  "membership": {
                    "id": "mem_01JD4CX40XT3YPEZHJ8VY0RG03",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "principalId": "prn_01JD1F7TG1SVVEHCFCS56KF78R",
                    "principalKind": "human",
                    "role": "member",
                    "status": "active",
                    "source": "invitation",
                    "invitationId": "inv_01JD4S9TK4EQEZ4YB4S2GTG2BB",
                    "createdAt": "2026-11-05T10:12:00.000Z",
                    "updatedAt": "2026-11-05T10:12:00.000Z"
                  },
                  "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"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden), [`invitation_email_mismatch`](https://agentpost.tools/docs/identityhound/errors#invitation_email_mismatch), [`invitation_not_open`](https://agentpost.tools/docs/identityhound/errors#invitation_not_open), or [`workspace_limit`](https://agentpost.tools/docs/identityhound/errors#workspace_limit).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "forbidden",
                                "invitation_email_mismatch",
                                "invitation_not_open",
                                "workspace_limit"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`invitation_invalid`](https://agentpost.tools/docs/identityhound/errors#invitation_invalid) or [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invitation_invalid", "not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict) or [`invitation_not_pending`](https://agentpost.tools/docs/identityhound/errors#invitation_not_pending).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict", "invitation_not_pending"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`role_not_assignable`](https://agentpost.tools/docs/identityhound/errors#role_not_assignable).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["role_not_assignable"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/principals/{id}/project-roles": {
      "post": {
        "operationId": "projectRoles.assign",
        "summary": "Assign a project role",
        "description": "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.\n\n- **Who may call:** Your server.\n- **Access:** Emits `project_role.assigned` with `principalId` and `role` only when the role is added.\n- **Idempotency-Key:** optional. ",
        "tags": ["Project roles"],
        "externalDocs": {
          "description": "Assign a project role, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/project-roles#assign-a-project-role"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A principal ID, `prn_…`. The `id` of a [`Principal`](https://agentpost.tools/docs/identityhound/reference/principals#the-principal-object).",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JD1F7TG1SVVEHCFCS56KF78R"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string",
                    "pattern": "^[a-z][a-z0-9_.-]*$",
                    "description": "A configured project role, such as \"support\""
                  }
                },
                "required": ["role"],
                "additionalProperties": false
              },
              "example": {
                "role": "support"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "principal": {
                      "$ref": "#/components/schemas/Principal"
                    }
                  },
                  "required": ["principal"]
                },
                "example": {
                  "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"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden) or [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`role_not_assignable`](https://agentpost.tools/docs/identityhound/errors#role_not_assignable).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["role_not_assignable"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/principals/{id}/project-roles/{role}": {
      "delete": {
        "operationId": "projectRoles.remove",
        "summary": "Remove a project role",
        "description": "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.\n\n- **Who may call:** Your server.\n- **Access:** Emits `project_role.removed` with `principalId` and `role` only when the role is removed. A deleted or missing principal answers `not_found`.\n- **Idempotency-Key:** optional. ",
        "tags": ["Project roles"],
        "externalDocs": {
          "description": "Remove a project role, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/project-roles#remove-a-project-role"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A principal ID, `prn_…`. The `id` of a [`Principal`](https://agentpost.tools/docs/identityhound/reference/principals#the-principal-object).",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JD1F7TG1SVVEHCFCS56KF78R"
          },
          {
            "name": "role",
            "in": "path",
            "required": true,
            "description": "A project role: a key of the config's `roles` whose `scope` is `project`, such as `support`.",
            "schema": {
              "type": "string"
            },
            "example": "support"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/resource-roles": {
      "post": {
        "operationId": "resourceRoles.assign",
        "summary": "Assign a resource role",
        "description": "Gives a principal, every principal that is not a guest, or every guest a role on a resource.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.resource_role:assign` in the resource's workspace. Without a workspace, only a trusted caller.\n- **Idempotency-Key:** optional. ",
        "tags": ["Resource roles"],
        "externalDocs": {
          "description": "Assign a resource role, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/resource-roles#assign-a-resource-role"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "resource": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "minLength": 1
                      },
                      "id": {
                        "type": "string",
                        "minLength": 1
                      },
                      "workspaceId": {
                        "description": "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.",
                        "type": "string"
                      }
                    },
                    "required": ["type", "id"],
                    "additionalProperties": false
                  },
                  "holder": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "principal"
                          },
                          "id": {
                            "type": "string",
                            "description": "A principal ID, prn_…"
                          }
                        },
                        "required": ["kind", "id"],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "all"
                          },
                          "of": {
                            "type": "string",
                            "enum": ["principal", "guest"],
                            "description": "`principal`: every principal that is not a guest. `guest`: every guest."
                          }
                        },
                        "required": ["kind", "of"],
                        "additionalProperties": false
                      }
                    ]
                  },
                  "role": {
                    "type": "string",
                    "pattern": "^[a-z][a-z0-9_.-]*$",
                    "description": "A role key from the config, such as \"member\""
                  },
                  "expiresAt": {
                    "type": "string",
                    "format": "date-time",
                    "description": "An ISO 8601 date and time"
                  }
                },
                "required": ["resource", "holder", "role"],
                "additionalProperties": false
              },
              "example": {
                "resource": {
                  "type": "report",
                  "id": "q3-revenue",
                  "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
                },
                "holder": {
                  "kind": "principal",
                  "id": "prn_01JD1F7TG1SVVEHCFCS56KF78R"
                },
                "role": "editor"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "resourceRole": {
                      "$ref": "#/components/schemas/ResourceRole"
                    }
                  },
                  "required": ["resourceRole"]
                },
                "example": {
                  "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"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden) or [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`role_not_assignable`](https://agentpost.tools/docs/identityhound/errors#role_not_assignable).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["role_not_assignable"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "resourceRoles.list",
        "summary": "List resource roles",
        "description": "The roles on one resource, or the roles one holder holds.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** By resource, needs `identity.resource_role:view`. By holder, a principal may list only its own.\n- **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Resource roles"],
        "externalDocs": {
          "description": "List resource roles, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/resource-roles#list-resource-roles"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "1–64 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "resourceType",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "example": "report"
          },
          {
            "name": "resourceId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "example": "q3-revenue"
          },
          {
            "name": "workspaceId",
            "in": "query",
            "required": false,
            "description": "A workspace ID, `wsp_…`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "holder",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "resourceRoles": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ResourceRole"
                      }
                    },
                    "next": {
                      "type": "string"
                    }
                  },
                  "required": ["resourceRoles"]
                },
                "example": {
                  "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"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden) or [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/resource-roles/{id}": {
      "delete": {
        "operationId": "resourceRoles.remove",
        "summary": "Remove a resource role",
        "description": "Removes a resource role.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.resource_role:remove`.\n- **Idempotency-Key:** optional. ",
        "tags": ["Resource roles"],
        "externalDocs": {
          "description": "Remove a resource role, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/resource-roles#remove-a-resource-role"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A resource role ID, `rro_…`. The `id` of a [`ResourceRole`](https://agentpost.tools/docs/identityhound/reference/resource-roles#the-resourcerole-object).",
            "schema": {
              "type": "string"
            },
            "example": "rro_01JD2FKSRJGD9ZJD5JHCA24JM8"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden) or [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/bundles": {
      "post": {
        "operationId": "bundles.create",
        "summary": "Create a bundle",
        "description": "Creates a bundle of entitlements from the catalog.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.bundle:manage`.\n- **Idempotency-Key:** optional. ",
        "tags": ["Bundles"],
        "externalDocs": {
          "description": "Create a bundle, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/bundles#create-a-bundle"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string",
                    "pattern": "^[a-z][a-z0-9_.-]*$"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "entitlement": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9_.-]*$"
                        },
                        "resource": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "minLength": 1
                            },
                            "id": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": ["type", "id"],
                          "additionalProperties": false
                        }
                      },
                      "required": ["entitlement"],
                      "additionalProperties": false
                    }
                  }
                },
                "required": ["key", "name", "items"],
                "additionalProperties": false
              },
              "example": {
                "key": "pro",
                "name": "Pro",
                "items": [
                  {
                    "entitlement": "reports.export"
                  },
                  {
                    "entitlement": "reports.schedule"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "bundle": {
                      "$ref": "#/components/schemas/Bundle"
                    }
                  },
                  "required": ["bundle"]
                },
                "example": {
                  "bundle": {
                    "key": "pro",
                    "name": "Pro",
                    "items": [
                      {
                        "entitlement": "reports.export"
                      },
                      {
                        "entitlement": "reports.schedule"
                      }
                    ],
                    "status": "active",
                    "version": 1,
                    "createdAt": "2026-11-02T14:05:00.000Z",
                    "updatedAt": "2026-11-02T14:05:00.000Z",
                    "updatedBy": "trusted_caller"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`entitlement_unknown`](https://agentpost.tools/docs/identityhound/errors#entitlement_unknown).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["entitlement_unknown"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "bundles.list",
        "summary": "List bundles",
        "description": "Every bundle.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.bundle:view`.",
        "tags": ["Bundles"],
        "externalDocs": {
          "description": "List bundles, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/bundles#list-bundles"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "bundles": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Bundle"
                      }
                    }
                  },
                  "required": ["bundles"]
                },
                "example": {
                  "bundles": [
                    {
                      "key": "pro",
                      "name": "Pro",
                      "items": [
                        {
                          "entitlement": "reports.export"
                        },
                        {
                          "entitlement": "reports.schedule"
                        }
                      ],
                      "status": "active",
                      "version": 1,
                      "createdAt": "2026-11-02T14:05:00.000Z",
                      "updatedAt": "2026-11-02T14:05:00.000Z",
                      "updatedBy": "trusted_caller"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/bundles/{key}": {
      "get": {
        "operationId": "bundles.get",
        "summary": "Get a bundle",
        "description": "One bundle.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.bundle:view`.",
        "tags": ["Bundles"],
        "externalDocs": {
          "description": "Get a bundle, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/bundles#get-a-bundle"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "description": "A bundle key, such as `pro`. The `key` of a [`Bundle`](https://agentpost.tools/docs/identityhound/reference/bundles#the-bundle-object).",
            "schema": {
              "type": "string"
            },
            "example": "pro"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "bundle": {
                      "$ref": "#/components/schemas/Bundle"
                    }
                  },
                  "required": ["bundle"]
                },
                "example": {
                  "bundle": {
                    "key": "pro",
                    "name": "Pro",
                    "items": [
                      {
                        "entitlement": "reports.export"
                      },
                      {
                        "entitlement": "reports.schedule"
                      }
                    ],
                    "status": "active",
                    "version": 1,
                    "createdAt": "2026-11-02T14:05:00.000Z",
                    "updatedAt": "2026-11-02T14:05:00.000Z",
                    "updatedBy": "trusted_caller"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "bundles.patch",
        "summary": "Update a bundle",
        "description": "Renames a bundle or changes its items. Existing grants follow the bundle's new items.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.bundle:manage`.\n- **Idempotency-Key:** optional. ",
        "tags": ["Bundles"],
        "externalDocs": {
          "description": "Update a bundle, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/bundles#update-a-bundle"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "description": "A bundle key, such as `pro`. The `key` of a [`Bundle`](https://agentpost.tools/docs/identityhound/reference/bundles#the-bundle-object).",
            "schema": {
              "type": "string"
            },
            "example": "pro"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "entitlement": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9_.-]*$"
                        },
                        "resource": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "minLength": 1
                            },
                            "id": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": ["type", "id"],
                          "additionalProperties": false
                        }
                      },
                      "required": ["entitlement"],
                      "additionalProperties": false
                    }
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "items": [
                  {
                    "entitlement": "reports.export"
                  },
                  {
                    "entitlement": "reports.schedule"
                  },
                  {
                    "entitlement": "reports.export",
                    "resource": {
                      "type": "report",
                      "id": "q3-revenue"
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "bundle": {
                      "$ref": "#/components/schemas/Bundle"
                    }
                  },
                  "required": ["bundle"]
                },
                "example": {
                  "bundle": {
                    "key": "pro",
                    "name": "Pro",
                    "items": [
                      {
                        "entitlement": "reports.export"
                      },
                      {
                        "entitlement": "reports.schedule"
                      },
                      {
                        "entitlement": "reports.export",
                        "resource": {
                          "type": "report",
                          "id": "q3-revenue"
                        }
                      }
                    ],
                    "status": "active",
                    "version": 2,
                    "createdAt": "2026-11-02T14:05:00.000Z",
                    "updatedAt": "2026-11-13T09:30:00.000Z",
                    "updatedBy": "trusted_caller"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`bundle_retired`](https://agentpost.tools/docs/identityhound/errors#bundle_retired) or [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["bundle_retired", "conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`entitlement_unknown`](https://agentpost.tools/docs/identityhound/errors#entitlement_unknown).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["entitlement_unknown"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/bundles/{key}/retire": {
      "post": {
        "operationId": "bundles.retire",
        "summary": "Retire a bundle",
        "description": "Retires a bundle. New grants can't use it, and existing grants of it stay as history but give nothing.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.bundle:manage`.\n- **Idempotency-Key:** optional. ",
        "tags": ["Bundles"],
        "externalDocs": {
          "description": "Retire a bundle, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/bundles#retire-a-bundle"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "description": "A bundle key, such as `pro`. The `key` of a [`Bundle`](https://agentpost.tools/docs/identityhound/reference/bundles#the-bundle-object).",
            "schema": {
              "type": "string"
            },
            "example": "pro"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "bundle": {
                      "$ref": "#/components/schemas/Bundle"
                    }
                  },
                  "required": ["bundle"]
                },
                "example": {
                  "bundle": {
                    "key": "pro",
                    "name": "Pro",
                    "items": [
                      {
                        "entitlement": "reports.export"
                      },
                      {
                        "entitlement": "reports.schedule"
                      }
                    ],
                    "status": "retired",
                    "version": 2,
                    "createdAt": "2026-11-02T14:05:00.000Z",
                    "updatedAt": "2026-11-13T09:30:00.000Z",
                    "updatedBy": "trusted_caller"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`bundle_retired`](https://agentpost.tools/docs/identityhound/errors#bundle_retired).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["bundle_retired"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/grants": {
      "post": {
        "operationId": "grants.create",
        "summary": "Create a grant",
        "description": "Grants a bundle or an entitlement. One Idempotency-Key identifies one create request with no time limit.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.grant:create` for the holder.\n- **Idempotency-Key:** required. The grant keeps its key with no time limit. An authorized retry with the same key and body answers with the original grant; changing any field answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), even after 24 hours or from another caller. Every field counts: `target`, `holder`, `provenance`, `metadata`, `startsAt`, and `expiresAt`. Object key order does not count; date strings and omitted fields do. Keep omitted fields omitted on retry: omitting `startsAt` again matches, but supplying the server-filled start time does not. A grant transferred to another holder refuses the original request too. For a grant with no saved request hash, the permanent check compares stored fields, compares explicit dates as instants, and allows an omitted `startsAt` to match the stored start.",
        "tags": ["Grants"],
        "externalDocs": {
          "description": "Create a grant, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/grants#create-a-grant"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. The grant keeps its key with no time limit. An authorized retry with the same key and body answers with the original grant; changing any field answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), even after 24 hours or from another caller. Every field counts: `target`, `holder`, `provenance`, `metadata`, `startsAt`, and `expiresAt`. Object key order does not count; date strings and omitted fields do. Keep omitted fields omitted on retry: omitting `startsAt` again matches, but supplying the server-filled start time does not. A grant transferred to another holder refuses the original request too. For a grant with no saved request hash, the permanent check compares stored fields, compares explicit dates as instants, and allows an omitted `startsAt` to match the stored start. One whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "order_1042"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "target": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "entitlement"
                          },
                          "entitlement": {
                            "type": "string",
                            "pattern": "^[a-z][a-z0-9_.-]*$"
                          },
                          "resource": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "minLength": 1
                              },
                              "id": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "required": ["type", "id"],
                            "additionalProperties": false
                          }
                        },
                        "required": ["kind", "entitlement"],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "bundle"
                          },
                          "bundle": {
                            "type": "string",
                            "pattern": "^[a-z][a-z0-9_.-]*$"
                          }
                        },
                        "required": ["kind", "bundle"],
                        "additionalProperties": false
                      }
                    ]
                  },
                  "holder": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "principal"
                          },
                          "id": {
                            "type": "string",
                            "description": "A principal ID, prn_…"
                          }
                        },
                        "required": ["kind", "id"],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "workspace"
                          },
                          "id": {
                            "type": "string",
                            "description": "A workspace ID, wsp_…"
                          }
                        },
                        "required": ["kind", "id"],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "all"
                          },
                          "of": {
                            "type": "string",
                            "enum": ["principal", "guest"],
                            "description": "`principal`: every principal that is not a guest. `guest`: every guest."
                          }
                        },
                        "required": ["kind", "of"],
                        "additionalProperties": false
                      }
                    ]
                  },
                  "provenance": {
                    "type": "object",
                    "properties": {
                      "source": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100,
                        "description": "Your app's label for why the grant exists."
                      },
                      "reference": {
                        "type": "string",
                        "maxLength": 200
                      },
                      "note": {
                        "type": "string",
                        "maxLength": 1000
                      }
                    },
                    "required": ["source"],
                    "additionalProperties": false
                  },
                  "metadata": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "startsAt": {
                    "type": "string",
                    "format": "date-time",
                    "description": "An ISO 8601 date and time"
                  },
                  "expiresAt": {
                    "type": "string",
                    "format": "date-time",
                    "description": "An ISO 8601 date and time"
                  }
                },
                "required": ["target", "holder", "provenance"],
                "additionalProperties": false
              },
              "example": {
                "target": {
                  "kind": "bundle",
                  "bundle": "pro"
                },
                "holder": {
                  "kind": "workspace",
                  "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
                },
                "provenance": {
                  "source": "purchase",
                  "reference": "order_1042"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "grant": {
                      "$ref": "#/components/schemas/Grant"
                    }
                  },
                  "required": ["grant"]
                },
                "example": {
                  "grant": {
                    "id": "grt_01JD708CK3K0Y4F83NATYTFGW9",
                    "target": {
                      "kind": "bundle",
                      "bundle": "pro"
                    },
                    "holder": {
                      "kind": "workspace",
                      "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
                    },
                    "provenance": {
                      "source": "purchase",
                      "reference": "order_1042"
                    },
                    "startsAt": "2026-11-13T09:30:00.000Z",
                    "status": "active",
                    "idempotencyKey": "order_1042",
                    "grantedBy": "trusted_caller",
                    "createdAt": "2026-11-13T09:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`bundle_retired`](https://agentpost.tools/docs/identityhound/errors#bundle_retired), [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict), or [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "bundle_retired",
                                "conflict",
                                "idempotency_mismatch"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`entitlement_unknown`](https://agentpost.tools/docs/identityhound/errors#entitlement_unknown).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["entitlement_unknown"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "grants.list",
        "summary": "List grants",
        "description": "Grants by holder, bundle, or entitlement.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** A principal lists its own grants, or a holder's with `identity.grant:view`.\n- **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Grants"],
        "externalDocs": {
          "description": "List grants, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/grants#list-grants"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "1–64 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "holderKind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["principal", "workspace", "all"]
            },
            "example": "workspace"
          },
          {
            "name": "holderId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          },
          {
            "name": "holderOf",
            "in": "query",
            "required": false,
            "description": "With `holderKind=all`: `principal` for grants to every principal that is not a guest, or `guest` for grants to every guest.",
            "schema": {
              "type": "string",
              "enum": ["principal", "guest"]
            }
          },
          {
            "name": "bundle",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_.-]*$"
            }
          },
          {
            "name": "entitlement",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_.-]*$"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["active", "revoked", "expired"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "grants": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Grant"
                      }
                    },
                    "next": {
                      "type": "string"
                    }
                  },
                  "required": ["grants"]
                },
                "example": {
                  "grants": [
                    {
                      "id": "grt_01JD708CK3K0Y4F83NATYTFGW9",
                      "target": {
                        "kind": "bundle",
                        "bundle": "pro"
                      },
                      "holder": {
                        "kind": "workspace",
                        "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
                      },
                      "provenance": {
                        "source": "purchase",
                        "reference": "order_1042"
                      },
                      "startsAt": "2026-11-13T09:30:00.000Z",
                      "status": "active",
                      "idempotencyKey": "order_1042",
                      "grantedBy": "trusted_caller",
                      "createdAt": "2026-11-13T09:30:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/grants/{id}": {
      "get": {
        "operationId": "grants.get",
        "summary": "Get a grant",
        "description": "One grant.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Its holder, or anyone with `identity.grant:view`.",
        "tags": ["Grants"],
        "externalDocs": {
          "description": "Get a grant, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/grants#get-a-grant"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A grant ID, `grt_…`. The `id` of a [`Grant`](https://agentpost.tools/docs/identityhound/reference/grants#the-grant-object).",
            "schema": {
              "type": "string"
            },
            "example": "grt_01JD708CK3K0Y4F83NATYTFGW9"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "grant": {
                      "$ref": "#/components/schemas/Grant"
                    }
                  },
                  "required": ["grant"]
                },
                "example": {
                  "grant": {
                    "id": "grt_01JD708CK3K0Y4F83NATYTFGW9",
                    "target": {
                      "kind": "bundle",
                      "bundle": "pro"
                    },
                    "holder": {
                      "kind": "workspace",
                      "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
                    },
                    "provenance": {
                      "source": "purchase",
                      "reference": "order_1042"
                    },
                    "startsAt": "2026-11-13T09:30:00.000Z",
                    "status": "active",
                    "idempotencyKey": "order_1042",
                    "grantedBy": "trusted_caller",
                    "createdAt": "2026-11-13T09:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/grants/{id}/revoke": {
      "post": {
        "operationId": "grants.revoke",
        "summary": "Revoke a grant",
        "description": "Revokes a grant.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Needs `identity.grant:revoke`.\n- **Idempotency-Key:** optional. ",
        "tags": ["Grants"],
        "externalDocs": {
          "description": "Revoke a grant, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/grants#revoke-a-grant"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A grant ID, `grt_…`. The `id` of a [`Grant`](https://agentpost.tools/docs/identityhound/reference/grants#the-grant-object).",
            "schema": {
              "type": "string"
            },
            "example": "grt_01JD708CK3K0Y4F83NATYTFGW9"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 1000
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "reason": "Refunded"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "grant": {
                      "$ref": "#/components/schemas/Grant"
                    }
                  },
                  "required": ["grant"]
                },
                "example": {
                  "grant": {
                    "id": "grt_01JD708CK3K0Y4F83NATYTFGW9",
                    "target": {
                      "kind": "bundle",
                      "bundle": "pro"
                    },
                    "holder": {
                      "kind": "workspace",
                      "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
                    },
                    "provenance": {
                      "source": "purchase",
                      "reference": "order_1042"
                    },
                    "startsAt": "2026-11-13T09:30:00.000Z",
                    "status": "revoked",
                    "idempotencyKey": "order_1042",
                    "grantedBy": "trusted_caller",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "revokedAt": "2026-11-13T09:30:00.000Z",
                    "revokedBy": "trusted_caller",
                    "revokeReason": "Refunded"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`grant_not_active`](https://agentpost.tools/docs/identityhound/errors#grant_not_active).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["grant_not_active"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/entitlements/check": {
      "post": {
        "operationId": "entitlements.check",
        "summary": "Check an entitlement",
        "description": "Whether a principal holds an entitlement, with the grant and bundle that give it.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** A principal checks itself; a trusted caller names any `principalId`.\n- **Idempotency-Key:** not taken. This operation changes nothing, so IdentityHound runs it on every request and it takes no `Idempotency-Key`.",
        "tags": ["Entitlements"],
        "externalDocs": {
          "description": "Check an entitlement, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/entitlements#check-an-entitlement"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "principalId": {
                    "type": "string",
                    "description": "A principal ID, prn_…"
                  },
                  "entitlement": {
                    "type": "string",
                    "pattern": "^[a-z][a-z0-9_.-]*$"
                  },
                  "resource": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "minLength": 1
                      },
                      "id": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": ["type", "id"],
                    "additionalProperties": false
                  },
                  "workspaceId": {
                    "type": "string",
                    "description": "A workspace ID, wsp_…"
                  }
                },
                "required": ["entitlement"],
                "additionalProperties": false
              },
              "example": {
                "principalId": "prn_01JD1F7TG1SVVEHCFCS56KF78R",
                "entitlement": "reports.export",
                "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntitlementCheckResponse"
                },
                "example": {
                  "held": true,
                  "grant": {
                    "id": "grt_01JD708CK3K0Y4F83NATYTFGW9",
                    "target": {
                      "kind": "bundle",
                      "bundle": "pro"
                    },
                    "holder": {
                      "kind": "workspace",
                      "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
                    },
                    "provenance": {
                      "source": "purchase",
                      "reference": "order_1042"
                    },
                    "startsAt": "2026-11-13T09:30:00.000Z",
                    "status": "active",
                    "idempotencyKey": "order_1042",
                    "grantedBy": "trusted_caller",
                    "createdAt": "2026-11-13T09:30:00.000Z"
                  },
                  "bundle": {
                    "key": "pro",
                    "name": "Pro",
                    "items": [
                      {
                        "entitlement": "reports.export"
                      },
                      {
                        "entitlement": "reports.schedule"
                      }
                    ],
                    "status": "active",
                    "version": 1,
                    "createdAt": "2026-11-02T14:05:00.000Z",
                    "updatedAt": "2026-11-02T14:05:00.000Z",
                    "updatedBy": "trusted_caller"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`entitlement_unknown`](https://agentpost.tools/docs/identityhound/errors#entitlement_unknown).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["entitlement_unknown"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/entitlements": {
      "get": {
        "operationId": "entitlements.list",
        "summary": "List entitlements",
        "description": "Every entitlement a principal holds, such as the games in its library.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** A principal lists its own; a trusted caller names any `principalId`.",
        "tags": ["Entitlements"],
        "externalDocs": {
          "description": "List entitlements, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/entitlements#list-entitlements"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "principalId",
            "in": "query",
            "required": false,
            "description": "A principal ID, `prn_…`.",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JD1F7TG1SVVEHCFCS56KF78R"
          },
          {
            "name": "entitlement",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_.-]*$"
            }
          },
          {
            "name": "resourceType",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "workspaceId",
            "in": "query",
            "required": false,
            "description": "A workspace ID, `wsp_…`.",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntitlementsResponse"
                },
                "example": {
                  "entitlements": [
                    {
                      "entitlement": "reports.export",
                      "grantId": "grt_01JD708CK3K0Y4F83NATYTFGW9",
                      "bundle": "pro"
                    },
                    {
                      "entitlement": "reports.schedule",
                      "grantId": "grt_01JD708CK3K0Y4F83NATYTFGW9",
                      "bundle": "pro"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/delegations": {
      "post": {
        "operationId": "delegations.create",
        "summary": "Create a delegation",
        "description": "A principal delegates directly to another principal.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** The delegator uses its own session or API key. Your server names the delegator.\n- **Idempotency-Key:** optional. ",
        "tags": ["Delegations"],
        "externalDocs": {
          "description": "Create a delegation, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/delegations#create-a-delegation"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "delegatorId": {
                    "type": "string",
                    "description": "A principal ID, prn_…"
                  },
                  "delegateId": {
                    "type": "string",
                    "description": "A principal ID, prn_…"
                  },
                  "workspaceId": {
                    "description": "The workspace the delegation covers. Required, unless `identity.connection:use` is its only permission.",
                    "type": "string"
                  },
                  "permissions": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "description": "A permission, such as \"report:edit\" or \"report:*\""
                    },
                    "description": "Each as `<resourceType>:<action>`, with no wildcard. A delegation never grants more than the delegator holds."
                  },
                  "connections": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_.-]*$"
                    }
                  },
                  "expiresIn": {
                    "type": "string",
                    "description": "A duration, such as \"15m\" or \"30d\""
                  },
                  "reason": {
                    "type": "string",
                    "maxLength": 1000
                  }
                },
                "required": ["delegateId", "permissions", "expiresIn"],
                "additionalProperties": false
              },
              "example": {
                "delegatorId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                "delegateId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                "permissions": ["report:view", "report:edit"],
                "expiresIn": "30d",
                "reason": "Draft the weekly report"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "delegation": {
                      "$ref": "#/components/schemas/Delegation"
                    }
                  },
                  "required": ["delegation"]
                },
                "example": {
                  "delegation": {
                    "id": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME",
                    "delegatorId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                    "delegateId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "permissions": ["report:view", "report:edit"],
                    "status": "active",
                    "reason": "Draft the weekly report",
                    "expiresAt": "2026-12-13T09:30:00.000Z",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found) or [`provider_unknown`](https://agentpost.tools/docs/identityhound/errors#provider_unknown).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found", "provider_unknown"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "delegations.list",
        "summary": "List delegations",
        "description": "Delegations the caller gave or holds, filtered by status, delegator, or delegate.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Pages:** `limit`, 1 to 500, default 100. The answer holds up to `limit` items; narrow the query's filters to reach others.",
        "tags": ["Delegations"],
        "externalDocs": {
          "description": "List delegations, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/delegations#list-delegations"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "delegatorId",
            "in": "query",
            "required": false,
            "description": "A principal ID, `prn_…`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "delegateId",
            "in": "query",
            "required": false,
            "description": "A principal ID, `prn_…`.",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JDWRHCP925GR1HC5AP0MCFKH"
          },
          {
            "name": "workspaceId",
            "in": "query",
            "required": false,
            "description": "A workspace ID, `wsp_…`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["requested", "active", "denied", "revoked", "expired"]
            },
            "example": "active"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "delegations": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Delegation"
                      }
                    }
                  },
                  "required": ["delegations"]
                },
                "example": {
                  "delegations": [
                    {
                      "id": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME",
                      "delegatorId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                      "delegateId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                      "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                      "permissions": ["report:view", "report:edit"],
                      "status": "active",
                      "reason": "Draft the weekly report",
                      "expiresAt": "2026-12-13T09:30:00.000Z",
                      "createdAt": "2026-11-13T09:30:00.000Z",
                      "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/delegations/requests": {
      "post": {
        "operationId": "delegations.request",
        "summary": "Request a delegation",
        "description": "The delegate requests a delegation. The delegator approves or denies it. Throttled per delegate.\n\n- **Who may call:** A signed-in principal.\n- **Access:** The delegate, with its own session or API key.\n- **Idempotency-Key:** optional. ",
        "tags": ["Delegations"],
        "externalDocs": {
          "description": "Request a delegation, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/delegations#request-a-delegation"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "delegatorId": {
                    "type": "string",
                    "description": "A principal ID, prn_…"
                  },
                  "workspaceId": {
                    "description": "The workspace the delegation covers. Required, unless `identity.connection:use` is its only permission.",
                    "type": "string"
                  },
                  "permissions": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "description": "A permission, such as \"report:edit\" or \"report:*\""
                    },
                    "description": "Each as `<resourceType>:<action>`, with no wildcard. A delegation never grants more than the delegator holds."
                  },
                  "connections": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_.-]*$"
                    }
                  },
                  "expiresIn": {
                    "type": "string",
                    "description": "A duration, such as \"15m\" or \"30d\""
                  },
                  "reason": {
                    "type": "string",
                    "maxLength": 1000
                  }
                },
                "required": ["delegatorId", "permissions", "expiresIn"],
                "additionalProperties": false
              },
              "example": {
                "delegatorId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                "permissions": ["report:view", "report:edit"],
                "expiresIn": "30d",
                "reason": "Draft the weekly report"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "delegation": {
                      "$ref": "#/components/schemas/Delegation"
                    }
                  },
                  "required": ["delegation"]
                },
                "example": {
                  "delegation": {
                    "id": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME",
                    "delegatorId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                    "delegateId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "permissions": ["report:view", "report:edit"],
                    "status": "requested",
                    "reason": "Draft the weekly report",
                    "expiresAt": "2026-12-13T09:30:00.000Z",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "createdBy": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                    "requestedAt": "2026-11-13T09:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found) or [`provider_unknown`](https://agentpost.tools/docs/identityhound/errors#provider_unknown).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found", "provider_unknown"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests, with `error.code` [`throttled`](https://agentpost.tools/docs/identityhound/errors#throttled).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["throttled"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/delegations/{id}": {
      "get": {
        "operationId": "delegations.get",
        "summary": "Get a delegation",
        "description": "One delegation. A delegate that requested one reads it until its `status` is `active` or `denied`.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Its delegator or delegate.",
        "tags": ["Delegations"],
        "externalDocs": {
          "description": "Get a delegation, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/delegations#get-a-delegation"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A delegation ID, `dlg_…`. The `id` of a [`Delegation`](https://agentpost.tools/docs/identityhound/reference/delegations#the-delegation-object).",
            "schema": {
              "type": "string"
            },
            "example": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "delegation": {
                      "$ref": "#/components/schemas/Delegation"
                    }
                  },
                  "required": ["delegation"]
                },
                "example": {
                  "delegation": {
                    "id": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME",
                    "delegatorId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                    "delegateId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "permissions": ["report:view", "report:edit"],
                    "status": "active",
                    "reason": "Draft the weekly report",
                    "expiresAt": "2026-12-13T09:30:00.000Z",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "delegations.revoke",
        "summary": "Revoke a delegation",
        "description": "Revokes a delegation. Its delegated tokens and connection access stop at once.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Its delegator or delegate, or anyone with `identity.delegation:revoke` in its workspace. Not with a delegated token.\n- **Idempotency-Key:** optional. ",
        "tags": ["Delegations"],
        "externalDocs": {
          "description": "Revoke a delegation, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/delegations#revoke-a-delegation"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A delegation ID, `dlg_…`. The `id` of a [`Delegation`](https://agentpost.tools/docs/identityhound/reference/delegations#the-delegation-object).",
            "schema": {
              "type": "string"
            },
            "example": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/delegations/{id}/approve": {
      "post": {
        "operationId": "delegations.approve",
        "summary": "Approve a delegation",
        "description": "Approves a requested delegation.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Its delegator, with its own session or API key, or your server.\n- **Idempotency-Key:** optional. ",
        "tags": ["Delegations"],
        "externalDocs": {
          "description": "Approve a delegation, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/delegations#approve-a-delegation"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A delegation ID, `dlg_…`. The `id` of a [`Delegation`](https://agentpost.tools/docs/identityhound/reference/delegations#the-delegation-object).",
            "schema": {
              "type": "string"
            },
            "example": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "delegation": {
                      "$ref": "#/components/schemas/Delegation"
                    }
                  },
                  "required": ["delegation"]
                },
                "example": {
                  "delegation": {
                    "id": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME",
                    "delegatorId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                    "delegateId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "permissions": ["report:view", "report:edit"],
                    "status": "active",
                    "reason": "Draft the weekly report",
                    "expiresAt": "2026-12-13T09:30:00.000Z",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "createdBy": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                    "requestedAt": "2026-11-13T09:30:00.000Z",
                    "decidedAt": "2026-11-13T09:30:00.000Z",
                    "decidedBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/delegations/{id}/deny": {
      "post": {
        "operationId": "delegations.deny",
        "summary": "Deny a delegation",
        "description": "Denies a requested delegation.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Its delegator, with its own session or API key, or your server.\n- **Idempotency-Key:** optional. ",
        "tags": ["Delegations"],
        "externalDocs": {
          "description": "Deny a delegation, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/delegations#deny-a-delegation"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A delegation ID, `dlg_…`. The `id` of a [`Delegation`](https://agentpost.tools/docs/identityhound/reference/delegations#the-delegation-object).",
            "schema": {
              "type": "string"
            },
            "example": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "delegation": {
                      "$ref": "#/components/schemas/Delegation"
                    }
                  },
                  "required": ["delegation"]
                },
                "example": {
                  "delegation": {
                    "id": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME",
                    "delegatorId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                    "delegateId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "permissions": ["report:view", "report:edit"],
                    "status": "denied",
                    "reason": "Draft the weekly report",
                    "expiresAt": "2026-12-13T09:30:00.000Z",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "createdBy": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                    "requestedAt": "2026-11-13T09:30:00.000Z",
                    "decidedAt": "2026-11-13T09:30:00.000Z",
                    "decidedBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/delegations/{id}/tokens": {
      "post": {
        "operationId": "delegations.token",
        "summary": "Get a delegated token",
        "description": "Exchanges the delegate's API key or session for a delegated token, lasting the config's `delegations.tokenTtl` unless `expiresIn` is shorter, and never past the delegation's expiry. Answers `conflict` until the delegation is approved.\n\n- **Who may call:** A signed-in principal.\n- **Access:** The delegate, with its API key or session.\n- **Idempotency-Key:** optional. ",
        "tags": ["Delegations"],
        "externalDocs": {
          "description": "Get a delegated token, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/delegations#get-a-delegated-token"
        },
        "security": [
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A delegation ID, `dlg_…`. The `id` of a [`Delegation`](https://agentpost.tools/docs/identityhound/reference/delegations#the-delegation-object).",
            "schema": {
              "type": "string"
            },
            "example": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/identityhound/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expiresIn": {
                    "type": "string",
                    "description": "A duration, such as \"15m\" or \"30d\""
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "expiresIn": "15m"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DelegatedToken"
                },
                "example": {
                  "token": "agp_dt_…",
                  "session": {
                    "id": "ses_01JD4TCTCH1J3DXJ3N1PVAXVX2",
                    "kind": "delegated",
                    "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                    "delegateId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                    "delegationId": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME",
                    "authMethods": ["api_key"],
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "lastSeenAt": "2026-11-13T09:30:00.000Z",
                    "idleExpiresAt": "2026-11-13T09:45:00.000Z",
                    "expiresAt": "2026-11-13T09:45:00.000Z"
                  },
                  "actor": {
                    "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"
                  },
                  "onBehalfOf": {
                    "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"
                  },
                  "delegation": {
                    "id": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME",
                    "delegatorId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
                    "delegateId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "permissions": ["report:view", "report:edit"],
                    "status": "active",
                    "reason": "Draft the weekly report",
                    "expiresAt": "2026-12-13T09:30:00.000Z",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/identityhound/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/identityhound/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/access/check": {
      "post": {
        "operationId": "access.check",
        "summary": "Check access",
        "description": "Allowed or denied, with the reason. `explain: true` adds each step; `audit: true` records a denial in the change feed.\n\n- **Who may call:** Your server or a signed-in principal.\n- **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`.\n- **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.",
        "tags": ["Access checks"],
        "externalDocs": {
          "description": "Check access, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/access#check-access"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "principalId": {
                    "type": "string",
                    "description": "A principal ID, prn_…"
                  },
                  "delegateId": {
                    "description": "The delegate that would act for `principalId` under a delegation. The check then holds the delegate to that delegation.",
                    "type": "string"
                  },
                  "delegationId": {
                    "description": "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.",
                    "type": "string"
                  },
                  "action": {
                    "type": "string",
                    "pattern": "^[a-z][a-z0-9_-]*(\\.[a-z][a-z0-9_-]*)*$",
                    "description": "An action of the resource type, such as \"edit\" or \"transaction.view\""
                  },
                  "resource": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "minLength": 1
                      },
                      "id": {
                        "type": "string",
                        "minLength": 1
                      },
                      "workspaceId": {
                        "description": "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.",
                        "type": "string"
                      }
                    },
                    "required": ["type", "id"],
                    "additionalProperties": false
                  },
                  "explain": {
                    "type": "boolean"
                  },
                  "audit": {
                    "type": "boolean"
                  }
                },
                "required": ["action", "resource"],
                "additionalProperties": false
              },
              "example": {
                "principalId": "prn_01JD1F7TG1SVVEHCFCS56KF78R",
                "action": "edit",
                "resource": {
                  "type": "report",
                  "id": "q3-revenue",
                  "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckResponse"
                },
                "example": {
                  "allowed": true,
                  "reason": "resource_role",
                  "matched": {
                    "role": "editor",
                    "resourceRoleId": "rro_01JD2FKSRJGD9ZJD5JHCA24JM8"
                  },
                  "configVersion": 3
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/access/check-batch": {
      "post": {
        "operationId": "access.checkBatch",
        "summary": "Check access in a batch",
        "description": "Up to 100 checks in one call, answered in order.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** Each check follows the rules of `POST /access/check`.\n- **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.",
        "tags": ["Access checks"],
        "externalDocs": {
          "description": "Check access in a batch, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/access#check-access-in-a-batch"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "checks": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "principalId": {
                          "type": "string",
                          "description": "A principal ID, prn_…"
                        },
                        "delegateId": {
                          "description": "The delegate that would act for `principalId` under a delegation. The check then holds the delegate to that delegation.",
                          "type": "string"
                        },
                        "delegationId": {
                          "description": "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.",
                          "type": "string"
                        },
                        "action": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9_-]*(\\.[a-z][a-z0-9_-]*)*$",
                          "description": "An action of the resource type, such as \"edit\" or \"transaction.view\""
                        },
                        "resource": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "minLength": 1
                            },
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "workspaceId": {
                              "description": "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.",
                              "type": "string"
                            }
                          },
                          "required": ["type", "id"],
                          "additionalProperties": false
                        },
                        "explain": {
                          "type": "boolean"
                        },
                        "audit": {
                          "type": "boolean"
                        }
                      },
                      "required": ["action", "resource"],
                      "additionalProperties": false
                    }
                  }
                },
                "required": ["checks"],
                "additionalProperties": false
              },
              "example": {
                "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"
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckBatchResponse"
                },
                "example": {
                  "results": [
                    {
                      "allowed": true,
                      "reason": "resource_role",
                      "matched": {
                        "role": "editor",
                        "resourceRoleId": "rro_01JD2FKSRJGD9ZJD5JHCA24JM8"
                      },
                      "configVersion": 3
                    },
                    {
                      "allowed": false,
                      "reason": "entitlement_missing",
                      "configVersion": 3
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/access/permissions": {
      "get": {
        "operationId": "access.permissions",
        "summary": "List permissions on a resource",
        "description": "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.\n\n- **Who may call:** Your server or a signed-in principal.\n- **Access:** A principal asks about itself; a trusted caller names any `principalId`.",
        "tags": ["Access checks"],
        "externalDocs": {
          "description": "List permissions on a resource, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/access#list-permissions-on-a-resource"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          },
          {
            "userToken": []
          },
          {
            "apiKey": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "principalId",
            "in": "query",
            "required": false,
            "description": "A principal ID, `prn_…`.",
            "schema": {
              "type": "string"
            },
            "example": "prn_01JD1F7TG1SVVEHCFCS56KF78R"
          },
          {
            "name": "resourceType",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "example": "report"
          },
          {
            "name": "resourceId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "example": "q3-revenue"
          },
          {
            "name": "workspaceId",
            "in": "query",
            "required": false,
            "description": "The workspace the resource belongs to. Workspace roles count only when it is set.",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PermissionsResponse"
                },
                "example": {
                  "permissions": ["report:view", "report:edit"],
                  "configVersion": 3
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/identityhound/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/events": {
      "get": {
        "operationId": "events.read",
        "summary": "Read the change feed",
        "description": "Events after a cursor, and the next cursor.\n\n- **Who may call:** Your server.\n- **Pages:** `limit`, 1 to 500, default 100. A feed: every answer has `next`, to send as `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Change feed"],
        "externalDocs": {
          "description": "Read the change feed, in the API reference",
          "url": "https://agentpost.tools/docs/identityhound/reference/events#read-the-change-feed"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "The `seq` to read after, or `latest` to start from now: no events, and `next` set to the newest `seq`. Start at 0, then pass each page’s `next`.",
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "const": "latest"
                },
                {
                  "anyOf": [
                    {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    {
                      "type": "string",
                      "pattern": "^\\d+$"
                    }
                  ]
                }
              ]
            },
            "example": 1041
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "The most events to answer with, from 1 to 500; 1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            },
            "example": 1
          },
          {
            "name": "types",
            "in": "query",
            "required": false,
            "description": "Full event types to keep, separated by commas. Without it, every type.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventsResponse"
                },
                "example": {
                  "events": [
                    {
                      "id": "01JDGKQN2M8X4C6V0B3N5T7R9W",
                      "seq": 1042,
                      "specversion": "1.0",
                      "type": "tools.agentpost.identity.membership.added",
                      "source": "/identityhound",
                      "subject": "mem_01JD4CX40XT3YPEZHJ8VY0RG03",
                      "time": "2026-11-05T10:12:00.000Z",
                      "datacontenttype": "application/json",
                      "data": {
                        "context": {
                          "actor": {
                            "id": "prn_01JD1F7TG1SVVEHCFCS56KF78R"
                          },
                          "via": "session"
                        },
                        "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                        "membershipId": "mem_01JD4CX40XT3YPEZHJ8VY0RG03",
                        "principalId": "prn_01JD1F7TG1SVVEHCFCS56KF78R",
                        "principalKind": "human",
                        "role": "member"
                      }
                    }
                  ],
                  "next": 1042
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/identityhound/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/identityhound/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`trusted_caller_required`](https://agentpost.tools/docs/identityhound/errors#trusted_caller_required).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["trusted_caller_required"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "410": {
            "description": "Gone, with `error.code` [`cursor_expired`](https://agentpost.tools/docs/identityhound/errors#cursor_expired).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["cursor_expired"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/identityhound/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/identityhound/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "IamConfig": {
        "description": "The project's config in the API's answer. Provider client secrets are write-only: `PUT /config` takes `clientSecret`, and the stored document holds `clientSecretEnc`, which never leaves the service.",
        "type": "object",
        "properties": {
          "version": {
            "type": "number"
          },
          "signUp": {
            "type": "object",
            "properties": {
              "mode": {
                "type": "string",
                "enum": ["open", "invite_only", "closed"]
              }
            },
            "required": ["mode"]
          },
          "signIn": {
            "type": "object",
            "properties": {
              "emailCode": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  },
                  "codeTtl": {
                    "type": "string",
                    "description": "A length of time as a request, a record, or a config holds it, such as `\"30d\"`."
                  },
                  "resendAfter": {
                    "type": "string",
                    "description": "A length of time as a request, a record, or a config holds it, such as `\"30d\"`."
                  }
                },
                "required": ["enabled", "codeTtl", "resendAfter"]
              },
              "providers": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "properties": {
                    "provider": {
                      "const": "twitch"
                    },
                    "enabled": {
                      "type": "boolean"
                    },
                    "clientId": {
                      "type": "string"
                    },
                    "signIn": {
                      "type": "boolean"
                    },
                    "signInScopes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "connectScopes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "provider",
                    "enabled",
                    "clientId",
                    "signIn",
                    "signInScopes",
                    "connectScopes"
                  ]
                }
              }
            },
            "required": ["emailCode", "providers"]
          },
          "sessions": {
            "type": "object",
            "properties": {
              "idleTtl": {
                "type": "string",
                "description": "A length of time as a request, a record, or a config holds it, such as `\"30d\"`."
              },
              "maxTtl": {
                "type": "string",
                "description": "A length of time as a request, a record, or a config holds it, such as `\"30d\"`."
              }
            },
            "required": ["idleTtl", "maxTtl"]
          },
          "guests": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "idleTtl": {
                "type": "string",
                "description": "A length of time as a request, a record, or a config holds it, such as `\"30d\"`."
              },
              "createPerIpPerHour": {
                "type": "number"
              },
              "maxActive": {
                "type": "number"
              }
            },
            "required": ["enabled", "idleTtl", "createPerIpPerHour"]
          },
          "accounts": {
            "type": "object",
            "properties": {
              "merge": {
                "type": "string",
                "enum": ["off", "on"]
              },
              "mergeTicketTtl": {
                "type": "string",
                "description": "A length of time as a request, a record, or a config holds it, such as `\"30d\"`."
              }
            },
            "required": ["merge", "mergeTicketTtl"]
          },
          "workspaces": {
            "type": "object",
            "properties": {
              "maxOwnedPerPrincipal": {
                "type": "number"
              }
            },
            "required": []
          },
          "invitations": {
            "type": "object",
            "properties": {
              "ttl": {
                "type": "string",
                "description": "A length of time as a request, a record, or a config holds it, such as `\"30d\"`."
              }
            },
            "required": ["ttl"]
          },
          "delegations": {
            "type": "object",
            "properties": {
              "maxTtl": {
                "type": "string",
                "description": "A length of time as a request, a record, or a config holds it, such as `\"30d\"`."
              },
              "tokenTtl": {
                "type": "string",
                "description": "A length of time as a request, a record, or a config holds it, such as `\"30d\"`."
              }
            },
            "required": ["maxTtl", "tokenTtl"]
          },
          "urls": {
            "type": "object",
            "properties": {
              "signInLink": {
                "type": "string"
              },
              "invitationAccept": {
                "type": "string"
              },
              "oauthReturn": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": ["oauthReturn"]
          },
          "resourceTypes": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "actions": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "requiresEntitlement": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  }
                }
              },
              "required": ["actions"]
            }
          },
          "roles": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "scope": {
                  "type": "string",
                  "enum": ["project", "workspace", "resource"]
                },
                "permissions": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "description": "A permission, such as `report:edit`"
                  }
                },
                "assignableTo": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": ["principal", "guest"],
                    "description": "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."
                  }
                },
                "builtIn": {
                  "const": true
                }
              },
              "required": ["name", "scope", "permissions"]
            }
          },
          "entitlements": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "description": {
                  "type": "string"
                },
                "resourceType": {
                  "type": "string"
                }
              },
              "required": ["description"]
            }
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              {
                "const": "trusted_caller"
              },
              {
                "const": "adopt"
              },
              {
                "const": "system"
              }
            ],
            "description": "Who saved this version: a principal's ID, `trusted_caller` for your server's secret key, or `adopt` for the config the project adopted IdentityHound with, which a project adopted before November 2026 shows as `system`."
          }
        },
        "required": [
          "version",
          "signUp",
          "signIn",
          "sessions",
          "guests",
          "accounts",
          "workspaces",
          "invitations",
          "delegations",
          "urls",
          "resourceTypes",
          "roles",
          "entitlements",
          "updatedAt",
          "updatedBy"
        ],
        "examples": [
          {
            "version": 3,
            "signUp": {
              "mode": "invite_only"
            },
            "signIn": {
              "emailCode": {
                "enabled": true,
                "codeTtl": "10m",
                "resendAfter": "30s"
              },
              "providers": {}
            },
            "sessions": {
              "idleTtl": "7d",
              "maxTtl": "30d"
            },
            "guests": {
              "enabled": false,
              "idleTtl": "30d",
              "createPerIpPerHour": 30
            },
            "accounts": {
              "merge": "off",
              "mergeTicketTtl": "10m"
            },
            "workspaces": {},
            "invitations": {
              "ttl": "7d"
            },
            "delegations": {
              "maxTtl": "30d",
              "tokenTtl": "15m"
            },
            "urls": {
              "signInLink": "https://app.example.com/sign-in",
              "invitationAccept": "https://app.example.com/invitations",
              "oauthReturn": ["https://app.example.com/auth/callback"]
            },
            "resourceTypes": {
              "report": {
                "actions": ["view", "edit", "export"]
              }
            },
            "roles": {
              "admin": {
                "name": "Admin",
                "scope": "workspace",
                "permissions": [
                  "identity.workspace:view",
                  "identity.member:*",
                  "identity.invitation:*",
                  "identity.resource_role:*",
                  "identity.grant:view"
                ]
              },
              "member": {
                "name": "Member",
                "scope": "workspace",
                "permissions": [
                  "identity.workspace:view",
                  "identity.member:view",
                  "identity.invitation:view",
                  "report:view"
                ]
              },
              "editor": {
                "name": "Editor",
                "scope": "resource",
                "assignableTo": ["principal", "guest"],
                "permissions": ["report:view", "report:edit"]
              },
              "support": {
                "name": "Support",
                "scope": "project",
                "permissions": ["report:view"]
              }
            },
            "entitlements": {
              "reports.export": {
                "description": "Export reports",
                "resourceType": "report"
              },
              "reports.schedule": {
                "description": "Schedule reports by email"
              }
            },
            "updatedAt": "2026-11-13T09:30:00.000Z",
            "updatedBy": "trusted_caller"
          }
        ]
      },
      "CodeRequested": {
        "description": "A code request's answer. It is the same whether or not the address gets a code.",
        "type": "object",
        "properties": {
          "verificationId": {
            "type": "string",
            "description": "Send it back with the code. A request for the same address before `resendAfter` runs out sends no new code and answers with this same ID."
          },
          "resendAfter": {
            "type": "number",
            "description": "Whole seconds until a request for the same address sends a new code. A request that sends one answers with the config's `signIn.emailCode.resendAfter` in seconds: `\"30s\"` answers `30`. A request within that window answers with the seconds left."
          }
        },
        "required": ["verificationId", "resendAfter"],
        "examples": [
          {
            "verificationId": "ver_01JDCXQVC1YRR68NC4NQ58DM0A",
            "resendAfter": 30
          }
        ]
      },
      "SessionGrant": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string",
            "description": "The bearer token. Shown once."
          },
          "session": {
            "$ref": "#/components/schemas/Session"
          },
          "principal": {
            "$ref": "#/components/schemas/Principal"
          },
          "signedUp": {
            "type": "boolean",
            "description": "True when this sign-in created the principal."
          }
        },
        "required": ["token", "session", "principal", "signedUp"],
        "examples": [
          {
            "token": "agp_st_…",
            "session": {
              "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
            },
            "principal": {
              "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"
            },
            "signedUp": false
          }
        ]
      },
      "OAuthStartResponse": {
        "type": "object",
        "properties": {
          "authorizeUrl": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string"
          }
        },
        "required": ["authorizeUrl", "state", "expiresAt"],
        "examples": [
          {
            "authorizeUrl": "https://id.twitch.tv/oauth2/authorize?client_id=your_client_id&response_type=code&scope=user%3Aread%3Aemail&state=…",
            "state": "oauth_state_…",
            "expiresAt": "2026-11-13T09:40:00.000Z"
          }
        ]
      },
      "OAuthCallbackResponse": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "purpose": {
                "const": "sign_in"
              },
              "connection": {
                "$ref": "#/components/schemas/Connection"
              },
              "token": {
                "type": "string",
                "description": "The bearer token. Shown once."
              },
              "session": {
                "$ref": "#/components/schemas/Session"
              },
              "principal": {
                "$ref": "#/components/schemas/Principal"
              },
              "signedUp": {
                "type": "boolean",
                "description": "True when this sign-in created the principal."
              }
            },
            "required": ["purpose", "token", "session", "principal", "signedUp"]
          },
          {
            "type": "object",
            "properties": {
              "purpose": {
                "const": "reauthorize"
              },
              "authorizeUrl": {
                "type": "string"
              },
              "state": {
                "type": "string"
              },
              "expiresAt": {
                "type": "string"
              }
            },
            "required": ["purpose", "authorizeUrl", "state", "expiresAt"]
          },
          {
            "type": "object",
            "properties": {
              "purpose": {
                "const": "link"
              },
              "identity": {
                "$ref": "#/components/schemas/Identity"
              },
              "principal": {
                "$ref": "#/components/schemas/Principal"
              }
            },
            "required": ["purpose", "identity", "principal"]
          },
          {
            "type": "object",
            "properties": {
              "purpose": {
                "const": "connect"
              },
              "connection": {
                "$ref": "#/components/schemas/Connection"
              }
            },
            "required": ["purpose", "connection"]
          }
        ],
        "examples": [
          {
            "purpose": "sign_in",
            "token": "agp_st_…",
            "session": {
              "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
            },
            "principal": {
              "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"
            },
            "signedUp": false
          }
        ]
      },
      "IntrospectResponse": {
        "type": "object",
        "properties": {
          "active": {
            "type": "boolean"
          },
          "credential": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "session"
                  },
                  "id": {
                    "type": "string",
                    "description": "A session ID, `ses_…`"
                  }
                },
                "required": ["kind", "id"]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "api_key"
                  },
                  "id": {
                    "type": "string",
                    "description": "An API key ID, `key_…`"
                  }
                },
                "required": ["kind", "id"]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "delegated_token"
                  },
                  "id": {
                    "type": "string",
                    "description": "A session ID, `ses_…`"
                  }
                },
                "required": ["kind", "id"]
              }
            ]
          },
          "actor": {
            "$ref": "#/components/schemas/Principal",
            "description": "The principal that holds the credential and makes requests with it."
          },
          "onBehalfOf": {
            "$ref": "#/components/schemas/Principal",
            "description": "The delegator, for a delegated token. Authority comes from it, within the delegation."
          },
          "delegation": {
            "$ref": "#/components/schemas/Delegation"
          },
          "restrictions": {
            "type": "object",
            "properties": {
              "workspaceIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "permissions": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": []
          },
          "session": {
            "$ref": "#/components/schemas/Session"
          }
        },
        "required": ["active"],
        "examples": [
          {
            "active": true,
            "credential": {
              "kind": "session",
              "id": "ses_01JD2EQP0GCGZMSCG7GMDVCFJ6"
            },
            "actor": {
              "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"
            },
            "session": {
              "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
            }
          }
        ]
      },
      "Principal": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A principal ID, `prn_…`"
          },
          "kind": {
            "type": "string",
            "enum": ["human", "guest", "agent", "service"],
            "description": "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."
          },
          "status": {
            "type": "string",
            "enum": ["active", "suspended", "deleted"]
          },
          "displayName": {
            "type": "string",
            "description": "A supplied name, 1 to 120 characters. Your app decides what to show when absent."
          },
          "avatarUrl": {
            "type": "string"
          },
          "projectRoles": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "description": {
            "type": "string"
          },
          "guest": {
            "type": "object",
            "properties": {
              "createdIp": {
                "type": "string"
              },
              "upgradedAt": {
                "type": "string",
                "format": "date-time"
              }
            },
            "required": []
          },
          "mergedInto": {
            "type": "string",
            "description": "A principal ID, `prn_…`"
          },
          "lastActiveAt": {
            "type": "string",
            "format": "date-time"
          },
          "externalRef": {
            "type": "string"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {}
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "type": "string",
            "description": "A principal ID, `prn_…`"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "suspendedAt": {
            "type": "string",
            "format": "date-time"
          },
          "deletedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "status",
          "projectRoles",
          "metadata",
          "createdAt",
          "updatedAt"
        ],
        "examples": [
          {
            "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"
          }
        ]
      },
      "Identity": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "An identity ID, `idn_…`"
          },
          "principalId": {
            "type": "string",
            "description": "A principal ID, `prn_…`"
          },
          "type": {
            "type": "string",
            "enum": ["email", "oauth"]
          },
          "provider": {
            "type": "string",
            "enum": ["email", "twitch"]
          },
          "subject": {
            "type": "string"
          },
          "verifiedAt": {
            "type": "string",
            "format": "date-time"
          },
          "profile": {
            "type": "object",
            "properties": {
              "login": {
                "type": "string"
              },
              "displayName": {
                "type": "string"
              },
              "email": {
                "type": "string"
              },
              "avatarUrl": {
                "type": "string"
              }
            },
            "required": []
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastUsedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "principalId",
          "type",
          "provider",
          "subject",
          "verifiedAt",
          "createdAt"
        ],
        "examples": [
          {
            "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"
          }
        ]
      },
      "Session": {
        "description": "A session as the API shows it: never with its token or hash.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A session ID, `ses_…`"
          },
          "kind": {
            "type": "string",
            "enum": ["direct", "delegated"]
          },
          "principalId": {
            "type": "string",
            "description": "Whose session it is: for a delegated session, the delegator."
          },
          "delegateId": {
            "type": "string",
            "description": "The delegate holding a delegated session."
          },
          "delegationId": {
            "type": "string",
            "description": "A delegation ID, `dlg_…`"
          },
          "authMethods": {
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "const": "email_code"
                },
                {
                  "type": "string",
                  "pattern": "^oauth:.*$"
                },
                {
                  "const": "api_key"
                },
                {
                  "const": "guest"
                }
              ]
            }
          },
          "client": {
            "type": "object",
            "properties": {
              "ip": {
                "type": "string"
              },
              "userAgent": {
                "type": "string"
              },
              "platform": {
                "type": "string"
              }
            },
            "required": []
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastSeenAt": {
            "type": "string",
            "format": "date-time"
          },
          "idleExpiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "revokedAt": {
            "type": "string",
            "format": "date-time"
          },
          "revokeReason": {
            "type": "string",
            "enum": [
              "sign_out",
              "self",
              "api_key_revoked",
              "principal_suspended",
              "identity_removed",
              "principal_deleted",
              "delegation_revoked",
              "upgraded",
              "merged"
            ]
          },
          "current": {
            "type": "boolean",
            "description": "True for the session the request was made with."
          }
        },
        "required": [
          "id",
          "kind",
          "principalId",
          "authMethods",
          "createdAt",
          "lastSeenAt",
          "idleExpiresAt",
          "expiresAt"
        ],
        "examples": [
          {
            "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
          }
        ]
      },
      "MergeGuestResponse": {
        "description": "What a merge answers with: the principal as it stands, the guest's ID, and what moved over.",
        "type": "object",
        "properties": {
          "principal": {
            "$ref": "#/components/schemas/Principal"
          },
          "guestId": {
            "type": "string",
            "description": "A principal ID, `prn_…`"
          },
          "moved": {
            "type": "object",
            "properties": {
              "grants": {
                "type": "number"
              },
              "resourceRoles": {
                "type": "number"
              }
            },
            "required": ["grants", "resourceRoles"]
          }
        },
        "required": ["principal", "guestId", "moved"],
        "examples": [
          {
            "principal": {
              "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"
            },
            "guestId": "prn_01JD8B49FTM5GZ9SVD3SRG7TKD",
            "moved": {
              "grants": 1,
              "resourceRoles": 0
            }
          }
        ]
      },
      "MergeAccountResponse": {
        "description": "What `POST /me/merge` answers with: the principal as it stands, the merged account's ID, and how much of each kind moved over.",
        "type": "object",
        "properties": {
          "principal": {
            "$ref": "#/components/schemas/Principal"
          },
          "mergedId": {
            "type": "string",
            "description": "A principal ID, `prn_…`"
          },
          "moved": {
            "type": "object",
            "properties": {
              "identities": {
                "type": "number"
              },
              "connections": {
                "type": "number"
              },
              "grants": {
                "type": "number"
              },
              "resourceRoles": {
                "type": "number"
              },
              "projectRoles": {
                "type": "number"
              },
              "workspaces": {
                "type": "number"
              }
            },
            "required": [
              "identities",
              "connections",
              "grants",
              "resourceRoles",
              "projectRoles",
              "workspaces"
            ]
          }
        },
        "required": ["principal", "mergedId", "moved"],
        "examples": [
          {
            "principal": {
              "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"
            },
            "mergedId": "prn_01JD9V3K7QH2M5X8R4T6W0B1CE",
            "moved": {
              "identities": 1,
              "connections": 1,
              "grants": 1,
              "resourceRoles": 0,
              "projectRoles": 0,
              "workspaces": 1
            }
          }
        ]
      },
      "ImportResponse": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "externalRef": {
                  "type": "string"
                },
                "principalId": {
                  "type": "string",
                  "description": "A principal ID, `prn_…`"
                },
                "outcome": {
                  "type": "string",
                  "enum": ["created", "existing", "failed"]
                },
                "error": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": ["code", "message"]
                }
              },
              "required": ["externalRef", "outcome"],
              "description": "One imported principal's outcome. A failed item names its error and leaves the rest of the batch alone."
            }
          },
          "principalIds": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "description": "A principal ID, `prn_…`"
            },
            "description": "`externalRef` to `principalId` for every item that did not fail."
          }
        },
        "required": ["results", "principalIds"],
        "examples": [
          {
            "results": [
              {
                "externalRef": "user_1001",
                "principalId": "prn_01JDSJ41R3JK54F6RKD4Y3J1GF",
                "outcome": "created"
              }
            ],
            "principalIds": {
              "user_1001": "prn_01JDSJ41R3JK54F6RKD4Y3J1GF"
            }
          }
        ]
      },
      "PrincipalCreated": {
        "type": "object",
        "properties": {
          "apiKey": {
            "$ref": "#/components/schemas/ApiKey"
          },
          "token": {
            "type": "string",
            "description": "The bearer token. Shown once."
          },
          "principal": {
            "$ref": "#/components/schemas/Principal"
          }
        },
        "required": ["apiKey", "token", "principal"],
        "examples": [
          {
            "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"
            }
          }
        ]
      },
      "ApiKeyCreated": {
        "type": "object",
        "properties": {
          "apiKey": {
            "$ref": "#/components/schemas/ApiKey"
          },
          "token": {
            "type": "string",
            "description": "The bearer token. Shown once."
          }
        },
        "required": ["apiKey", "token"],
        "examples": [
          {
            "apiKey": {
              "id": "key_01JD3F215PNGEK0WH9BSJZRD81",
              "principalId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
              "name": "Report assistant",
              "prefix": "agp_ak_acme_3f9a1c2b7d4e",
              "restrictions": {
                "workspaceIds": ["wsp_01JDGKQN2K4RF0M0Z2HBASFA62"],
                "permissions": ["report:view", "report:edit"]
              },
              "status": "active",
              "createdAt": "2026-11-06T16:45:00.000Z",
              "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
            },
            "token": "agp_ak_…"
          }
        ]
      },
      "ApiKey": {
        "description": "An API key as the API shows it: never with its secret or hash. `prefix` is the public part a holder sees on its copy.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "An API key ID, `key_…`"
          },
          "principalId": {
            "type": "string",
            "description": "A principal ID, `prn_…`"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "restrictions": {
            "type": "object",
            "properties": {
              "workspaceIds": {
                "type": "array",
                "items": {
                  "type": "string",
                  "description": "A workspace ID, `wsp_…`"
                }
              },
              "permissions": {
                "type": "array",
                "items": {
                  "type": "string",
                  "description": "A permission, such as `report:edit`"
                }
              }
            },
            "required": []
          },
          "status": {
            "type": "string",
            "enum": ["active", "revoked"]
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastUsedAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              {
                "const": "trusted_caller"
              }
            ]
          },
          "revokedAt": {
            "type": "string",
            "format": "date-time"
          },
          "revokedBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              {
                "const": "trusted_caller"
              }
            ]
          },
          "rotatedFrom": {
            "type": "string",
            "description": "An API key ID, `key_…`"
          },
          "graceEndsAt": {
            "type": "string",
            "format": "date-time",
            "description": "Set on a rotated key: it keeps working until then."
          }
        },
        "required": [
          "id",
          "principalId",
          "name",
          "prefix",
          "status",
          "createdAt",
          "createdBy"
        ],
        "examples": [
          {
            "id": "key_01JD3F215PNGEK0WH9BSJZRD81",
            "principalId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
            "name": "Report assistant",
            "prefix": "agp_ak_acme_3f9a1c2b7d4e",
            "restrictions": {
              "workspaceIds": ["wsp_01JDGKQN2K4RF0M0Z2HBASFA62"],
              "permissions": ["report:view", "report:edit"]
            },
            "status": "active",
            "createdAt": "2026-11-06T16:45:00.000Z",
            "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
          }
        ]
      },
      "Connection": {
        "description": "A connected account as the API shows it: never with its tokens.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A connection ID, `con_…`"
          },
          "principalId": {
            "type": "string",
            "description": "A principal ID, `prn_…`"
          },
          "providerKey": {
            "type": "string"
          },
          "subject": {
            "type": "string"
          },
          "identityId": {
            "type": "string",
            "description": "An identity ID, `idn_…`"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "accessTokenExpiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "string",
            "enum": ["active", "needs_reauth"]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastRefreshedAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastUsedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "principalId",
          "providerKey",
          "subject",
          "scopes",
          "status",
          "createdAt"
        ],
        "examples": [
          {
            "id": "con_01JDJGPK8BY9CQ8J097GQDBK74",
            "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
            "providerKey": "twitch",
            "subject": "91234567",
            "identityId": "idn_01JDG344JJGW867DQ6EJ5WGCY2",
            "scopes": ["user:read:email", "channel:read:subscriptions"],
            "accessTokenExpiresAt": "2026-11-13T13:30:00.000Z",
            "status": "active",
            "createdAt": "2026-11-03T08:20:00.000Z",
            "lastRefreshedAt": "2026-11-13T09:30:00.000Z"
          }
        ]
      },
      "ConnectionTokenResponse": {
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": ["accessToken", "scopes"],
        "examples": [
          {
            "accessToken": "provider_access_token_…",
            "expiresAt": "2026-11-13T13:30:00.000Z",
            "scopes": ["user:read:email", "channel:read:subscriptions"]
          }
        ]
      },
      "WorkspaceWithMembership": {
        "type": "object",
        "properties": {
          "workspace": {
            "$ref": "#/components/schemas/Workspace"
          },
          "membership": {
            "$ref": "#/components/schemas/Membership"
          }
        },
        "required": ["workspace"],
        "examples": [
          {
            "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"
            }
          }
        ]
      },
      "Workspace": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A workspace ID, `wsp_…`"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["active", "archived"]
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {}
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              {
                "const": "trusted_caller"
              }
            ]
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "archivedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "name",
          "status",
          "metadata",
          "createdAt",
          "createdBy",
          "updatedAt"
        ],
        "examples": [
          {
            "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": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A membership ID, `mem_…`"
          },
          "workspaceId": {
            "type": "string",
            "description": "A workspace ID, `wsp_…`"
          },
          "principalId": {
            "type": "string",
            "description": "A principal ID, `prn_…`"
          },
          "principalKind": {
            "type": "string",
            "enum": ["human", "guest", "agent", "service"],
            "description": "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."
          },
          "role": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["active", "suspended"]
          },
          "source": {
            "type": "string",
            "enum": ["creator", "invitation", "direct_add", "import"]
          },
          "invitationId": {
            "type": "string",
            "description": "An invitation ID, `inv_…`"
          },
          "addedBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              {
                "const": "trusted_caller"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "workspaceId",
          "principalId",
          "role",
          "status",
          "source",
          "createdAt",
          "updatedAt"
        ],
        "examples": [
          {
            "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"
          }
        ]
      },
      "InvitationCreated": {
        "type": "object",
        "properties": {
          "invitation": {
            "$ref": "#/components/schemas/Invitation"
          },
          "token": {
            "type": "string",
            "description": "The code channel's token, shown once."
          }
        },
        "required": ["invitation"],
        "examples": [
          {
            "invitation": {
              "id": "inv_01JD4S9TK4EQEZ4YB4S2GTG2BB",
              "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
              "role": "member",
              "channel": "email",
              "email": "grace@example.com",
              "openTo": ["principal"],
              "status": "pending",
              "invitedBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
              "createdAt": "2026-11-04T11:00:00.000Z",
              "expiresAt": "2026-11-11T11:00:00.000Z"
            }
          }
        ]
      },
      "Invitation": {
        "description": "An invitation as the API shows it: never with its token or hash.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "An invitation ID, `inv_…`"
          },
          "workspaceId": {
            "type": "string",
            "description": "A workspace ID, `wsp_…`"
          },
          "role": {
            "type": "string"
          },
          "channel": {
            "type": "string",
            "enum": ["email", "code"]
          },
          "email": {
            "type": "string"
          },
          "openTo": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": ["principal", "guest"],
              "description": "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."
            },
            "description": "Who may accept: `guest`, `principal` (any principal that is not a guest), or both. Without it, whoever the role is open to."
          },
          "status": {
            "type": "string",
            "enum": ["pending", "accepted", "revoked", "expired"]
          },
          "invitedBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              {
                "const": "trusted_caller"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "acceptedBy": {
            "type": "string",
            "description": "A principal ID, `prn_…`"
          },
          "acceptedAt": {
            "type": "string",
            "format": "date-time"
          },
          "revokedAt": {
            "type": "string",
            "format": "date-time"
          },
          "revokedBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              {
                "const": "trusted_caller"
              }
            ]
          }
        },
        "required": [
          "id",
          "workspaceId",
          "role",
          "channel",
          "status",
          "invitedBy",
          "createdAt",
          "expiresAt"
        ],
        "examples": [
          {
            "id": "inv_01JD4S9TK4EQEZ4YB4S2GTG2BB",
            "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
            "role": "member",
            "channel": "email",
            "email": "grace@example.com",
            "openTo": ["principal"],
            "status": "pending",
            "invitedBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
            "createdAt": "2026-11-04T11:00:00.000Z",
            "expiresAt": "2026-11-11T11:00:00.000Z"
          }
        ]
      },
      "InvitationPreviewResponse": {
        "type": "object",
        "properties": {
          "invitation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "An invitation ID, `inv_…`"
              },
              "role": {
                "type": "string"
              },
              "channel": {
                "type": "string",
                "enum": ["email", "code"]
              },
              "email": {
                "type": "string"
              },
              "openTo": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": ["principal", "guest"],
                  "description": "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."
                },
                "description": "Who may accept: `guest`, `principal` (any principal that is not a guest), or both. Without it, whoever the role is open to."
              },
              "status": {
                "type": "string",
                "enum": ["pending", "accepted", "revoked", "expired"]
              },
              "expiresAt": {
                "type": "string",
                "format": "date-time"
              }
            },
            "required": ["id", "role", "channel", "status", "expiresAt"]
          },
          "workspace": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "A workspace ID, `wsp_…`"
              },
              "name": {
                "type": "string"
              }
            },
            "required": ["id", "name"]
          },
          "invitedBy": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              "displayName": {
                "type": "string",
                "description": "A supplied name, 1 to 120 characters. Your app decides what to show when absent."
              },
              "avatarUrl": {
                "type": "string"
              }
            },
            "required": ["id"]
          }
        },
        "required": ["invitation", "workspace"],
        "examples": [
          {
            "invitation": {
              "id": "inv_01JD4S9TK4EQEZ4YB4S2GTG2BB",
              "role": "member",
              "channel": "email",
              "email": "grace@example.com",
              "openTo": ["principal"],
              "expiresAt": "2026-11-11T11:00:00.000Z",
              "status": "pending"
            },
            "workspace": {
              "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
              "name": "Acme"
            },
            "invitedBy": {
              "id": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
              "displayName": "Ada Lovelace"
            }
          }
        ]
      },
      "InvitationAccepted": {
        "type": "object",
        "properties": {
          "membership": {
            "$ref": "#/components/schemas/Membership"
          },
          "workspace": {
            "$ref": "#/components/schemas/Workspace"
          }
        },
        "required": ["membership", "workspace"],
        "examples": [
          {
            "membership": {
              "id": "mem_01JD4CX40XT3YPEZHJ8VY0RG03",
              "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
              "principalId": "prn_01JD1F7TG1SVVEHCFCS56KF78R",
              "principalKind": "human",
              "role": "member",
              "status": "active",
              "source": "invitation",
              "invitationId": "inv_01JD4S9TK4EQEZ4YB4S2GTG2BB",
              "createdAt": "2026-11-05T10:12:00.000Z",
              "updatedAt": "2026-11-05T10:12:00.000Z"
            },
            "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"
            }
          }
        ]
      },
      "ResourceRole": {
        "description": "A role held on one resource (ih_resource_roles).",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A resource role ID, `rro_…`"
          },
          "resource": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              },
              "id": {
                "type": "string"
              }
            },
            "required": ["type", "id"]
          },
          "workspaceId": {
            "type": "string",
            "description": "The resource's home workspace, if any. Assignments without one are managed by trusted callers."
          },
          "holder": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "principal"
                  },
                  "id": {
                    "type": "string",
                    "description": "A principal ID, `prn_…`"
                  }
                },
                "required": ["kind", "id"]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "all"
                  },
                  "of": {
                    "type": "string",
                    "enum": ["principal", "guest"],
                    "description": "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."
                  }
                },
                "required": ["kind", "of"]
              }
            ],
            "description": "A resource role's holder: a principal, every guest, or every principal that is not a guest; never a workspace."
          },
          "role": {
            "type": "string"
          },
          "assignedBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              {
                "const": "trusted_caller"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "resource",
          "holder",
          "role",
          "assignedBy",
          "createdAt"
        ],
        "examples": [
          {
            "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"
          }
        ]
      },
      "Bundle": {
        "description": "A named, editable set of entitlements (ih_bundles). Its key is its ID.",
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "entitlement": {
                  "type": "string"
                },
                "resource": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    }
                  },
                  "required": ["type", "id"]
                }
              },
              "required": ["entitlement"]
            }
          },
          "status": {
            "type": "string",
            "enum": ["active", "retired"],
            "description": "A retired bundle grants nothing; its grants stay as history."
          },
          "version": {
            "type": "number"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              {
                "const": "trusted_caller"
              }
            ]
          }
        },
        "required": [
          "key",
          "name",
          "items",
          "status",
          "version",
          "createdAt",
          "updatedAt",
          "updatedBy"
        ],
        "examples": [
          {
            "key": "pro",
            "name": "Pro",
            "items": [
              {
                "entitlement": "reports.export"
              },
              {
                "entitlement": "reports.schedule"
              }
            ],
            "status": "active",
            "version": 1,
            "createdAt": "2026-11-02T14:05:00.000Z",
            "updatedAt": "2026-11-02T14:05:00.000Z",
            "updatedBy": "trusted_caller"
          }
        ]
      },
      "Grant": {
        "description": "What a principal, a workspace, every guest, or every principal that is not a guest has been given (ih_grants). A grant past `expiresAt` stops counting at once; the sweep then marks it `expired` and emits the event.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A grant ID, `grt_…`"
          },
          "target": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "entitlement"
                  },
                  "entitlement": {
                    "type": "string"
                  },
                  "resource": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string"
                      },
                      "id": {
                        "type": "string"
                      }
                    },
                    "required": ["type", "id"]
                  }
                },
                "required": ["kind", "entitlement"]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "bundle"
                  },
                  "bundle": {
                    "type": "string"
                  }
                },
                "required": ["kind", "bundle"]
              }
            ]
          },
          "holder": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "principal"
                  },
                  "id": {
                    "type": "string",
                    "description": "A principal ID, `prn_…`"
                  }
                },
                "required": ["kind", "id"]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "workspace"
                  },
                  "id": {
                    "type": "string",
                    "description": "A workspace ID, `wsp_…`"
                  }
                },
                "required": ["kind", "id"]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "all"
                  },
                  "of": {
                    "type": "string",
                    "enum": ["principal", "guest"],
                    "description": "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."
                  }
                },
                "required": ["kind", "of"]
              }
            ]
          },
          "provenance": {
            "type": "object",
            "properties": {
              "source": {
                "type": "string",
                "description": "Your app's label for why the grant exists, 1 to 100 characters."
              },
              "reference": {
                "type": "string",
                "description": "Opaque, such as an order ID or an achievement ID."
              },
              "note": {
                "type": "string"
              }
            },
            "required": ["source"]
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {},
            "description": "Your app's data, at most 4 KB. IdentityHound answers with it as you sent it."
          },
          "startsAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "string",
            "enum": ["active", "revoked", "expired"]
          },
          "idempotencyKey": {
            "type": "string"
          },
          "grantedBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              {
                "const": "trusted_caller"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "revokedAt": {
            "type": "string",
            "format": "date-time"
          },
          "revokedBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              {
                "const": "trusted_caller"
              }
            ]
          },
          "revokeReason": {
            "type": "string"
          },
          "expiredAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "target",
          "holder",
          "provenance",
          "startsAt",
          "status",
          "idempotencyKey",
          "grantedBy",
          "createdAt"
        ],
        "examples": [
          {
            "id": "grt_01JD708CK3K0Y4F83NATYTFGW9",
            "target": {
              "kind": "bundle",
              "bundle": "pro"
            },
            "holder": {
              "kind": "workspace",
              "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
            },
            "provenance": {
              "source": "purchase",
              "reference": "order_1042"
            },
            "startsAt": "2026-11-13T09:30:00.000Z",
            "status": "active",
            "idempotencyKey": "order_1042",
            "grantedBy": "trusted_caller",
            "createdAt": "2026-11-13T09:30:00.000Z"
          }
        ]
      },
      "EntitlementCheckResponse": {
        "type": "object",
        "properties": {
          "held": {
            "type": "boolean"
          },
          "grant": {
            "$ref": "#/components/schemas/Grant"
          },
          "bundle": {
            "$ref": "#/components/schemas/Bundle"
          }
        },
        "required": ["held"],
        "examples": [
          {
            "held": true,
            "grant": {
              "id": "grt_01JD708CK3K0Y4F83NATYTFGW9",
              "target": {
                "kind": "bundle",
                "bundle": "pro"
              },
              "holder": {
                "kind": "workspace",
                "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
              },
              "provenance": {
                "source": "purchase",
                "reference": "order_1042"
              },
              "startsAt": "2026-11-13T09:30:00.000Z",
              "status": "active",
              "idempotencyKey": "order_1042",
              "grantedBy": "trusted_caller",
              "createdAt": "2026-11-13T09:30:00.000Z"
            },
            "bundle": {
              "key": "pro",
              "name": "Pro",
              "items": [
                {
                  "entitlement": "reports.export"
                },
                {
                  "entitlement": "reports.schedule"
                }
              ],
              "status": "active",
              "version": 1,
              "createdAt": "2026-11-02T14:05:00.000Z",
              "updatedAt": "2026-11-02T14:05:00.000Z",
              "updatedBy": "trusted_caller"
            }
          }
        ]
      },
      "EntitlementsResponse": {
        "type": "object",
        "properties": {
          "entitlements": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "entitlement": {
                  "type": "string"
                },
                "resource": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    }
                  },
                  "required": ["type", "id"]
                },
                "grantId": {
                  "type": "string",
                  "description": "A grant ID, `grt_…`"
                },
                "bundle": {
                  "type": "string"
                }
              },
              "required": ["entitlement", "grantId"],
              "description": "One entitlement a principal holds, with the grant and bundle it comes from."
            }
          }
        },
        "required": ["entitlements"],
        "examples": [
          {
            "entitlements": [
              {
                "entitlement": "reports.export",
                "grantId": "grt_01JD708CK3K0Y4F83NATYTFGW9",
                "bundle": "pro"
              },
              {
                "entitlement": "reports.schedule",
                "grantId": "grt_01JD708CK3K0Y4F83NATYTFGW9",
                "bundle": "pro"
              }
            ]
          }
        ]
      },
      "Delegation": {
        "description": "Permissions a delegator grants its delegate (ih_delegations). `permissions` are concrete, never wildcards, so they can be checked against what the delegator holds. `connections` names the provider keys the delegate may fetch the delegator's connected-account tokens for, which also needs `identity.connection:use` in `permissions`.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A delegation ID, `dlg_…`"
          },
          "delegatorId": {
            "type": "string",
            "description": "A principal ID, `prn_…`"
          },
          "delegateId": {
            "type": "string",
            "description": "A principal ID, `prn_…`"
          },
          "workspaceId": {
            "type": "string",
            "description": "A workspace ID, `wsp_…`"
          },
          "permissions": {
            "type": "array",
            "items": {
              "type": "string",
              "description": "A permission, such as `report:edit`"
            }
          },
          "connections": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "enum": ["requested", "active", "denied", "revoked", "expired"]
          },
          "reason": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              {
                "const": "trusted_caller"
              }
            ]
          },
          "requestedAt": {
            "type": "string",
            "format": "date-time"
          },
          "decidedAt": {
            "type": "string",
            "format": "date-time"
          },
          "decidedBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              {
                "const": "trusted_caller"
              }
            ]
          },
          "revokedAt": {
            "type": "string",
            "format": "date-time"
          },
          "revokedBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "A principal ID, `prn_…`"
              },
              {
                "const": "trusted_caller"
              }
            ]
          },
          "expiredAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "delegatorId",
          "delegateId",
          "permissions",
          "status",
          "expiresAt",
          "createdAt",
          "createdBy"
        ],
        "examples": [
          {
            "id": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME",
            "delegatorId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
            "delegateId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
            "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
            "permissions": ["report:view", "report:edit"],
            "status": "active",
            "reason": "Draft the weekly report",
            "expiresAt": "2026-12-13T09:30:00.000Z",
            "createdAt": "2026-11-13T09:30:00.000Z",
            "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
          }
        ]
      },
      "DelegatedToken": {
        "description": "The short-lived token the delegate uses to act for the delegator.",
        "type": "object",
        "properties": {
          "token": {
            "type": "string",
            "description": "The bearer token. Shown once."
          },
          "session": {
            "$ref": "#/components/schemas/Session"
          },
          "actor": {
            "$ref": "#/components/schemas/Principal",
            "description": "The delegate, which makes requests with the token."
          },
          "onBehalfOf": {
            "$ref": "#/components/schemas/Principal",
            "description": "The delegator the delegate acts for."
          },
          "delegation": {
            "$ref": "#/components/schemas/Delegation"
          }
        },
        "required": ["token", "session", "actor", "onBehalfOf", "delegation"],
        "examples": [
          {
            "token": "agp_dt_…",
            "session": {
              "id": "ses_01JD4TCTCH1J3DXJ3N1PVAXVX2",
              "kind": "delegated",
              "principalId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
              "delegateId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
              "delegationId": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME",
              "authMethods": ["api_key"],
              "createdAt": "2026-11-13T09:30:00.000Z",
              "lastSeenAt": "2026-11-13T09:30:00.000Z",
              "idleExpiresAt": "2026-11-13T09:45:00.000Z",
              "expiresAt": "2026-11-13T09:45:00.000Z"
            },
            "actor": {
              "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"
            },
            "onBehalfOf": {
              "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"
            },
            "delegation": {
              "id": "dlg_01JDQYPRQ3QP4QP62W3DQZ86ME",
              "delegatorId": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D",
              "delegateId": "prn_01JDWRHCP925GR1HC5AP0MCFKH",
              "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
              "permissions": ["report:view", "report:edit"],
              "status": "active",
              "reason": "Draft the weekly report",
              "expiresAt": "2026-12-13T09:30:00.000Z",
              "createdAt": "2026-11-13T09:30:00.000Z",
              "createdBy": "prn_01JDG9X6KH1ZEF2ZWP185VMW9D"
            }
          }
        ]
      },
      "CheckResponse": {
        "type": "object",
        "properties": {
          "allowed": {
            "type": "boolean"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string",
                "enum": ["project_role", "workspace_role", "resource_role"]
              },
              {
                "type": "string",
                "enum": [
                  "unknown_permission",
                  "principal_inactive",
                  "actor_inactive",
                  "delegation_missing",
                  "delegation_expired",
                  "delegation_scope",
                  "delegation_workspace",
                  "credential_restricted",
                  "no_access",
                  "workspace_archived",
                  "entitlement_missing"
                ]
              }
            ]
          },
          "matched": {
            "type": "object",
            "properties": {
              "role": {
                "type": "string"
              },
              "membershipId": {
                "type": "string",
                "description": "A membership ID, `mem_…`"
              },
              "resourceRoleId": {
                "type": "string",
                "description": "A resource role ID, `rro_…`"
              },
              "grantId": {
                "type": "string",
                "description": "A grant ID, `grt_…`"
              },
              "delegationId": {
                "type": "string",
                "description": "A delegation ID, `dlg_…`"
              }
            },
            "required": []
          },
          "configVersion": {
            "type": "number"
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "step": {
                  "type": "string"
                },
                "outcome": {
                  "type": "string",
                  "enum": ["pass", "fail", "skip"]
                },
                "detail": {
                  "type": "string"
                }
              },
              "required": ["step", "outcome"]
            }
          }
        },
        "required": ["allowed", "reason", "configVersion"],
        "examples": [
          {
            "allowed": true,
            "reason": "resource_role",
            "matched": {
              "role": "editor",
              "resourceRoleId": "rro_01JD2FKSRJGD9ZJD5JHCA24JM8"
            },
            "configVersion": 3
          }
        ]
      },
      "CheckBatchResponse": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CheckResponse"
            }
          }
        },
        "required": ["results"],
        "examples": [
          {
            "results": [
              {
                "allowed": true,
                "reason": "resource_role",
                "matched": {
                  "role": "editor",
                  "resourceRoleId": "rro_01JD2FKSRJGD9ZJD5JHCA24JM8"
                },
                "configVersion": 3
              },
              {
                "allowed": false,
                "reason": "entitlement_missing",
                "configVersion": 3
              }
            ]
          }
        ]
      },
      "PermissionsResponse": {
        "type": "object",
        "properties": {
          "permissions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "configVersion": {
            "type": "number"
          }
        },
        "required": ["permissions", "configVersion"],
        "examples": [
          {
            "permissions": ["report:view", "report:edit"],
            "configVersion": 3
          }
        ]
      },
      "EventsResponse": {
        "type": "object",
        "properties": {
          "events": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "A plain ULID, unique to the event."
                },
                "seq": {
                  "type": "number",
                  "description": "The event's place in the project's feed, from 1. Pass it as `after` to read the events after it."
                },
                "specversion": {
                  "const": "1.0"
                },
                "type": {
                  "type": "string",
                  "description": "The full type, `tools.agentpost.identity.<event>`."
                },
                "source": {
                  "const": "/identityhound"
                },
                "subject": {
                  "type": "string",
                  "description": "The record the event is about."
                },
                "time": {
                  "type": "string",
                  "format": "date-time",
                  "description": "When the change was made."
                },
                "datacontenttype": {
                  "const": "application/json"
                },
                "data": {
                  "type": "object",
                  "properties": {
                    "context": {
                      "type": "object",
                      "properties": {
                        "actor": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "description": "A principal ID, `prn_…`"
                                },
                                {
                                  "const": "trusted_caller"
                                },
                                {
                                  "const": "anonymous"
                                }
                              ]
                            }
                          },
                          "required": ["id"],
                          "description": "Who made the request with its own credential: a principal's ID, `trusted_caller` for your server's secret key, or `anonymous` before sign-in."
                        },
                        "onBehalfOf": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "description": "A principal ID, `prn_…`"
                            }
                          },
                          "required": ["id"],
                          "description": "The delegator, when the actor acted under a delegation."
                        },
                        "delegationId": {
                          "type": "string",
                          "description": "The delegation the actor acted under, with a delegated token."
                        },
                        "via": {
                          "type": "string",
                          "enum": [
                            "session",
                            "api_key",
                            "delegated_token",
                            "trusted_caller",
                            "system"
                          ],
                          "description": "How the actor called: with a session, an API key, a delegated token, or your server's secret key; `system` for IdentityHound's own changes, such as an expiry sweep."
                        }
                      },
                      "required": ["actor", "via"],
                      "description": "Who made the change, and for whom."
                    },
                    "workspaceId": {
                      "type": "string",
                      "description": "The workspace the change is in, when it is in one."
                    }
                  },
                  "required": ["context"],
                  "additionalProperties": {}
                }
              },
              "required": [
                "id",
                "seq",
                "specversion",
                "type",
                "source",
                "time",
                "datacontenttype",
                "data"
              ],
              "description": "One change-feed record: CloudEvents 1.0, structured JSON, as every Agentpost service's feed has it. A time is `T`: `string` on the wire, `Date` in process."
            }
          },
          "next": {
            "type": "number",
            "description": "Pass as `after` to continue. Always present. A full page gives its last event's `seq`. A shorter page has caught up, so it gives the newest `seq` read, past any events a `types` filter skipped; `after=latest` gives the newest `seq`."
          }
        },
        "required": ["events", "next"],
        "examples": [
          {
            "events": [
              {
                "id": "01JDGKQN2M8X4C6V0B3N5T7R9W",
                "seq": 1042,
                "specversion": "1.0",
                "type": "tools.agentpost.identity.membership.added",
                "source": "/identityhound",
                "subject": "mem_01JD4CX40XT3YPEZHJ8VY0RG03",
                "time": "2026-11-05T10:12:00.000Z",
                "datacontenttype": "application/json",
                "data": {
                  "context": {
                    "actor": {
                      "id": "prn_01JD1F7TG1SVVEHCFCS56KF78R"
                    },
                    "via": "session"
                  },
                  "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                  "membershipId": "mem_01JD4CX40XT3YPEZHJ8VY0RG03",
                  "principalId": "prn_01JD1F7TG1SVVEHCFCS56KF78R",
                  "principalKind": "human",
                  "role": "member"
                }
              }
            ],
            "next": 1042
          }
        ]
      },
      "Error": {
        "description": "The body of every error. Act on `error.code`: each code has an entry on [IdentityHound errors](https://agentpost.tools/docs/identityhound/errors).",
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "What to act on. It never changes for a given error. Each error response lists the codes it can carry."
              },
              "message": {
                "type": "string",
                "description": "What went wrong, for humans. It may change."
              },
              "details": {
                "description": "What the code needs, when it needs more, such as `issues` for `invalid_request`."
              },
              "docs": {
                "type": "string",
                "format": "uri",
                "description": "The code’s entry on the errors page."
              }
            },
            "required": ["code", "message", "docs"]
          }
        },
        "required": ["error"]
      }
    },
    "securitySchemes": {
      "secretKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "sk_…",
        "description": "Your project's secret key, sent from your server. It is the trusted caller, and it names your project for the operations anyone may call."
      },
      "publishableKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "pk_…",
        "description": "Your project's publishable key, sent from a browser at one of the key's allowed origins, or from a native app when the key allows native apps. It reaches only the operations that start a session and an invitation's preview."
      },
      "sessionToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "agp_st_…",
        "description": "A signed-in principal's session token."
      },
      "userToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ut_…",
        "description": "A user token, for a signed-in principal."
      },
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "agp_ak_…",
        "description": "A principal's API key."
      },
      "delegatedToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "agp_dt_…",
        "description": "A delegated token, with which it acts for a principal through a delegation."
      }
    }
  }
}
