Hm, quite hacky, but seems to work:
'hooks' => [
'route:before' => function ($route, $path, $method) {
if (Str::startsWith($path, 'api/pages/')) {
$pagePath = str_replace('+', '/', str_replace('pages/', '', $route->arguments()[0]));
$page = page($pagePath);
$user = kirby()->user();
if ($page && $user) {
if ($page->email()->value() !== $user->email()) {
throw new Exception('You cannot access this page');
}
}
}
}
]