{
  "asyncapi": "3.0.0",
  "info": {
    "title": "core/user-sessions",
    "version": ""
  },
  "channels": {
    "systemEventsUserSession": {
      "address": "system-events.user-session",
      "messages": {
        "coreUserSessionBegun": {
          "$ref": "#/components/messages/user-session.coreUserSessionBegun"
        },
        "coreUserSessionEnded": {
          "$ref": "#/components/messages/user-session.coreUserSessionEnded"
        }
      }
    }
  },
  "operations": {
    "coreUserSessionBegun": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/systemEventsUserSession"
      },
      "messages": [
        {
          "$ref": "#/channels/systemEventsUserSession/messages/coreUserSessionBegun"
        }
      ]
    },
    "coreUserSessionEnded": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/systemEventsUserSession"
      },
      "messages": [
        {
          "$ref": "#/channels/systemEventsUserSession/messages/coreUserSessionEnded"
        }
      ]
    }
  },
  "components": {
    "messages": {
      "user-session.coreUserSessionBegun": {
        "name": "com.qlik.core.user-session.begun",
        "tags": [
          {
            "name": "user-session"
          }
        ],
        "title": "Session begun",
        "payload": {
          "type": "object",
          "allOf": [
            {
              "$ref": "#/components/schemas/cloudEventsContextAttributes"
            },
            {
              "$ref": "#/components/schemas/cloudEventsQlikExtensionsAttributes"
            },
            {
              "type": "object",
              "required": [
                "type",
                "data"
              ],
              "properties": {
                "data": {
                  "type": "object",
                  "examples": [
                    {
                      "idpId": "661d627cef218789bbd67cc9",
                      "source": "interactive",
                      "subject": "auth0\\foo",
                      "recovery": false
                    }
                  ],
                  "properties": {
                    "idpId": {
                      "type": "string",
                      "example": "661d627cef218789bbd67cc9",
                      "description": "Identifier of the identity provider through which the session was initiated. Omitted when no external identity provider was used."
                    },
                    "source": {
                      "type": "string",
                      "example": "interactive",
                      "description": "The authentication flow that initiated the session, for example `interactive` (interactive browser login) or `jwt-login-session` (JWT login)."
                    },
                    "subject": {
                      "type": "string",
                      "example": "auth0\\foo",
                      "description": "User's subject identifier in the identity database."
                    },
                    "recovery": {
                      "type": "boolean",
                      "example": false,
                      "description": "Whether the session is part of a recovery login."
                    },
                    "userType": {
                      "enum": [
                        "anonymous"
                      ],
                      "type": "string",
                      "description": "The user's type, only specified for anonymous users."
                    }
                  },
                  "description": "Data specific to the user session begun event."
                },
                "type": {
                  "type": "string",
                  "default": "com.qlik.core.user-session.begun",
                  "description": "The type of event."
                }
              }
            }
          ]
        },
        "description": "Published when a user session is created.",
        "x-qlik-deprecated": false,
        "x-qlik-stability": "stable",
        "x-qlik-visibility": "public"
      },
      "user-session.coreUserSessionEnded": {
        "name": "com.qlik.core.user-session.ended",
        "tags": [
          {
            "name": "user-session"
          }
        ],
        "title": "Session ended",
        "payload": {
          "type": "object",
          "allOf": [
            {
              "$ref": "#/components/schemas/cloudEventsContextAttributes"
            },
            {
              "$ref": "#/components/schemas/cloudEventsQlikExtensionsAttributes"
            },
            {
              "type": "object",
              "required": [
                "type",
                "data"
              ],
              "properties": {
                "data": {
                  "type": "object",
                  "examples": [
                    {
                      "subject": "auth0\\foo"
                    }
                  ],
                  "properties": {
                    "subject": {
                      "type": "string",
                      "example": "auth0\\foo",
                      "description": "User's subject identifier in the identity database."
                    }
                  },
                  "description": "Data specific to the user session end event."
                },
                "type": {
                  "type": "string",
                  "default": "com.qlik.core.user-session.ended",
                  "description": "The type of event."
                }
              }
            }
          ]
        },
        "description": "Published when a user session ends.",
        "x-qlik-deprecated": false,
        "x-qlik-stability": "stable",
        "x-qlik-visibility": "public"
      }
    },
    "schemas": {
      "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": [
              "2026-01-01T12:00:00Z"
            ],
            "minLength": 1,
            "description": "Timestamp of when the occurrence happened. Must adhere to RFC 3339."
          },
          "type": {
            "type": "string",
            "examples": [
              "com.qlik.core.user-session.begun"
            ],
            "minLength": 1,
            "description": "Describes the type of event related to the originating occurrence."
          },
          "source": {
            "type": "string",
            "format": "uri-reference",
            "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",
            "default": "application/json",
            "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": {
          "meta": {
            "type": "object",
            "examples": [
              {
                "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"
              }
            ],
            "properties": {
              "userAgent": {
                "type": "string",
                "examples": [
                  "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"
                ],
                "description": "The User-Agent header of the request that triggered the event."
              }
            },
            "description": "Additional request metadata carried as a CloudEvents extension."
          },
          "userid": {
            "type": "string",
            "examples": [
              "605a18af2ab08cdbfad09259"
            ],
            "description": "Unique identifier for the user triggering the event."
          },
          "authtype": {
            "type": "string",
            "examples": [
              "service_account"
            ],
            "description": "The type of principal that triggered the occurrence."
          },
          "originip": {
            "type": "string",
            "examples": [
              "0.0.0.0"
            ],
            "description": "Origin IP address."
          },
          "tenantid": {
            "type": "string",
            "examples": [
              "TiQ8GPVr8qI714Lp5ChAAFFaU24MJy69"
            ],
            "description": "Unique identifier for the tenant related to the event."
          },
          "sessionid": {
            "type": "string",
            "examples": [
              "WZhiEfgW2bLd7HgR-jjzAh6VnicipweT"
            ],
            "description": "Unique identifier for the session related to the event."
          },
          "authclaims": {
            "type": "string",
            "examples": [
              "{\\\"iss\\\":\\\"qlik.api.internal/service\\\",\\\"sub\\\":\\\"service\\\",\\\"subType\\\":\\\"service\\\"}"
            ],
            "description": "A JSON string representing claims of the principal that triggered the event"
          },
          "tracestate": {
            "type": "string",
            "examples": [
              "rojo=00f067aa0ba902b7,congo=t61rcWkgMzE"
            ],
            "description": "W3C Trace Context tracestate header propagated with the event."
          },
          "traceparent": {
            "type": "string",
            "examples": [
              "00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01"
            ],
            "description": "W3C Trace Context traceparent header propagated with the event."
          }
        }
      }
    }
  }
}