Hello,
I am using a webhook to revalidate the cache of certain Dato models using an API route in a Next.js project. So I use the custom payload to pass my page slug. So far, so good.
Except that in some cases, my slugs have a prefix, defined in my Next.js project:
const PROGRAM_SLUG_PREFIX = 'programmes/'
This constant is mapped to an object, with Dato’s model API key as the key:
const slugPrefixes = {
program: PROGRAM_SLUG_PREFIX
}
In my current webhook, here is my payload:
{
"entity": "{{entity}}",
"path": "/programmes/{{#entity}}{{#attributes}}{{slug}}{{/attributes}}{{/entity}}"
}
It works, but I have to create as many webhooks as there are Dato models and enter the prefix manually. I would like to be able to retrieve the _modelApiKey dynamically from the webhook’s triggered record, but when I inspect the entity’s content, I don’t have a _modelApiKey in the meta key, as shown in the documentation.
Here is the meta content after my webhook trigger:
"meta": {
"created_at": "2025-08-20T10:19:14.237+02:00",
"updated_at": "2025-10-13T17:55:56.195+02:00",
"published_at": "2025-10-13T17:55:57.836+02:00",
"publication_scheduled_at": null,
"unpublishing_scheduled_at": null,
"first_published_at": "2025-08-30T00:00:02.545+02:00",
"is_valid": true,
"is_current_version_valid": true,
"is_published_version_valid": true,
"has_children": null,
"status": "published",
"current_version": "dSsTa9gkRySYK3iw6GosEQ",
"stage": null
}
Would it be possible to include it, please? Or do you have another idea?
Thank you in advance.