{
  "openapi": "3.0.0",
  "info": {
    "title": "Events service API",
    "version": "1.11.07.02",
    "description": "API documentation for Events service API"
  },
  "servers": [
    {
      "url": "https://pilot-root.1kosmos.net/events/"
    }
  ],
  "paths": {
    "/tenant/{tenantId}/community/{communityId}/event/{eventName}": {
      "put": {
        "summary": "Create Event",
        "description": "Creates an event in DB. You can send any number of fields in request body\n\n|              **Parameters**                  |\n|----------------------------------------------|\n\n### eventName (required)\nThe name of the event to log. Suggested values: E_USER_ONBOARDED, E_USER_INVITED, E_LOGIN_ATTEMPT, E_LOG_OTP_REQUESTED or different.\n\n### tenantId (required)\nThe id of tenant\n\n### communityId (required)\nThe id of community\n\n|              **Headers**                     |\n|----------------------------------------------|\n\n### licensekey (required)\nLicense key encrypted with ECDSA\n\n### requestid (required)\nJSON string encrypted with ECDSA which should contain \"appid\" (string), \"uuid\" (string) and \"ts\" (number) representing epoch timestamp in seconds - it shouldn't be more or less than 60 seconds from now\n\n### publickey (required)\nPublic key\n\n|              **Request Body**                |\n|----------------------------------------------|\n\n### type (required)\nEvent type\n\n### timestamp (optional)\nTime of event in string that is able to be parsed as date <br />\ndefault = current time\n\n### epoch_time (optional)\nTime of event in number <br />\ndefault = current time\n\n\n|              **Returns**                     |\n|----------------------------------------------|\n\nReturns status code OK if everything is ok\n",
        "tags": [
          "Tenant"
        ],
        "security": [
          {
            "authMyPublicKey": []
          },
          {
            "authMyPrivateKey": []
          },
          {
            "authLicense": []
          }
        ],
        "parameters": [
          {
            "name": "eventName",
            "in": "path",
            "description": "Name of event",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tenantId",
            "in": "path",
            "description": "Id of tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "communityId",
            "in": "path",
            "description": "Id of community",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "licensekey",
            "in": "header",
            "description": "License key encrypted with ECDSA / Try Authorize &#128274;",
            "required": true,
            "schema": {
              "type": "string",
              "example": "Do not enter anything, use 'Authorize' fields"
            }
          },
          {
            "name": "requestid",
            "in": "header",
            "description": "JSON string encrypted with ECDSA which should contain \"appid\" (string), \"uuid\" (string) and \"ts\" (number) representing epoch timestamp in seconds - it shouldn't be more or less than 60 seconds from now / Try Authorize &#128274;",
            "required": true,
            "schema": {
              "type": "string",
              "example": "Do not enter anything, use 'Authorize' fields"
            }
          },
          {
            "name": "publickey",
            "in": "header",
            "description": "Public Key  / Try Authorize &#128274;",
            "required": true,
            "schema": {
              "type": "string",
              "example": "Do not enter anything, use 'Authorize' fields"
            }
          }
        ],
        "requestBody": {
          "description": "Request body contains 'data' field with encrypted object below:\n\nIMPORTANT - you can send unencrypted data in this request, it is only available in Swagger\n\n```\n{\n    \"data\": {\n        \"type\": \"string - required\",\n        \"epoch_time\": \"number in seconds - optional\",\n        \"timestamp\": \"string in date format 'YYYY-MM-DD HH:mm:ss.SSS' or other readable - optional\",\n        ...restOfEventData\n    }\n}\n```\n",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateEventRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/schemas/OK"
          },
          "400": {
            "$ref": "#/components/schemas/BadRequestError"
          },
          "403": {
            "$ref": "#/components/schemas/ForbiddenError"
          }
        }
      }
    },
    "/servicekeys": {
      "get": {
        "summary": "Get service keys",
        "description": "This endpoint returns available service keys.\nThe license you are using must be of authLevel 'system'\n\n|              **Headers**                     |\n|----------------------------------------------|\n\n### licensekey (required)\nLicense key encrypted with ECDSA\n\n### requestid (required)\nJSON string encrypted with ECDSA which should contain \"appid\" (string), \"uuid\" (string) and \"ts\" (number) representing epoch timestamp in seconds - it shouldn't be more or less than 60 seconds from now\n\n### publickey (required)\nPublic key\n\n|              **Returns**                     |\n|----------------------------------------------|\n\nReturns array with service keys\n",
        "tags": [
          "Service Key"
        ],
        "security": [
          {
            "authMyPublicKey": []
          },
          {
            "authMyPrivateKey": []
          },
          {
            "authLicense": []
          }
        ],
        "parameters": [
          {
            "name": "licensekey",
            "in": "header",
            "description": "License key encrypted with ECDSA / Try Authorize &#128274;",
            "required": true,
            "schema": {
              "type": "string",
              "example": "Do not enter anything, use 'Authorize' fields"
            }
          },
          {
            "name": "requestid",
            "in": "header",
            "description": "JSON string encrypted with ECDSA which should contain \"appid\" (string), \"uuid\" (string) and \"ts\" (number) representing epoch timestamp in seconds - it shouldn't be more or less than 60 seconds from now / Try Authorize &#128274;",
            "required": true,
            "schema": {
              "type": "string",
              "example": "Do not enter anything, use 'Authorize' fields"
            }
          },
          {
            "name": "publickey",
            "in": "header",
            "description": "Public Key  / Try Authorize &#128274;",
            "required": true,
            "schema": {
              "type": "string",
              "example": "Do not enter anything, use 'Authorize' fields"
            }
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/schemas/ServiceKeysResponse"
          }
        }
      }
    },
    "/servicekey/{keyId}": {
      "delete": {
        "summary": "Reset Service Key",
        "description": "This endpoint resets service key for given keyId. Deletes current one and recreates a new one.\nThe license you are using must be of authLevel 'system'\n\n|              **Parameters**                  |\n|----------------------------------------------|\n\n### keyId (required)\nThe keyId of service key to reset\n\n|              **Headers**                     |\n|----------------------------------------------|\n\n### licensekey (required)\nLicense key encrypted with ECDSA\n\n### requestid (required)\nJSON string encrypted with ECDSA which should contain \"appid\" (string), \"uuid\" (string) and \"ts\" (number) representing epoch timestamp in seconds - it shouldn't be more or less than 60 seconds from now\n\n### publickey (required)\nPublic key\n\n|              **Returns**                     |\n|----------------------------------------------|\n\nReturns object with page info and data\n",
        "tags": [
          "Service Key"
        ],
        "security": [
          {
            "authMyPublicKey": []
          },
          {
            "authMyPrivateKey": []
          },
          {
            "authLicense": []
          }
        ],
        "parameters": [
          {
            "name": "keyId",
            "in": "path",
            "description": "keyId of service key to reset",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "licensekey",
            "in": "header",
            "description": "License key encrypted with ECDSA / Try Authorize &#128274;",
            "required": true,
            "schema": {
              "type": "string",
              "example": "Do not enter anything, use 'Authorize' fields"
            }
          },
          {
            "name": "requestid",
            "in": "header",
            "description": "JSON string encrypted with ECDSA which should contain \"appid\" (string), \"uuid\" (string) and \"ts\" (number) representing epoch timestamp in seconds - it shouldn't be more or less than 60 seconds from now / Try Authorize &#128274;",
            "required": true,
            "schema": {
              "type": "string",
              "example": "Do not enter anything, use 'Authorize' fields"
            }
          },
          {
            "name": "publickey",
            "in": "header",
            "description": "Public Key  / Try Authorize &#128274;",
            "required": true,
            "schema": {
              "type": "string",
              "example": "Do not enter anything, use 'Authorize' fields"
            }
          }
        ],
        "responses": {
          "204": {
            "$ref": "#/components/schemas/NoContent"
          }
        }
      }
    },
    "/sd": {
      "get": {
        "summary": "Get all service directories.",
        "description": "Get all service directories.\n\n|            **Returns**                    |\n|-------------------------------------------|\n\nReturns all service directories.\n",
        "tags": [
          "Service Directory"
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetServiceDirectoryResponse"
                }
              }
            }
          }
        }
      }
    },
    "/publickeys": {
      "get": {
        "description": "Get system's public key.\nNo authorization\n\n|            **Returns**                    |\n|-------------------------------------------|\n\nReturns a public key object\n",
        "tags": [
          "Public Key"
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicKeyResponse"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/schemas/NotFoundError"
          }
        }
      }
    },
    "/healthz": {
      "get": {
        "summary": "Get healthz.",
        "description": "Get healthz\n\n|            **Returns**                    |\n|-------------------------------------------|\n\nReturns a healthz object\n - ```version = <git-tag>.<commit-id>.<dob>```\n\n - ```git-tag```: When code is compiled from a git-tag, this must carry the tag name. This should match one of the git tags.\n\n - ```commit-id```: This is the git-commit-id. eg: When code is built from this, the hex code, in the end, is the commit it.\n\n - ```dob```: Date Of Build. This is epoc-time-in-seconds that tell the time when the build was created.\n\n - \u200bif the code is not built from a git-tag, then the ```version =\ufffc<commit-id>.<dob>```\n",
        "tags": [
          "Healthz"
        ],
        "security": [
          {
            "license": []
          }
        ],
        "parameters": [
          {
            "name": "synthetic-heartbeat",
            "in": "header",
            "description": "If this field is set then additional health information is collection (will not be displayed).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "licensekey",
            "in": "header",
            "description": "plain text license key (system level OR infra-key);",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success\n\n```\n{\n    \"status\": \"all services operational\",\n    \"publicKey\": \"string\" //same as <service>/publickeys endpoint,\n    \"code\": \"200\",\n    \"version\": \"<version>\", //as defined above\n    \"syntheticheartbeatId\": \"<syntheticheartbeatId>\"\n}\n```\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthzResponse"
                }
              }
            }
          }
        }
      }
    },
    "/environment": {
      "get": {
        "description": "\n|            **Returns**                    |\n|-------------------------------------------|\n\n|            **Headers**                     |\n|----------------------------------------------|\n\n  ### licensekey\n  License key\n",
        "tags": [
          "Environment"
        ],
        "parameters": [
          {
            "name": "licensekey",
            "in": "header",
            "description": "License key;",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string",
                  "example": "Not supported"
                }
              }
            }
          }
        }
      }
    },
    "/ecdsa_helper/{method}": {
      "post": {
        "description": "Encrypt and decrypt the data string by public key and private key.\n\n|              **Parameters**                  |\n|----------------------------------------------|\n\n### method (optional)\nThe method parameter is type of enum. Default value is encrypt. <br />\nThis parameter only accepts following values <br />\n   **encrypt**, **decrypt**\n\n\n|            **Request Body**                  |\n|----------------------------------------------|\n\n\n### dataStr (required)\nThe dataStr key is type of string.\n\n<br />\n### publicKey (required)\nThe publicKey is type of string.\n\n<br />\n### privateKey (required)\nThe privateKey is type of string.\n\n|            **Returns**                    |\n|-------------------------------------------|\n\nReturns the encrypted/decrypted string. <br />\nThis API throw an error if something goes wrong. A common source of error is public or private key is not valid.\n",
        "tags": [
          "ECDSA Helper"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EcdsaEncryptDecryptRequest"
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "method",
            "schema": {
              "type": "string",
              "enum": [
                "encrypt",
                "decrypt"
              ],
              "default": "encrypt"
            }
          }
        ],
        "responses": {
          "200": {
            "422": {
              "$ref": "#/components/schemas/UnsupportedStateError"
            },
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EcdsaEncryptDecryptResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "EcdsaEncryptDecryptRequest": {
        "type": "object",
        "required": [
          "dataStr",
          "publicKey",
          "privateKey"
        ],
        "properties": {
          "dataStr": {
            "required": true,
            "type": "string",
            "description": "Message to encrypt or decrypt",
            "example": "Hey, This is example data string."
          },
          "publicKey": {
            "required": true,
            "type": "string",
            "example": "xxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
          },
          "privateKey": {
            "required": true,
            "type": "string",
            "example": "xxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
          }
        }
      },
      "EcdsaEncryptDecryptResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "string"
          }
        },
        "example": {
          "data": "xxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxx"
        }
      },
      "ServiceKey": {
        "type": "object",
        "required": [
          "tag",
          "keyId",
          "keySecret",
          "type"
        ],
        "properties": {
          "tag": {
            "type": "string",
            "description": "service ecdsa"
          },
          "keyId": {
            "type": "string",
            "description": "ecdsa publicKey"
          },
          "keySecret": {
            "type": "string",
            "description": "ecdsa private key"
          },
          "type": {
            "type": "string",
            "description": "default = ecdsa | hawk"
          }
        },
        "example": {
          "tag": "xxxxx",
          "keyId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx",
          "keySecret": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx",
          "type": "xxxxx"
        }
      },
      "ValidationError": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error content"
          },
          "param": {
            "type": "string",
            "description": "Field name"
          }
        },
        "xml": {
          "name": "ValidationError"
        }
      },
      "PublicKeyResponse": {
        "type": "object",
        "properties": {
          "publicKey": {
            "type": "string"
          }
        },
        "example": {
          "publicKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        }
      },
      "NoContent": {
        "description": "This API returns no content"
      },
      "OK": {
        "description": "API successfully processed"
      },
      "ForbiddenError": {
        "description": "Caller doesn't have right permissions to call this API"
      },
      "BadRequestError": {
        "description": "Bad request",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "errors": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/ValidationError"
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      },
      "UnauthorizedError": {
        "description": "API is not authorized to call this API"
      },
      "NotFoundError": {
        "description": "No service Key found"
      },
      "NotFoundRowsError": {
        "description": "No rows found"
      },
      "UnsupportedStateError": {
        "description": "Unsupported state or unable to authenticate data",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "example": "Unsupported state or unable to authenticate data"
                }
              }
            }
          }
        }
      },
      "ServiceKeysResponse": {
        "type": "array",
        "description": "Service keys array",
        "items": {
          "$ref": "#/components/schemas/ServiceKey"
        }
      },
      "HealthzResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "all services operational"
          },
          "publicKey": {
            "type": "string",
            "example": "//same as <service>/publickeys endpoint"
          },
          "code": {
            "type": "string",
            "example": "200"
          },
          "version": {
            "type": "string",
            "example": "xxxx.xxxx.xxxx"
          },
          "syntheticheartbeatId": {
            "type": "string",
            "example": "xxxxxxxx"
          }
        }
      },
      "CreateEventRequest": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "example": "event"
              },
              "timestamp": {
                "type": "string",
                "example": "2023-02-14 15:00:00.000"
              },
              "epoch_time": {
                "type": "number",
                "example": 1318781876
              }
            }
          }
        }
      },
      "GetServiceDirectoryResponse": {
        "type": "object",
        "properties": {
          "name1": {
            "type": "string"
          },
          "name2": {
            "type": "string"
          },
          "name3": {
            "type": "string"
          }
        },
        "example": {
          "name1": "https://xxx.xxxxxx.xxx/xxxxx",
          "name2": "https://xxx.xxxxxx.xxx/xxxxx",
          "name3": "https://xxx.xxxxxx.xxx/xxxxx"
        }
      }
    },
    "securitySchemes": {
      "authMyPublicKey": {
        "type": "apiKey",
        "name": "authMyPublicKey",
        "in": "header",
        "description": "Caller's ECDSA publicKey"
      },
      "authMyPrivateKey": {
        "type": "apiKey",
        "name": "authMyPrivateKey",
        "in": "header",
        "description": "Caller's ECDSA privateKey"
      },
      "authLicense": {
        "type": "apiKey",
        "name": "authLicense",
        "in": "header",
        "description": "License key from License API"
      }
    }
  },
  "tags": [
    {
      "name": "Environment"
    }
  ]
}