{
  "openapi": "3.0.0",
  "info": {
    "title": "Chatbot API Service",
    "version": "1.00.04",
    "license": {}
  },
  "paths": {
    "/.well-known": {
      "get": {
        "summary": "Get well known config.",
        "description": "Get well known config<br />\n\n\n|            **Returns**                    |\n|-------------------------------------------|\n\nReturns an object\n",
        "tags": [
          "Well Known config"
        ],
        "responses": {
          "200": {
            "description": "Success\n\n```\n{\n    \"public_key\": \"string\" //same as <service>/publickeys endpoint,\n}\n```\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WellKnowResponse"
                }
              }
            }
          }
        }
      }
    },
    "/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 'environment.allowed_time_span' seconds from now\n\n### publickey (required)\nPublic key\n\n|              **Returns**                     |\n|----------------------------------------------|\n\nReturns array with service keys\n",
        "tags": [
          "Service Key"
        ],
        "security": [
          {
            "keyId": []
          },
          {
            "keySecret": []
          },
          {
            "license": []
          }
        ],
        "parameters": [
          {
            "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 'environment.allowed_time_span' 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"
            }
          },
          {
            "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"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceKeysResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          },
          "500": {
            "description": "Internal Server Error"
          }
        }
      }
    },
    "/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 'environment.allowed_time_span' seconds from now\n\n### publickey (required)\nPublic key\n\n|              **Returns**                     |\n|----------------------------------------------|\n\nReturns re-created service key\n",
        "tags": [
          "Service Key"
        ],
        "security": [
          {
            "keyId": []
          },
          {
            "keySecret": []
          },
          {
            "license": []
          }
        ],
        "parameters": [
          {
            "name": "keyId",
            "in": "path",
            "description": "keyId of service key to reset",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "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 'environment.allowed_time_span' 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"
            }
          },
          {
            "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"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceKeysResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "500": {
            "description": "Internal Server Error"
          }
        }
      }
    },
    "/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/GetServiceComponentsResponse"
                }
              }
            }
          }
        }
      }
    },
    "/query/agent/{agentId}": {
      "post": {
        "summary": "Chat API endpoint to query specific agent",
        "description": "Sends user input to specific agent and returns response",
        "tags": [
          "ChatAPI"
        ],
        "security": [
          {
            "keyId": []
          },
          {
            "keySecret": []
          },
          {
            "license": []
          },
          {
            "authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID to query"
          },
          {
            "in": "query",
            "name": "sessionId",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional session ID. If not provided, generated by API."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "data": {
                    "type": "object",
                    "properties": {
                      "sessionId": {
                        "type": "string",
                        "description": "Optional session ID. If not provided, generated by API."
                      },
                      "userInput": {
                        "type": "string",
                        "description": "User input for the agent.",
                        "required": true
                      },
                      "tenantId": {
                        "type": "string",
                        "description": "Optional. Only allowed if using system/service key for authorization."
                      },
                      "communityId": {
                        "type": "string",
                        "description": "Optional. Only allowed if using system/service key for authorization."
                      },
                      "username": {
                        "type": "string",
                        "description": "Optional. Only allowed if using system/service key for authorization."
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Agent response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "response": {
                      "type": "string"
                    },
                    "sessionId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/publickeys": {
      "get": {
        "summary": "Get system's public key.",
        "description": "Get system's public key.\n\n|            **Returns**                    |\n|-------------------------------------------|\n\nReturns a public key object\n",
        "tags": [
          "Public Key"
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicKeyResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid ECDSA signature / ID found."
          }
        }
      }
    },
    "/jwt/verifyToken": {
      "post": {
        "description": "Verify JWT token and check active session\n\nThis endpoint verifies a JWT token and checks if the user has an active login session.\nIt also validates user permissions for AI chatbot access and ensures the user is active and not disabled.\nIf validation fails, all user login sessions are destroyed.\n\n|              **Headers**                     |\n|----------------------------------------------|\n\n### requestid (required)\nJSON string encrypted with ECDSA containing \"appid\" (string), \"uuid\" (string) and \"ts\" (number) representing epoch timestamp in seconds\n\n### publickey (required)\nECDSA Public key for encryption/decryption\n\n|            **Request Body**                  |\n|----------------------------------------------|\n\n### data (required)\nEncrypted object containing:\n- token: JWT token string to verify\n\n|            **Returns**                    |\n|-------------------------------------------|\n\nReturns verification result with decoded token data and user permissions.\n",
        "security": [
          {
            "keyId": []
          },
          {
            "keySecret": []
          }
        ],
        "parameters": [
          {
            "name": "requestid",
            "in": "header",
            "description": "JSON string encrypted with ECDSA containing request metadata",
            "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"
            }
          }
        ],
        "tags": [
          "JWT"
        ],
        "requestBody": {
          "description": "Request body contains encrypted 'data' field with the token to verify.\n\nFor Swagger preview, you can send unencrypted data:\n```\n{\n    \"data\": {\n        \"token\": \"your-jwt-token-here\"\n    }\n}\n```\n",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JwtVerifyTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token verified successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JwtVerifyTokenResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid, expired, or unauthorized token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Invalid token"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/healthz": {
      "get": {
        "summary": "Get healthz.",
        "description": "Get healthz<br />\n\n\n|            **Returns**                    |\n|-------------------------------------------|\n\nReturns a healthz object\n - ```version = <git-tag>.<commit-id>.<dob>``` <br />\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 - ```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 - ```dob```: Date Of Build. This is epoc-time-in-se\tconds that tell the time when the build was created.\n - \u200bif the code is not built from a git-tag, then the ```version =\ufffc<commit-id>.<dob>```\n",
        "tags": [
          "Healthz"
        ],
        "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}\n```\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthzResponse"
                }
              }
            }
          }
        }
      }
    },
    "/environment": {
      "get": {
        "description": "Provide details regarding the environments.\n|            **Returns**                    |\n|-------------------------------------------|\n\nReturns an environment object\n",
        "tags": [
          "Environment"
        ],
        "security": [
          {
            "license": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/ecdsa_helper/{method}": {
      "post": {
        "summary": "Encrypt and decrypt the data string by public key and private key.",
        "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### data (optional)\nThe data 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": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EcdsaEncryptDecryptRequest"
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "method",
            "schema": {
              "type": "string",
              "enum": [
                "encrypt",
                "decrypt"
              ],
              "default": "encrypt"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EcdsaEncryptDecryptResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PublicKeyResponse": {
        "type": "object",
        "properties": {
          "publicKey": {
            "type": "string"
          }
        },
        "example": {
          "publicKey": ""
        }
      },
      "HealthzResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string"
          },
          "publicKey": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "version": {
            "type": "string"
          }
        },
        "example": {
          "status": "all services operational",
          "publicKey": "//same as <service>/publickeys endpoint",
          "code": "200",
          "version": "xxxx.xxxx.xxxx"
        }
      },
      "WellKnowResponse": {
        "type": "object",
        "properties": {
          "public_key": {
            "type": "string"
          }
        },
        "example": {
          "public_key": "//same as <service>/publickeys endpoint"
        }
      },
      "EcdsaEncryptDecryptRequest": {
        "type": "object",
        "properties": {
          "data": {
            "type": "string"
          },
          "publicKey": {
            "type": "string"
          },
          "privateKey": {
            "type": "string"
          }
        },
        "example": {
          "data": "Hey, This is example data string.",
          "publicKey": "xxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxx=",
          "privateKey": "xxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxx="
        }
      },
      "EcdsaEncryptDecryptResponse": {
        "type": "object",
        "properties": {
          "publicKey": {
            "type": "string"
          },
          "data": {
            "type": "array"
          }
        },
        "example": {
          "data": "xxxxxxxxxxxxxxxxxxxx",
          "publicKey": "xxxxxxxxxxxxxxxxxxxx"
        }
      },
      "ServiceKeysResponse": {
        "type": "array",
        "description": "Service keys array",
        "items": {
          "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"
          }
        }
      },
      "GetServiceComponentsResponse": {
        "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"
        }
      },
      "JwtVerifyTokenRequest": {
        "type": "object",
        "properties": {
          "data": {
            "description": "Encrypted data containing token (or unencrypted for Swagger preview)",
            "oneOf": [
              {
                "type": "string",
                "description": "Encrypted data string"
              },
              {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "description": "JWT token to verify",
                    "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
                  }
                }
              }
            ]
          }
        },
        "example": {
          "data": {
            "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
          }
        }
      },
      "JwtVerifyTokenResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "status": {
                "type": "integer",
                "description": "HTTP status code",
                "example": 200
              },
              "data": {
                "type": "string",
                "description": "Decrypted token data containing user information",
                "example": "{\"user\":{\"id\":\"123\",\"email\":\"user@example.com\"},\"tenant\":{\"id\":\"tenant123\"},\"community\":{\"id\":\"community123\"}}"
              }
            }
          },
          "publicKey": {
            "type": "string",
            "description": "Public key used for encryption",
            "example": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE..."
          }
        },
        "example": {
          "data": {
            "status": 200,
            "data": "{\"user\":{\"id\":\"123\",\"email\":\"user@example.com\"},\"tenant\":{\"id\":\"tenant123\"},\"community\":{\"id\":\"community123\"}}"
          },
          "publicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE..."
        }
      }
    },
    "securitySchemes": {
      "keyId": {
        "type": "apiKey",
        "name": "keyId",
        "in": "header",
        "description": "ECDSA Public Key"
      },
      "keySecret": {
        "type": "apiKey",
        "name": "keySecret",
        "in": "header",
        "description": "ECDSA Private Key"
      },
      "license": {
        "type": "apiKey",
        "name": "license",
        "in": "header",
        "description": "License key from License Microservice"
      },
      "authorization": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "JWT token from Auth Microservice (Bearer prefix will be added automatically)"
      }
    }
  },
  "tags": [
    {
      "name": "Well Known config"
    },
    {
      "name": "Service Key"
    },
    {
      "name": "Public Key"
    },
    {
      "name": "JWT",
      "description": "Endpoints for JWT operations"
    },
    {
      "name": "Healthz"
    },
    {
      "name": "Environment"
    },
    {
      "name": "ECDSA Helper"
    }
  ],
  "servers": [
    {
      "url": "https://pilot-root.1kosmos.net/chatapi/"
    }
  ]
}