# Routes are not working in 4.1?

**URL:** <https://forum.getkirby.com/t/routes-are-not-working-in-4-1/31112>\
**Category:** Questions\
**Created:** [March 15, 2024, 6:16pm UTC](https://forum.getkirby.com/t/routes-are-not-working-in-4-1/31112 "2024-03-15T18:16:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhampu](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/zhampu/32/7529_2.png) [@zhampu](https://forum.getkirby.com/u/zhampu)\
**Post date:** [March 15, 2024, 6:16pm UTC](https://forum.getkirby.com/t/routes-are-not-working-in-4-1/31112/1 "2024-03-15T18:16:23Z")

</div>

Hey,  
im struggling with a custom route. I have also tried a simple one and im getting “'No route found for path: “get-book-code” and request method: “GET””.

Im using valet with php 8.1 working locally.

any hint? httaccess should be modified?

```auto
<?php
return [
    'routes' => [
        [
            'pattern' => 'api/get-book-code',
            'method' => 'GET',
            'action' => function () {
                $codesPage = page('bookcodes'); 
                $bookCodes = $codesPage->bookCodes()->toStructure();

                foreach ($bookCodes as $index => $code) {
                    if ($code->claimed()->toBool() === false) {

                        $updatedCodes = $bookCodes->toArray();
                        $updatedCodes[$index]['claimed'] = 'true';
                        $codesPage->update([
                            'bookCodes' => yaml::encode($updatedCodes)
                        ]);
                        return [
                            'code' => $code->code(),
                        ];
                    }
                }
                return [
                    'status' => 'error',
                    'message' => 'All codes have been claimed.'
                ];
            }
        ]
    ]
];

```

```auto
<?php

return [
    'debug' => true, 
    'routes' => [
        [
            'pattern' => 'api/test',
            'method' => 'GET',
            'action' => function () {
                return [
                    'status' => 'success',
                    'message' => 'This is a test endpoint.'
                ];
            }
        ]
    ]
];

```

---

<div class="post-metadata">

**Author:** ![zhampu](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/zhampu/32/7529_2.png) [@zhampu](https://forum.getkirby.com/u/zhampu)\
**Post date:** [March 15, 2024, 6:57pm UTC](https://forum.getkirby.com/t/routes-are-not-working-in-4-1/31112/2 "2024-03-15T18:57:59Z")

</div>

Perhaps I posted too early: For reference the pattern works without the /api/ part

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 15, 2024, 11:17pm UTC](https://forum.getkirby.com/t/routes-are-not-working-in-4-1/31112/3 "2024-03-15T23:17:57Z")

</div>

> [@zhampu](#):
>
> `api/get-book-code',`

You cannot use `api` in a non-api custom route.

So you either need to make thing `something/get-book-code`.

Or you have to register the route as `api` route: [API | Kirby CMS](https://getkirby.com/docs/reference/plugins/extensions/api), but if you do that, you need authentication.
