{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cosuno/json-schema/cosuno-create-invited-user-input-schema.json",
  "title": "CreateInvitedUserInput",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cosuno-users-api-openapi.yml#/components/schemas/CreateInvitedUserInput",
  "allOf": [
    {
      "$ref": "#/$defs/UserBase"
    },
    {
      "anyOf": [
        {
          "properties": {
            "officeIds": {
              "items": {
                "type": "string"
              },
              "type": "array",
              "description": "IDs of the offices the new user should have access to. If omitted, the user gets access to all offices."
            },
            "type": {
              "$ref": "#/$defs/PRINCIPAL_USER_TYPE.administrator",
              "description": "Built-in administrator account type. Administrators have access to all offices, so `officeIds` is optional."
            }
          },
          "required": [
            "type"
          ],
          "type": "object"
        },
        {
          "properties": {
            "officeIds": {
              "items": {
                "type": "string"
              },
              "type": "array",
              "description": "IDs of the offices the new user should have access to.",
              "minItems": 1
            },
            "type": {
              "anyOf": [
                {
                  "$ref": "#/$defs/PRINCIPAL_USER_TYPE.guest"
                },
                {
                  "$ref": "#/$defs/PRINCIPAL_USER_TYPE.manager"
                },
                {
                  "$ref": "#/$defs/PRINCIPAL_USER_TYPE.collaborator"
                }
              ],
              "description": "Built-in non-administrator account type. Requires at least one office assignment via `officeIds`."
            }
          },
          "required": [
            "officeIds",
            "type"
          ],
          "type": "object"
        },
        {
          "properties": {
            "officeIds": {
              "items": {
                "type": "string"
              },
              "type": "array",
              "description": "IDs of the offices the new user should have access to.",
              "minItems": 1
            },
            "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": [
            "officeIds",
            "customUserRoleId",
            "type"
          ],
          "type": "object"
        }
      ]
    }
  ],
  "$defs": {
    "CUSTOM_USER_TYPE": {
      "type": "string",
      "enum": [
        "custom"
      ]
    },
    "PRINCIPAL_USER_TYPE.administrator": {
      "enum": [
        "administrator"
      ],
      "type": "string"
    },
    "PRINCIPAL_USER_TYPE.collaborator": {
      "enum": [
        "collaborator"
      ],
      "type": "string"
    },
    "PRINCIPAL_USER_TYPE.guest": {
      "enum": [
        "guest"
      ],
      "type": "string"
    },
    "PRINCIPAL_USER_TYPE.manager": {
      "enum": [
        "manager"
      ],
      "type": "string"
    },
    "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
        }
      },
      "required": [
        "email"
      ],
      "type": "object",
      "additionalProperties": false
    }
  }
}