API custom endpoint get all pages with template

Hi, I’m fairly new to using Kirby with an API.
Is there a possibility to create a custom endpoint that provides me with all pages of a given template? This is how I tried it until now:

<?php
Kirby::plugin('my/api', [
	'api' => [
		'routes' => function($kirby) {
			return [
				[
					'pattern' => 'my-endpoint',
					'action'  => function () use ($kirby) {
						return [
							'users' => $kirby->site()->index()->filterBy('template', 'myTemplate')
						];
					}
				]
			];
		}
	]

]);

Thanks a lot in advance!

PS: maybe a different topic, but related: $kirby->page(‘myPage’) as well as $kirby->page(‘myUuid’) don’t work for me. Am I doing something wrong here, or how do I get a certain page

And what exactly is the problem? The code should actually work.

Sorry, you’re right, it works actually.

I didn’t create the according template file.

(Just as a hint for others who might run into this problem: I’m trying to connect a frontend framework to a headless version of Kirby and therefore didn’t think about creating template files since I thought that I just need blueprints and I thought it would be enough to select those in the backend.)