Webhook enpoint in route

Hi, I am trying to make my own route for an incoming web hook.
The route itself works, but the sender says it is a 404 Error and I have difficulties to update my side, if I am not logged in. The idea is to update a tracking field for shipped parcels.

  [ 'routes' => function(){ return [
            'pattern' => 'webhook',
            'action' => function(){

                $page = site()->page('orders')->children()->listed()->search('224229339','parcel_id');

                $obj = new req;
                $data = $obj->data();

                    'tracking' => json_encode($data)
                ], 'en');

                $return = (object)[
                        "action" => "integration_connected",
                        "timestamp" => time()

                $body = json_encode( $return );

                return Response::json(

The id is later coming from the web hook, this is just for testing purposes.

Any help is appreciated, the web hook endpoint is new for me.

Thanks in advance

The page helper expects a string as parameter, since you already try to create a page object in the first line, no need to use the page helper. But you must test if this line returns a page object before you continue.

Also, you have to authenticate before you can update, e,g with kirby()->impersonate('kirby');

You are right. I have to check if the page exists. Since I test with a “Defined” ID, which I know that exists it is working, but for the future I need to check first.

The authentication helped for updating the page as well. Thank you!

Any idea why the web hook server can not handle the data, but the browser shows it?

Web Browser result

Does the webhook send a post request? Then you need to add the method prop in your route, see docs.

@pixelijn Thank you very much. I completely oversaw this option and tried it inside the route. Perfect.