{
  "asyncapi": "3.0.0",
  "info": {
    "title": "core/users",
    "version": ""
  },
  "channels": {
    "systemEventsUsers": {
      "address": "system-events.users",
      "messages": {
        "coreUserCreated": {
          "$ref": "#/components/messages/users.coreUserCreated"
        },
        "coreUserDeleted": {
          "$ref": "#/components/messages/users.coreUserDeleted"
        },
        "coreUserProvisioned": {
          "$ref": "#/components/messages/users.coreUserProvisioned"
        },
        "coreUserUpdated": {
          "$ref": "#/components/messages/users.coreUserUpdated"
        }
      }
    }
  },
  "operations": {
    "coreUserCreated": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/systemEventsUsers"
      },
      "messages": [
        {
          "$ref": "#/channels/systemEventsUsers/messages/coreUserCreated"
        }
      ]
    },
    "coreUserDeleted": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/systemEventsUsers"
      },
      "messages": [
        {
          "$ref": "#/channels/systemEventsUsers/messages/coreUserDeleted"
        }
      ]
    },
    "coreUserProvisioned": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/systemEventsUsers"
      },
      "messages": [
        {
          "$ref": "#/channels/systemEventsUsers/messages/coreUserProvisioned"
        }
      ]
    },
    "coreUserUpdated": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/systemEventsUsers"
      },
      "messages": [
        {
          "$ref": "#/channels/systemEventsUsers/messages/coreUserUpdated"
        }
      ]
    }
  },
  "components": {
    "messages": {
      "users.coreUserCreated": {
        "name": "com.qlik.core.user.created",
        "tags": [
          {
            "name": "users"
          }
        ],
        "title": "User created",
        "payload": {
          "type": "object",
          "allOf": [
            {
              "$ref": "#/components/schemas/cloudEventsContextAttributes"
            },
            {
              "$ref": "#/components/schemas/cloudEventsQlikExtensionsAttributes"
            },
            {
              "type": "object",
              "properties": {
                "data": {
                  "type": "object",
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/user"
                    },
                    {
                      "$ref": "#/components/schemas/botUser"
                    }
                  ],
                  "examples": [],
                  "description": "The event data payload containing created user details. The payload conforms to the `user` schema for human users, or the `botUser` schema for bot (service) accounts."
                },
                "type": {
                  "type": "string",
                  "default": "com.qlik.core.user.created",
                  "description": "The type of the event."
                }
              }
            }
          ]
        },
        "description": "Published when a new user is created.",
        "x-qlik-stability": "stable",
        "x-qlik-visibility": "public",
        "x-qlik-deprecated": false
      },
      "users.coreUserDeleted": {
        "name": "com.qlik.core.user.deleted",
        "tags": [
          {
            "name": "users"
          }
        ],
        "title": "User deleted",
        "payload": {
          "type": "object",
          "allOf": [
            {
              "$ref": "#/components/schemas/cloudEventsContextAttributes"
            },
            {
              "$ref": "#/components/schemas/cloudEventsQlikExtensionsAttributes"
            },
            {
              "type": "object",
              "properties": {
                "data": {
                  "type": "object",
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/user"
                    },
                    {
                      "$ref": "#/components/schemas/botUser"
                    }
                  ],
                  "examples": [],
                  "description": "The event data payload containing deleted user details. The payload conforms to the `user` schema for human users, or the `botUser` schema for bot (service) accounts."
                },
                "type": {
                  "type": "string",
                  "default": "com.qlik.core.user.deleted",
                  "description": "The type of the event."
                }
              }
            }
          ]
        },
        "description": "Published when a user is deleted.",
        "x-qlik-stability": "stable",
        "x-qlik-visibility": "public",
        "x-qlik-deprecated": false
      },
      "users.coreUserProvisioned": {
        "name": "com.qlik.core.user.provisioned",
        "tags": [
          {
            "name": "users"
          }
        ],
        "title": "User provisioned",
        "payload": {
          "type": "object",
          "allOf": [
            {
              "$ref": "#/components/schemas/cloudEventsContextAttributes"
            },
            {
              "$ref": "#/components/schemas/cloudEventsQlikExtensionsAttributes"
            },
            {
              "type": "object",
              "properties": {
                "data": {
                  "$ref": "#/components/schemas/provisionedUser"
                },
                "type": {
                  "type": "string",
                  "default": "com.qlik.core.user.provisioned",
                  "description": "The type of the event."
                }
              }
            }
          ]
        },
        "description": "Published when a new user is provisioned by an IdP.",
        "x-qlik-stability": "stable",
        "x-qlik-visibility": "public",
        "x-qlik-deprecated": false
      },
      "users.coreUserUpdated": {
        "name": "com.qlik.core.user.updated",
        "tags": [
          {
            "name": "users"
          }
        ],
        "title": "User updated",
        "payload": {
          "type": "object",
          "allOf": [
            {
              "$ref": "#/components/schemas/cloudEventsContextAttributes"
            },
            {
              "$ref": "#/components/schemas/cloudEventsQlikExtensionsAttributes"
            },
            {
              "type": "object",
              "properties": {
                "data": {
                  "type": "object",
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/updateObject"
                    },
                    {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/user"
                        },
                        {
                          "$ref": "#/components/schemas/botUser"
                        }
                      ]
                    }
                  ],
                  "examples": [],
                  "description": "The event data payload containing updated user details. It combines the `_updates` change set (see the `updateObject` schema) with the updated user record, which conforms to the `user` schema for human users, or the `botUser` schema for bot (service) accounts."
                },
                "type": {
                  "type": "string",
                  "default": "com.qlik.core.user.updated",
                  "description": "The type of the event."
                }
              }
            }
          ]
        },
        "description": "Published when a user is updated.",
        "x-qlik-stability": "stable",
        "x-qlik-visibility": "public",
        "x-qlik-deprecated": false
      }
    },
    "schemas": {
      "assignedGroups": {
        "type": "array",
        "items": {
          "type": "object",
          "required": [
            "id",
            "name"
          ],
          "properties": {
            "id": {
              "type": "string",
              "format": "uid",
              "example": "507f191e810c19729de860ea",
              "description": "The unique group identifier"
            },
            "name": {
              "type": "string",
              "example": "Finance",
              "readOnly": true,
              "description": "The group name"
            },
            "providerType": {
              "enum": [
                "idp",
                "custom"
              ],
              "type": "string",
              "example": "custom",
              "description": "The provider type of the group."
            },
            "assignedRoles": {
              "$ref": "#/components/schemas/assignedRoles"
            }
          },
          "description": "A group assigned to the user."
        }
      },
      "assignedRoles": {
        "type": "array",
        "items": {
          "type": "object",
          "required": [
            "id",
            "name",
            "type",
            "level"
          ],
          "properties": {
            "id": {
              "type": "string",
              "format": "uid",
              "example": "507f191e810c19729de860ea",
              "description": "The unique role identifier"
            },
            "name": {
              "type": "string",
              "example": "My Custom Role",
              "readOnly": true,
              "description": "The role name"
            },
            "type": {
              "enum": [
                "default",
                "custom"
              ],
              "type": "string",
              "example": "custom",
              "readOnly": true,
              "description": "The type of role"
            },
            "level": {
              "enum": [
                "admin",
                "user"
              ],
              "type": "string",
              "example": "user",
              "readOnly": true,
              "description": "The role level"
            }
          },
          "description": "A role assigned to the user."
        }
      },
      "botUser": {
        "type": "object",
        "required": [
          "id",
          "subject",
          "name",
          "tenantId",
          "clientId"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uid",
            "readOnly": true,
            "description": "The unique bot user identifier."
          },
          "name": {
            "type": "string",
            "description": "The name of the bot user."
          },
          "groups": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "group1",
              "group2"
            ],
            "description": "Group names associated to the bot user."
          },
          "status": {
            "enum": [
              "active",
              "disabled",
              "deleted"
            ],
            "type": "string",
            "description": "The status of the bot user within the tenant."
          },
          "subject": {
            "type": "string",
            "description": "The unique bot user identifier which incorporates the client ID."
          },
          "clientId": {
            "type": "string",
            "description": "The OAuth client ID that the bot user belongs to."
          },
          "tenantId": {
            "type": "string",
            "format": "uid",
            "description": "The tenant that the bot user belongs to."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "The timestamp for when the bot user record was created."
          },
          "assignedRoles": {
            "$ref": "#/components/schemas/assignedRoles"
          },
          "lastUpdatedAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "The timestamp for when the bot user record was last updated."
          },
          "assignedGroups": {
            "$ref": "#/components/schemas/assignedGroups"
          }
        }
      },
      "cloudEventsContextAttributes": {
        "type": "object",
        "required": [
          "id",
          "source",
          "specversion",
          "type"
        ],
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "A234-1234-1234"
            ],
            "minLength": 1,
            "description": "Identifies the event."
          },
          "time": {
            "type": "string",
            "format": "date-time",
            "examples": [
              "2025-04-21T13:45:30Z"
            ],
            "minLength": 1,
            "description": "Timestamp of when the occurrence happened. Must adhere to RFC 3339."
          },
          "type": {
            "type": "string",
            "examples": [
              "com.qlik.v1.app.created"
            ],
            "minLength": 1,
            "description": "Describes the type of event related to the originating occurrence."
          },
          "source": {
            "type": "string",
            "format": "uri-reference",
            "default": "com.qlik/identities",
            "examples": [
              "com.qlik/my-service"
            ],
            "minLength": 1,
            "description": "Identifies the context in which an event happened."
          },
          "specversion": {
            "type": "string",
            "examples": [
              "1.0"
            ],
            "minLength": 1,
            "description": "The version of the CloudEvents specification which the event uses."
          },
          "datacontenttype": {
            "type": "string",
            "examples": [
              "application/json"
            ],
            "minLength": 1,
            "description": "Content type of the data value. Must adhere to RFC 2046 format."
          }
        },
        "description": "CloudEvents Specification JSON Schema"
      },
      "cloudEventsQlikExtensionsAttributes": {
        "type": "object",
        "required": [
          "tenantid"
        ],
        "properties": {
          "userid": {
            "type": "string",
            "examples": [
              "VZhiEfgW2bLd7HgR-jjzAh6VnicipweT"
            ],
            "description": "Unique identifier for the user triggering the event."
          },
          "tenantid": {
            "type": "string",
            "examples": [
              "VZhiEfgW2bLd7HgR-jjzAh6VnicipweT"
            ],
            "description": "Unique identifier for the tenant related to the event."
          }
        }
      },
      "provisionedUser": {
        "type": "object",
        "examples": [
          {
            "id": "507f191e810c19729de860ea",
            "name": "John Doe",
            "email": "john.doe@example.com",
            "locale": "en-US",
            "status": "provisioned",
            "subject": "auth0\\user123",
            "tenantId": "VZhiEfgW2bLd7HgR-jjzAh6VnicipweT",
            "zoneinfo": "America/New_York",
            "createdAt": "2025-11-25T10:30:00Z",
            "lastUpdatedAt": "2025-11-25T10:30:00Z"
          }
        ],
        "required": [
          "id",
          "tenantId"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uid",
            "readOnly": true,
            "description": "The unique user identifier."
          },
          "name": {
            "type": "string",
            "description": "The name of the user."
          },
          "email": {
            "type": "string",
            "description": "The email address for the user."
          },
          "locale": {
            "type": "string",
            "description": "Represents the end-user's language tag."
          },
          "status": {
            "type": "string",
            "example": "provisioned",
            "description": "The status of the provisioned user within the tenant."
          },
          "picture": {
            "type": "string",
            "format": "url",
            "description": "A static url linking to the avatar of the user."
          },
          "subject": {
            "type": "string",
            "description": "The unique user identifier from an identity provider."
          },
          "tenantId": {
            "type": "string",
            "format": "uid",
            "description": "The tenant that the user belongs to."
          },
          "zoneinfo": {
            "type": "string",
            "description": "Represents the end-user's time zone."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "The timestamp for when the user record was provisioned."
          },
          "lastUpdatedAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "The timestamp for when the user record was last updated."
          }
        },
        "description": "The event data payload containing provisioned user details."
      },
      "updateObject": {
        "type": "object",
        "examples": [
          {
            "_updates": [
              {
                "path": "/name",
                "newValue": "Dan",
                "oldValue": "Dylan"
              },
              {
                "path": "/email",
                "newValue": "dan@example.com",
                "oldValue": "dylan@example.com"
              }
            ]
          }
        ],
        "properties": {
          "_updates": {
            "type": "array",
            "items": {
              "type": "object",
              "example": {
                "path": "/attributePath",
                "newValue": "Dan",
                "oldValue": "Dylan"
              },
              "properties": {
                "path": {
                  "type": "string",
                  "description": "Field that was updated."
                },
                "newValue": {
                  "description": "JSON value of the field after the update. The value can be a scalar, array, object, or null, depending on the field."
                },
                "oldValue": {
                  "description": "JSON value of the field before the update. The value can be a scalar, array, object, or null, depending on the field."
                }
              }
            },
            "description": "Collection of updates performed on the resource."
          }
        },
        "description": "Object representing the updates performed on a resource."
      },
      "user": {
        "type": "object",
        "required": [
          "id",
          "subject",
          "name",
          "tenantId"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uid",
            "readOnly": true,
            "description": "The unique user identifier."
          },
          "name": {
            "type": "string",
            "description": "The name of the user."
          },
          "email": {
            "type": "string",
            "description": "The email address for the user."
          },
          "groups": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "group1",
              "group2"
            ],
            "description": "References to IdP groups assigned to the user."
          },
          "locale": {
            "type": "string",
            "description": "Represents the end-user's language tag."
          },
          "status": {
            "enum": [
              "active",
              "invited",
              "disabled",
              "deleted"
            ],
            "type": "string",
            "description": "The status of the user within the tenant."
          },
          "picture": {
            "type": "string",
            "format": "url",
            "description": "A static url linking to the avatar of the user."
          },
          "subject": {
            "type": "string",
            "description": "The unique user identifier from an identity provider."
          },
          "tenantId": {
            "type": "string",
            "format": "uid",
            "description": "The tenant that the user belongs to."
          },
          "zoneinfo": {
            "type": "string",
            "description": "Represents the end-user's time zone."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "The timestamp for when the user record was created."
          },
          "inviteExpiry": {
            "type": "number",
            "readOnly": true,
            "description": "The number of seconds until the user invitation will expire."
          },
          "assignedRoles": {
            "$ref": "#/components/schemas/assignedRoles"
          },
          "lastUpdatedAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "The timestamp for when the user record was last updated."
          },
          "assignedGroups": {
            "$ref": "#/components/schemas/assignedGroups"
          },
          "preferredLocale": {
            "type": "string",
            "description": "Represents the end-user's preferred language tag."
          },
          "preferredZoneinfo": {
            "type": "string",
            "description": "Represents the end-user's preferred time zone."
          }
        }
      }
    }
  }
}