(window.webpackJsonp=window.webpackJsonp||[]).push([[13],{480:function(e,t,s){"use strict";s.r(t);var a=s(63),o=Object(a.a)({},(function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[s("h1",{attrs:{id:"wolfeo-webhooks"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#wolfeo-webhooks"}},[e._v("#")]),e._v(" Wolfeo Webhooks")]),e._v(" "),s("p",[e._v("Wolfeo Webhooks allow you to receive a response from Wolfeo to a dedicated endpoint on your platform when an event happens.")]),e._v(" "),s("h1",{attrs:{id:"getting-started"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#getting-started"}},[e._v("#")]),e._v(" Getting Started")]),e._v(" "),s("p",[e._v("To get started using Wolfeo webhooks, visit "),s("a",{attrs:{href:"https://wolfeo.me/settings/developers",target:"_blank",rel:"noopener noreferrer"}},[e._v("wolfeo.me/settings/developers"),s("OutboundLink")],1),e._v(" and click on the button to create a new webhook. Enter an endpoint for your app to consume, and Wolfeo will send POST requests with a payload containing the event information to that route.")]),e._v(" "),s("h1",{attrs:{id:"receiving-webhooks"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#receiving-webhooks"}},[e._v("#")]),e._v(" Receiving Webhooks")]),e._v(" "),s("p",[e._v("To receive webhooks on your platform, create a POST route for example")]),e._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v('"https://mysite.com/wolfeo-webhooks"\n')])])]),s("p",[e._v("and save this route in the Developer Settings on Wolfeo. The route "),s("strong",[e._v("must")]),e._v(" have HTTPS.")]),e._v(" "),s("h1",{attrs:{id:"signing-requests"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#signing-requests"}},[e._v("#")]),e._v(" Signing Requests")]),e._v(" "),s("p",[e._v("When a new webhook is created on Wolfeo, we will automatically generate a client-secret key used to sign your requests. This is visible in your Developer Webhook Settings and is used to confirm the validity of our request. You do not need to add additional authorisation headers to manage signing. It is provided out-of-the-box.")]),e._v(" "),s("h2",{attrs:{id:"verifying-requests"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#verifying-requests"}},[e._v("#")]),e._v(" Verifying Requests")]),e._v(" "),s("p",[e._v("To test the received request and confirm it came from Wolfeo, you can use the sent payload and the signature to verify it. A PHP example is given below using the "),s("code",[e._v("hash_hmac")]),e._v(" function.")]),e._v(" "),s("div",{staticClass:"language-PHP extra-class"},[s("pre",{pre:!0,attrs:{class:"language-php"}},[s("code",[s("span",{pre:!0,attrs:{class:"token variable"}},[e._v("$requestPayload")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token string single-quoted-string"}},[e._v("'{}'")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[e._v("// Some JSON data sent by our webhook")]),e._v("\n"),s("span",{pre:!0,attrs:{class:"token variable"}},[e._v("$secretKey")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token string single-quoted-string"}},[e._v("'your-secret-key'")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[e._v("// Secret key found in Wolfeo developer settings")]),e._v("\n\n"),s("span",{pre:!0,attrs:{class:"token variable"}},[e._v("$signature")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[e._v("hash_hmac")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),s("span",{pre:!0,attrs:{class:"token string single-quoted-string"}},[e._v("'sha256'")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token variable"}},[e._v("$requestPayload")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token variable"}},[e._v("$secretKey")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[e._v("// Hash generated here should match hash sent by Wolfeo webhook")]),e._v("\n")])])])])}),[],!1,null,null,null);t.default=o.exports}}]);