Say I have a Content Type Book
with a text field Title
and a reference field Author
, which in turn has it's own fields Name
(text) and Headshot
(media - image).
I want to set up a webhook that fires whenever a Book
is created or updated, and I want the payload to include all of the fields, including the nested reference Author
fields.
When using the Content Delivery API, I know that I can specify an include
property to specify how many nested levels of reference fields I want returned, like so:
await client.getEntries({
content_type: 'book',
include: 2
});
I'm wondering if it's possible to specify something similar in the webhook payload configuration object in order to have the payload itself contain nested reference field properties, rather than just it's sys
fields.
If this is not possible, then how should I approach requesting the nested field properties? If I do a new request with the reference's ID, is it guaranteed to exist or will I have to wait the 5 minutes it takes for the CDN changes to propagate?
Thanks in advance!
The references are not included in the webhook payload and you will have to make a separate request based on the id of the reference field.
If can't wait for the CDN to propagate (which should only take at most a minute) you could always query the reference through the management API. Remember though that the management API calls are more costly as they are not cached. If possible I would suggest waiting until the CDN propagation has completed and query the reference at that time.