diff --git a/rest/index.php b/rest/index.php
index 95e244bf40e72d8cf5989b2dcc091d5bdfa0843c..2ee36acb7c5b72254d728a11c1f6cb8b17ad0f23 100755
--- a/rest/index.php
+++ b/rest/index.php
@@ -87,15 +87,6 @@ $app->put('/documents/{id}/workflows/interrupt', \Workflow\controllers\WorkflowC
 //Emails
 $app->post('/emails', \Email\controllers\EmailController::class . ':send');
 
-//Languages
-$app->get('/languages', \SrcCore\controllers\LanguageController::class . ':getAvailableCoreLanguages');
-$app->get('/languages/{lang}', \SrcCore\controllers\LanguageController::class . ':getByLang');
-$app->put('/languages', \SrcCore\controllers\LanguageController::class . ':generateLang');
-
-//PasswordRules
-$app->get('/passwordRules', \SrcCore\controllers\PasswordController::class . ':get');
-$app->put('/passwordRules', \SrcCore\controllers\PasswordController::class . ':updateRules');
-
 //Groups
 $app->post('/groups', \Group\controllers\GroupController::class . ':create');
 $app->get('/groups', \Group\controllers\GroupController::class . ':get');
@@ -106,6 +97,19 @@ $app->put('/groups/{id}/privilege/{privilegeId}', \Group\controllers\GroupContro
 $app->put('/groups/{id}/users', \Group\controllers\GroupController::class . ':addUser');
 $app->delete('/groups/{id}/users/{userId}', \Group\controllers\GroupController::class . ':removeUser');
 
+//History
+$app->post('/history', \History\controllers\HistoryController::class . ':get');
+$app->get('/history/messageTypes', \History\controllers\HistoryController::class . ':getMessageTypes');
+
+//Languages
+$app->get('/languages', \SrcCore\controllers\LanguageController::class . ':getAvailableCoreLanguages');
+$app->get('/languages/{lang}', \SrcCore\controllers\LanguageController::class . ':getByLang');
+$app->put('/languages', \SrcCore\controllers\LanguageController::class . ':generateLang');
+
+//PasswordRules
+$app->get('/passwordRules', \SrcCore\controllers\PasswordController::class . ':get');
+$app->put('/passwordRules', \SrcCore\controllers\PasswordController::class . ':updateRules');
+
 //Users
 $app->post('/users', \User\controllers\UserController::class . ':create');
 $app->get('/users', \User\controllers\UserController::class . ':get');
diff --git a/src/app/history/controllers/HistoryController.php b/src/app/history/controllers/HistoryController.php
index e2ecfac9ad59b0f0205c2d0ee4a456598404677c..36ab339f9ef976ff4e03fe0141752f34a2eb69ce 100755
--- a/src/app/history/controllers/HistoryController.php
+++ b/src/app/history/controllers/HistoryController.php
@@ -29,6 +29,7 @@ use Slim\Http\Request;
 use Slim\Http\Response;
 use SrcCore\controllers\LanguageController;
 use SrcCore\models\CoreConfigModel;
+use SrcCore\models\DatabaseModel;
 use SrcCore\models\TextFormatModel;
 use SrcCore\models\ValidatorModel;
 use User\models\UserModel;
@@ -57,36 +58,90 @@ class HistoryController
         return true;
     }
 
-    public function get(Request $request, Response $response, array $args)
+    public function get(Request $request, Response $response)
     {
-        //TODO privilege
-
-//        $history = HistoryModel::get([
-//            'select'    => ['code', 'type', '"user"', 'date', 'message', 'data', 'user_id', 'ip'],
-//            'where'     => ["(object_type = ? AND object_id = ?) OR (data->>'mainDocumentId' = ?)"],
-//            'data'      => ['main_documents', $args['id'], $args['id']],
-//            'orderBy'   => ['date']
-//        ]);
-//
-//
-//        HistoryController::add([
-//            'code'          => 'OK',
-//            'objectType'    => 'history',
-//            'objectId'      => $args['id'],
-//            'type'          => 'VIEW',
-//            'message'       => '{documentHistoryViewed}',
-//            'data'          => ['objectType' => 'main_documents']
-//        ]);
-//
-//        $queryParams = $request->getQueryParams();
-//        if (!isset($queryParams['mode']) || $queryParams['mode'] == 'json') {
-//            return $response->withJson(['history' => $formattedHistory['formattedHistory']]);
-//        } else {
-//            $historyXml = HistoryController::arrayToXml(['data' => $formattedHistory['formattedHistory'], 'xml' => false]);
-//            $response->write($historyXml);
-//            $response = $response->withAddedHeader('Content-Disposition', "inline; filename=maarch_history.xml");
-//            return $response->withHeader('Content-Type', 'application/xml');
-//        }
+        if (!PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_history'])) {
+            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
+        }
+
+        $queryParams = $request->getQueryParams();
+        $body = $request->getParsedBody();
+
+        $limit = 25;
+        if (!empty($queryParams['limit']) && is_numeric($queryParams['limit'])) {
+            $limit = (int)$queryParams['limit'];
+        }
+        $offset = 0;
+        if (!empty($queryParams['offset']) && is_numeric($queryParams['offset'])) {
+            $offset = (int)$queryParams['offset'];
+        }
+
+        $where = [];
+        $data = [];
+        if (!empty($body['users']) && is_array($body['users'])) {
+            $where[] = 'user_id in (?)';
+            $data[]  = $body['users'];
+        }
+
+        if (!empty($body['date']['start'])) {
+            $where[] = 'date > ?';
+            $data[]  = $body['date']['start'];
+        }
+        if (!empty($body['date']['end'])) {
+            $where[] = 'date < ?';
+            $data[]  = $body['date']['end'];
+        }
+        if (!empty($body['messageTypes']) && is_array($body['messageTypes'])) {
+            $queryTypes = '{';
+            foreach ($body['messageTypes'] as $key => $messageType) {
+                if ($key > 0) {
+                    $queryTypes .= ',';
+                }
+                $queryTypes .= "\"%{{$messageType}}%\"";
+            }
+            $queryTypes .= '}';
+            $where[] = 'message like any (?)';
+            $data[]  = $queryTypes;
+        }
+
+        $history = HistoryModel::get([
+            'select'    => ['code', 'type', '"user"', 'date', 'message', 'data', 'user_id', 'ip', 'object_id', 'count(1) OVER()'],
+            'where'     => $where,
+            'data'      => $data,
+            'orderBy'   => ['date DESC'],
+            'limit'     => $limit,
+            'offset'    => $offset
+        ]);
+
+        $formattedHistory = [];
+
+        $lang       = LanguageController::get();
+        $langKeys   = [];
+        $langValues = [];
+        foreach ($lang as $key => $value) {
+            $langKeys[]   = "/{{$key}}/";
+            $langValues[] = $value;
+        }
+
+        $total = $history[0]['count'] ?? 0;
+        foreach ($history as $value) {
+            $date = new \DateTime($value['date']);
+
+            $data = json_decode($value['data'], true);
+            $formattedHistory[] = [
+                'code'      => $value['code'],
+                'objectId'  => $value['object_id'],
+                'type'      => $value['type'],
+                'userId'    => $value['user_id'],
+                'user'      => $value['user'],
+                'date'      => $date->format('c'),
+                'ip'        => $value['ip'],
+                'message'   => preg_replace($langKeys, $langValues, $value['message']),
+                'data'      => $data
+            ];
+        }
+
+        return $response->withJson(['history' => $formattedHistory, 'total' => $total]);
     }
 
     public function getByDocumentId(Request $request, Response $response, array $args)
@@ -129,6 +184,25 @@ class HistoryController
         }
     }
 
+    public function getMessageTypes(Request $request, Response $response)
+    {
+        if (!PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_history'])) {
+            return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
+        }
+
+        $rawHistory = DatabaseModel::select([
+            'select'    => ['DISTINCT h.msg'],
+            'table'     => ["(SELECT REGEXP_MATCHES(message, '{[a-zA-Z]+}', 'g') AS msg FROM history) h"],
+        ]);
+
+        $messageTypes = [];
+        foreach ($rawHistory as $value) {
+            $messageTypes[] = str_replace(['"', '{', '}'], '', $value['msg']);
+        }
+
+        return $response->withJson(['messageTypes' => $messageTypes]);
+    }
+
     public static function getFormattedHistory($args = [])
     {
         $adr = AdrModel::getDocumentsAdr([
diff --git a/src/app/history/models/HistoryModel.php b/src/app/history/models/HistoryModel.php
index ebfde00211c3a5b0e6331b62dde6d352d5c3a7d9..c2e2515d2ec263234aaa4f2801004402138f9b9c 100755
--- a/src/app/history/models/HistoryModel.php
+++ b/src/app/history/models/HistoryModel.php
@@ -19,20 +19,20 @@ use SrcCore\models\ValidatorModel;
 
 class HistoryModel
 {
-    public static function get(array $aArgs)
+    public static function get(array $args)
     {
-        ValidatorModel::notEmpty($aArgs, ['select']);
-        ValidatorModel::arrayType($aArgs, ['select', 'where', 'data', 'orderBy']);
-        ValidatorModel::intType($aArgs, ['limit', 'offset']);
+        ValidatorModel::notEmpty($args, ['select']);
+        ValidatorModel::arrayType($args, ['select', 'where', 'data', 'orderBy']);
+        ValidatorModel::intType($args, ['limit', 'offset']);
 
         $history = DatabaseModel::select([
-            'select'    => $aArgs['select'],
+            'select'    => $args['select'],
             'table'     => ['history'],
-            'where'     => empty($aArgs['where']) ? [] : $aArgs['where'],
-            'data'      => empty($aArgs['data']) ? [] : $aArgs['data'],
-            'orderBy'   => empty($aArgs['orderBy']) ? [] : $aArgs['orderBy'],
-            'offset'    => empty($aArgs['offset']) ? 0 : $aArgs['offset'],
-            'limit'     => empty($aArgs['limit']) ? 0 : $aArgs['limit'],
+            'where'     => empty($args['where']) ? [] : $args['where'],
+            'data'      => empty($args['data']) ? [] : $args['data'],
+            'orderBy'   => empty($args['orderBy']) ? [] : $args['orderBy'],
+            'offset'    => empty($args['offset']) ? 0 : $args['offset'],
+            'limit'     => empty($args['limit']) ? 0 : $args['limit'],
         ]);
 
         return $history;