# Remove a person

POST

/v1/identity/users/{userId}/unregister

```sh
curl --request POST \
  --url https://example.com/v1/identity/users/example/unregister \
  --header 'Authorization: Bearer <token>'
```

Removes a person from the workspace, in one step: they’re marked removed (`unregisteredAt`; their record stays, so their history still says who they were), every API key and session of theirs is revoked, every grant and membership they hold is taken away, and every connection they own is removed (`owner-removed`, withdrawn at its app where the app allows), all before it answers. Their keys get `401` at once. Their email is free again: adding it makes a new person. Removing someone already removed takes what their removal left (one that stopped part-way, or one on an earlier version that kept their connections), and otherwise changes nothing. Refused for yourself, the deployment’s seed user, and someone the server’s `KINDGI_ADMIN_EMAILS` names, whom the next start would add back (`identity-user-unregister-refused`, `details.reason` `listed-admin`: take the address off the list and restart first), and for the only tenant admin (`last-tenant-admin`). Tenant admins only. Mounted when the identity directory can remove people.

## Authorizations

- **[bearerAuth](https://docs.kindgi.com/v0.8.0/reference/api.md#bearerauth)**

## Parameters

### Path Parameters

**userId**

required

string

\>= 1 characters

### Header Parameters

**Idempotency-Key**

string

\>= 1 characters

Caller-supplied idempotency key, scoped to the caller: the same key from someone else in the workspace is their own request (from 0.1.5). Retries with the same key return the original response byte-identical (per `docs/API-ROUTE-CONVENTIONS.md` §3.1). A retry sent while the first request still runs is answered `409 idempotency-key-in-flight` with `Retry-After`, on a runtime whose store holds keys (from 0.1.5); retry after it, and you get the first request’s answer. An answer that carries a secret (a new API key or public run token, a session token, a generated signing secret) isn’t kept: a retry gets `409 idempotency-key-replay-withheld`, with the first request’s status and when it succeeded (from 0.1.5). A request whose key store can’t be read before it runs is answered `503 idempotency-store-unavailable` with `Retry-After`: nothing ran, so retry with the same key (from 0.3.0).

## Responses

### 200

The removed person, and what removing them took away.

application/json

A removed person, and what removing them took away (each 0 when nothing of theirs was left to take).

object

**user**

required

Workspace-scoped user record (admin plane). `primaryEmail` may be redacted on the wire based on workspace policy (the routes treat it as opaque). `metadata` is free-form JSON — deployments carry IdP claims / provisioning source / roles here.

object

**userId**

required

string

**tenantId**

required

string format: uuid

**primaryEmail**

string

**displayName**

string

**createdAt**

required

string format: date-time

**lastActiveAt**

string format: date-time

**unregisteredAt**

When they were removed from the workspace (`POST /v1/identity/users/{userId}/unregister`); absent while they are here.

string format: date-time

**invite**

Their invitation, while they haven’t signed in: absent once they have, for people added without an email, and for people added before invitations (from 0.1.9).

object

**state**

required

string

Allowed values: pending expired

**expiresAt**

required

string format: date-time

**sentAt**

When it was last emailed; absent when it never was.

string format: date-time

**firstSignedInAt**

Their first sign-in that made a session. Absent before it, and for people who last signed in before it was kept (from 0.1.9).

string format: date-time

**createdBy**

Who added them: `user:<id>` (a tenant admin) or `service_account:<id>`; `identity_provider:<providerId>` for someone who joined by domain through that identity provider, or `email_domain:<domain>` through one of the workspace’s allowed domains; `site:<siteId>` for a person a site signs in. Ids only, never an email. Absent for the seed user, and from a runtime that doesn’t keep it.

string

\>= 1 characters

**metadata**

object

**_key_**

additional properties

any

**grants**

The person’s grants: only on `GET /v1/identity/users?include=grants`, and only from a runtime that reads grants.

object

**userId**

required

string

**tenantAdmin**

Whether the person is a tenant admin. Absent when the runtime has no authorization store: nothing grants it then.

boolean

**tenantAdminFromSetting**

Whether the running server’s `KINDGI_ADMIN_EMAILS` names the person: they’re a tenant admin at every start, and taking tenant admin from them, or removing them, answers 409 `listed-admin` until the address is off the list. Absent when the runtime doesn’t report it.

boolean

**tenantMember**

Whether the person is a tenant member: they read the workspace’s settings (providers, policies, adapters, signing keys, deployments), not its projects. A person is one from being added. Absent when the runtime has no authorization store, or doesn’t report it.

boolean

**projects**

required

Direct project memberships.

Array\<object>

A person’s direct role on a project.

object

**projectId**

required

string

**role**

required

Role on a project, as read. `member` is only read, on a role given before it was retired: it grants what `viewer` does, and writes refuse it.

string

Allowed values: viewer runner editor owner admin member

**teams**

required

Team memberships.

Array\<object>

A person’s role in a team.

object

**teamId**

required

string

**role**

required

Role on a team membership.

string

Allowed values: member admin

**reviewer**

A person’s active entry on the reviewer roster.

object

**role**

required

Reviewer role class. Hierarchy: standard < senior < admin.

string

Allowed values: standard senior admin

**capabilities**

The capabilities the person holds, such as `env:write` or `signing-keys:write`. Absent when the runtime doesn’t report them: unknown, not none.

Array\<string>

**keysRevoked**

required

integer

**mintedKeysRevoked**

The keys minted with theirs, and with those in turn, revoked with them, whoever they act for. Not in `keysRevoked`. Absent where the key store doesn’t record which key minted which.

integer

**sessionsRevoked**

required

integer

**grantsRemoved**

required

integer

##### Example

```json
{
  "user": {
    "invite": {
      "state": "pending"
    },
    "grants": {
      "projects": [
        {
          "role": "viewer"
        }
      ],
      "teams": [
        {
          "role": "member"
        }
      ],
      "reviewer": {
        "role": "standard"
      }
    }
  }
}
```

### 400

Malformed request body.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 401

Missing / malformed / expired / revoked bearer token.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 403

Not a tenant admin.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 404

No user with that id under this workspace (`identity-user-not-found`).

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 409

Yourself, the seed user or a person `KINDGI_ADMIN_EMAILS` names (`identity-user-unregister-refused`, `details.reason`), the only tenant admin (`last-tenant-admin`), or an idempotency conflict. Or `idempotency-key-in-flight` (with `Retry-After`): a request with the same `Idempotency-Key` still runs, so this one wasn’t run; send it again after `Retry-After` to get that request’s answer.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

#### Headers

**Retry-After**

integer

\>= 1

Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.

### 429

`rate-limit-exceeded` with `details.limit: "api-requests"`, on a runtime that sets workspace limits (Kindgi Cloud): this workspace’s limit on API requests a minute is reached, so the request wasn’t run; `Retry-After` says when to send it again.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

#### Headers

**Retry-After**

integer

\>= 1

Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.

### 500

Server error (unmapped domain code or framework crash).

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 503

The `Idempotency-Key` store (`idempotency-store-unavailable`) or the authorization store (`authz-backend-unavailable`) couldn’t be reached before the request ran, or the database was too busy for its authorization check (`database-busy`), so nothing was changed; `Retry-After` (whole seconds) says when to try again with the same key.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

#### Headers

**Retry-After**

integer

\>= 1

Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.

## See also

- [`GET /v1/identity/users`: List users in the workspace](https://docs.kindgi.com/v0.8.0/reference/api/operations/identityuserslist.md)
- [`POST /v1/identity/users`: Add a person](https://docs.kindgi.com/v0.8.0/reference/api/operations/identityuserscreate.md)
- [`GET /v1/identity/users/{userId}`: Get a user by id](https://docs.kindgi.com/v0.8.0/reference/api/operations/identityusersget.md)
- [`GET /v1/identity/users/{userId}/sessions`: List active sessions for a user](https://docs.kindgi.com/v0.8.0/reference/api/operations/identityuserslistsessions.md)
- [Kindgi 0.7.0](https://docs.kindgi.com/v0.8.0/releases/0.7.0.md)
- [Error code `authz-backend-unavailable`](https://docs.kindgi.com/v0.8.0/reference/errors.md#authz-backend-unavailable)
- [Error code `database-busy`](https://docs.kindgi.com/v0.8.0/reference/errors.md#database-busy)
- [Error code `idempotency-key-in-flight`](https://docs.kindgi.com/v0.8.0/reference/errors.md#idempotency-key-in-flight)
- [Error code `idempotency-store-unavailable`](https://docs.kindgi.com/v0.8.0/reference/errors.md#idempotency-store-unavailable)
- [Error code `identity-user-not-found`](https://docs.kindgi.com/v0.8.0/reference/errors.md#identity-user-not-found)
- [Error code `identity-user-unregister-refused`](https://docs.kindgi.com/v0.8.0/reference/errors.md#identity-user-unregister-refused)
- [Error code `last-tenant-admin`](https://docs.kindgi.com/v0.8.0/reference/errors.md#last-tenant-admin)
- [Error code `rate-limit-exceeded`](https://docs.kindgi.com/v0.8.0/reference/errors.md#rate-limit-exceeded)
- [Every error code](https://docs.kindgi.com/v0.8.0/reference/errors.md)
