webhookSync Issue

Hi team!
I’m creating a Webhook from Sanity to Algolia, and for that, I need to create an API. I’m using Astro, and my function is as follows:
Something is failing, and I don’t know what it is. I get this error . Is there any step I’m doing wrong? So far I was able to Connect Sanity to Algolia. I can do the search and the creatObject functionality.
This is the error I get: TypeError: Cannot read properties of undefined (reading 'ids') .
This is my code:
Thanks in advanced!!

import indexer from "sanity-algolia";
import algoliasearch from "algoliasearch/lite";
import { client } from "@services/api/index";

export async function get({ params, request }) {
  const algoliaInstance = algoliasearch("XXXXXX", "XXXXXXX");
  const index = algoliaInstance.initIndex("dev_NEREA");
  const sanityAlgolia = indexer(
    {
      page: {
        index,
        projection: `*[_type == "page"]{
					title, "objectID" : _id, _type, _rev ,template, 'slug' : en_slug.current
				}`,
      },
    },

    (document) => document,

    (document) => !["unapproved"].includes(document.status)
  );

  return await sanityAlgolia
    .webhookSync(client, request.body as any)
    .then(() => ({
      status: 200,
      body: "Success!",
    }))
    .catch((error) => ({
      status: 500,
      body: "Something went wrong" + error,
    }));
}