# Remove Member

`DELETE /v1/members/{user_id}`

Take a person's role on one workspace away (they keep what the
organization gives them), or remove them from the organization. Needs
``members:write``. A key never removes its own creator from the
organization: leaving one takes a signed-in session.

- Base URL: `https://junction-api.qualiastudios.dev`
- Authentication: an API key in the `X-API-Key` header, or `Authorization: Bearer …`

## Parameters

- `user_id` (path, string (uuid), required)
- `project_id` (query, string | null (uuid)): A workspace of the organization; omit it for the organization itself. A workspace key names its own workspace.
- `keep` (query, array of string (uuid)): Removing from the organization: the workspaces they stay a guest of, at the role they hold there

## Responses

- `200` The change and what they keep: `application/json` `RoleChange`
- `400` Refused by the role rules: `application/json` `ErrorResponse`
- `401` Invalid or missing API key: `application/json` `ErrorResponse`
- `403` The key lacks members:write, or its creator may not give or take this role here (nobody grants above their own role): `application/json` `ErrorResponse`
- `404` Not found or not readable: `application/json` `ErrorResponse`
- `409` The organization's last owner stays: `application/json` `ErrorResponse`
- `422` Validation Error: `application/json` `HTTPValidationError`

## Schemas

```yaml
RoleChange:
  properties:
    space_id:
      type: string
      format: uuid
      description: The space the role is on
    kind:
      type: string
      enum:
        - organization
        - workspace
    name:
      type: string
    slug:
      type:
        - string
        - "null"
    root_id:
      description: Its organization
      format: uuid
      type:
        - string
        - "null"
    parent_id:
      format: uuid
      type:
        - string
        - "null"
    user:
      $ref: "#/components/schemas/GrantSubject"
    role:
      description: The role granted here now; null once removed
      nullable: true
      type: string
      enum:
        - viewer
        - contributor
        - admin
        - owner
    from:
      description: The role granted here before
      nullable: true
      type: string
      enum:
        - viewer
        - contributor
        - admin
        - owner
    changed:
      type: boolean
      description: False when the role was already that
    effective:
      description: The role they hold here now, inherited or not; null when they hold none
      nullable: true
      allOf:
        - $ref: "#/components/schemas/EffectiveRole"
    kept:
      description: "Removed from the organization: the workspaces they stay a guest of"
      nullable: true
      items:
        $ref: "#/components/schemas/KeptWorkspace"
      type: array
  type: object
  required:
    - space_id
    - kind
    - name
    - user
    - changed
  title: RoleChange
  description: What setting or removing a role did.
GrantSubject:
  properties:
    user_id:
      type: string
      format: uuid
    email:
      type:
        - string
        - "null"
    display_name:
      type:
        - string
        - "null"
    username:
      type:
        - string
        - "null"
  type: object
  required:
    - user_id
  title: GrantSubject
EffectiveRole:
  properties:
    role:
      type: string
      enum:
        - viewer
        - contributor
        - admin
        - owner
    inherited:
      type: boolean
    granted_on:
      $ref: "#/components/schemas/SpaceRef"
  type: object
  required:
    - role
    - inherited
    - granted_on
  title: EffectiveRole
SpaceRef:
  properties:
    space_id:
      type: string
      format: uuid
    kind:
      type: string
      enum:
        - organization
        - workspace
    name:
      type: string
    slug:
      type:
        - string
        - "null"
    icon:
      description: A workspace's icon; null for none
      type:
        - string
        - "null"
  type: object
  required:
    - space_id
    - kind
    - name
  title: SpaceRef
  description: Enough of a space to name it.
KeptWorkspace:
  properties:
    space_id:
      type: string
      format: uuid
    name:
      type:
        - string
        - "null"
    role:
      nullable: true
      type: string
      enum:
        - viewer
        - contributor
        - admin
        - owner
  type: object
  required:
    - space_id
  title: KeptWorkspace
ErrorResponse:
  properties:
    detail:
      type: string
      description: Error message describing what went wrong
  type: object
  required:
    - detail
  title: ErrorResponse
  description: Standard error response.
HTTPValidationError:
  properties:
    detail:
      items:
        $ref: "#/components/schemas/ValidationError"
      type: array
  type: object
  title: HTTPValidationError
ValidationError:
  properties:
    loc:
      items:
        type:
          - string
          - integer
      type: array
      title: Location
    msg:
      type: string
      title: Message
    type:
      type: string
      title: Error Type
    input: {}
    ctx:
      type: object
      title: Context
  type: object
  required:
    - loc
    - msg
    - type
  title: ValidationError
```
