diff --git a/app/docs/md/routing/api-routes/webhooks.md b/app/docs/md/routing/api-routes/webhooks.md new file mode 100644 index 00000000..315a1afe --- /dev/null +++ b/app/docs/md/routing/api-routes/webhooks.md @@ -0,0 +1,29 @@ +--- +title: Webhooks +--- + +A webhook is a method of augmenting or altering the behavior of a web page or web application with custom callbacks. + +You can use a api route to receive webhooks from third parties: + + + +```javascript +export async function post (req) { + try { + const data = req.body + // Process the webhook payload + // Validate payload, etc. + } catch (error) { + return { + status: 400, + } + } + + return { + status: 200, + } +} +``` + + diff --git a/app/docs/nav-data.mjs b/app/docs/nav-data.mjs index c9c44727..6747ab7f 100644 --- a/app/docs/nav-data.mjs +++ b/app/docs/nav-data.mjs @@ -59,7 +59,7 @@ export const data = [ path: '/docs/routing/api-routes/', label: 'API Routes', hasChildren: true, - items: [ 'middleware', 'tutorial' ], + items: [ 'middleware', 'tutorial', 'webhooks' ], }, ], },