{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cosuno/json-schema/cosuno-update-user-input-schema.json",
  "title": "UpdateUserInput",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cosuno-users-api-openapi.yml#/components/schemas/UpdateUserInput",
  "allOf": [
    {
      "$ref": "#/$defs/Partial_UserBase_"
    },
    {
      "properties": {
        "status": {
          "$ref": "#/$defs/Extract_USER_STATUS.active-or-inactive-or-invited-or-inviteCanceled_",
          "description": "New status for the user. Only the following transitions are allowed:\n- `active` → `inactive` (deactivate an active user)\n- `inactive` → `active` (reactivate a deactivated user)\n- `invited` → `inviteCanceled` (cancel a pending invitation)\n- `inviteCanceled` → `invited` (restore a cancelled invitation)"
        }
      },
      "type": "object"
    },
    {
      "anyOf": [
        {
          "properties": {
            "type": {
              "$ref": "#/$defs/PRINCIPAL_USER_TYPE",
              "description": "Built-in account type to assign to the user."
            }
          },
          "type": "object"
        },
        {
          "properties": {
            "customUserRoleId": {
              "type": "string",
              "description": "ID of the custom user role to assign. Obtainable via `GET /users/custom-types`."
            },
            "type": {
              "$ref": "#/$defs/CUSTOM_USER_TYPE",
              "description": "Indicates that a custom account type is being assigned; `customUserRoleId` must also be provided."
            }
          },
          "required": [
            "customUserRoleId",
            "type"
          ],
          "type": "object"
        }
      ]
    }
  ],
  "$defs": {
    "CUSTOM_USER_TYPE": {
      "type": "string",
      "enum": [
        "custom"
      ]
    },
    "Extract_USER_STATUS.active-or-inactive-or-invited-or-inviteCanceled_": {
      "type": "string",
      "enum": [
        "invited",
        "inviteCanceled",
        "active",
        "inactive"
      ],
      "description": "Extract from T those types that are assignable to U"
    },
    "PRINCIPAL_USER_TYPE": {
      "enum": [
        "administrator",
        "guest",
        "collaborator",
        "manager"
      ],
      "type": "string"
    },
    "Partial_UserBase_": {
      "properties": {
        "email": {
          "type": "string",
          "description": "Email address of the user. Also used as their login identifier.",
          "format": "email",
          "maxLength": 200
        },
        "firstName": {
          "type": "string",
          "description": "Given name of the user.",
          "maxLength": 100
        },
        "lastName": {
          "type": "string",
          "description": "Family name of the user.",
          "maxLength": 100
        }
      },
      "type": "object",
      "description": "Make all properties in T optional"
    }
  }
}