apaleo / announcements

Subscribe to this repo to be notified about changes in the apaleo API
15 stars 1 forks source link

Webhook Improvements #104

Open edkarhuber opened 1 year ago

edkarhuber commented 1 year ago

New Webhook Improvements 🎉

Today we are happy to announce new updates for webhooks that we recently released.

Events subscription⚡

The main one is the ability to subscribe to specific events. You no longer need to receive notifications that you are not interested in. Now when you create a subscription you should use events field to specify the list of events, like that:

{
  "endpointUrl": "https://example.com",
  "events": [
    "reservation/created",
    "reservation/changed",
    "folio/created"
  ],
  "propertyIds": [
    ...
  ]
}

However, if you want to subscribe to all events for a specific topic it's still possible to do so by using a wildcard: {topic}/*. Check this example:

{
  "endpointUrl": "https://example.com",
  "events": [
    "reservation/*",
    "folio/*"
  ],
  "propertyIds": [
    ...
  ]
}

It is important to note that all existing subscriptions have already been migrated to the new configuration, but despite this, the former topics field is still available, so you can create and update subscriptions by using this topic field.

⚠️ This topics field is going to be deprecated on March 15, 2023. Please ensure you use events instead of topics in your code before that date. Here is the list of affected webhook API endpoints: GET /v1/subscriptions POST /v1/subscriptions/ GET /v1/subscriptions/{id} PUT /v1/subscriptions/{id}

Tracking ID 🔎

In addition, starting from now the webhook notification request is going to contain an apaleo-tracking-id header which contains the tracking Id of the request that initiated the event. It can be useful if you want to track the whole flow from sending the first request to being notified that this request has changed something in the platform.

Enjoy the use!

Check the updated documentation for webhooks in the Developer Documentation.

chrisonline commented 1 year ago

Does this also affect the https://distribution.apaleo.com/v1/subscriptions ?

edkarhuber commented 1 year ago

Hi @chrisonline no, it doesn't affect distribution subs, only the ones from webhook API:

GET /v1/subscriptions POST /v1/subscriptions/ GET /v1/subscriptions/{id} PUT /v1/subscriptions/{id}

edkarhuber commented 1 year ago

All announcements have been moved to our community portal: https://community.apaleo.com In case you have any questions regarding new webhook improvements, feel free to ask here: https://community.apaleo.com/c/dev-announcements/new-webhook-improvements

ghost commented 1 year ago

@edkarhuber sorry for bothering, just want to clarify, in webhook payload we are still going to receive topic, not the event?

edkarhuber commented 1 year ago

Hey @GodDmitrii yes, you're right - no changes here. All webhook notifications have the same payload as before. Otherwise, this would break all subscribers. As before, payload details are described here: https://apaleo.dev/guides/webhook/webhooks-payload.html