1"use strict";(self.webpackChunkfluvio_docs=self.webpackChunkfluvio_docs||[]).push([[129],{59994:(e,o,n)=>{n.r(o),n.d(o,{assets:()=>r,contentTitle:()=>i,default:()=>h,frontMatter:()=>a,metadata:()=>l,toc:()=>c});var t=n(74848),s=n(28453);const a={title:"Use Webhooks",description:"A short guide on using Cloud Webhooks",sidebar_position:2},i=void 0,l={id:"cloud/how-to/use-webhooks",title:"Use Webhooks",description:"A short guide on using Cloud Webhooks",source:"@site/versioned_docs/version-0.18.1/cloud/how-to/use-webhooks.mdx",sourceDirName:"cloud/how-to",slug:"/cloud/how-to/use-webhooks",permalink:"/docs/cloud/how-to/use-webhooks",draft:!1,unlisted:!1,editUrl:"https://github.com/infinyon/fluvio-docs/tree/main/versioned_docs/version-0.18.1/cloud/how-to/use-webhooks.mdx",tags:[],version:"0.18.1",lastUpdatedBy:"Felipe Cardozo",lastUpdatedAt:1752028303e3,sidebarPosition:2,frontMatter:{title:"Use Webhooks",description:"A short guide on using Cloud Webhooks",sidebar_position:2},sidebar:"cloud",previous:{title:"Use Connectors",permalink:"/docs/cloud/how-to/use-connectors"},next:{title:"Use WebSocket Gateway",permalink:"/docs/cloud/how-to/use-ws-gateway"}},r={},c=[{value:"Webhook Configuration",id:"webhook-configuration",level:2},{value:"Create a simple Webhook",id:"create-a-simple-webhook",level:2},{value:"Send data to webhook",id:"send-data-to-webhook",level:3},{value:"Create a JSON Webhook and embed HTTP parts",id:"create-a-json-webhook-and-embed-http-parts",level:2},{value:"Webhook Path and Query info",id:"webhook-path-and-query-info",level:3},{value:"Conclusion",id:"conclusion",level:2}];function d(e){const o={a:"a",admonition:"admonition",code:"code",em:"em",h2:"h2",h3:"h3",p:"p",pre:"pre",...(0,s.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(o.p,{children:["This guide assumes that ",(0,t.jsx)(o.code,{children:"fluvio"})," is installed, and logged-in to InfinyOn Cloud. Follow the ",(0,t.jsx)(o.a,{href:"/docs/cloud/quickstart",children:"Quick Start"})," to get set up."]}),"\n",(0,t.jsxs)(o.p,{children:["Webhooks are special connectors with an associated external url. Users can send data to their topics via a ",(0,t.jsx)(o.code,{children:"HTTP PO
1ST"})," request."]}),"\n",(0,t.jsx)(o.h2,{id:"webhook-configuration",children:"Webhook Configuration"}),"\n",(0,t.jsx)(o.p,{children:"The webhook configuration file has the following structure:"}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{className:"language-yaml",children:"meta:\n name: my-webhook # required\n topic: my-webhook # required\n logLevel: debug # default: info, options: [trace, debug, info, warn, error]\n secrets:\n - name: my-key\n producer:\n linger: 100ms\n batch-size: 1mb\n compression: snappy # default: none, options: [none, gzip, snappy, lz4, zstd]\nwebhook:\n outputParts: full # default: body, options: [full, body]\n outputType: json # default: text, options: [text, json]\n outputUri: full # default: none, options: [full, none, path, query]\ntransforms:\n - uses: infinyon/[email protected]\n with:\n key: ${{ secrets.my_key }}\n"})}),"\n",(0,t.jsxs)(o.p,{children:["The minimum configuration has needs the top 2 required fields: ",(0,t.jsx)(o.code,{children:"name"})," and ",(0,t.jsx)(o.code,{children:"topic"}),". The ",(0,t.jsx)(o.code,{children:"name"})," is the name of the webhook, and the ",(0,t.jsx)(o.code,{children:"topic"})," is the topic that the webhook will publish to."]}),"\n",(0,t.jsx)(o.h2,{id:"create-a-simple-webhook",children:"Create a simple Webhook"}),"\n",(0,t.jsx)(o.p,{children:"Let's create an example configuration file"}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{className:"language-yaml",children:"# example-webhook.yaml\nmeta:\n name: my-webhook\n topic: my-webhook-topic\n"})}),"\n",(0,t.jsx)(o.p,{children:"Add a webhook to InfinyOn Cloud"}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{className:"language-shell",metastring:'copy="fl"',children:"$ fluvio cloud webhook create --config example-webhook.yaml\n"})}),"\n",(0,t.jsx)(o.p,{children:"Your output should look similar to this. We'll cover sending data to this url."}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{children:'Webhook "my-webhook" created with url: https://infinyon.cloud/webhooks/v1/[random string]\n'})}),"\n",(0,t.jsx)(o.p,{children:"If you need this url again, you can run this command to list your webhooks, and their urls."}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{className:"language-shell",metastring:'copy="fl"',children:"$ fluvio cloud webhook list\n"})}),"\n",(0,t.jsx)(o.p,{children:"Example output"}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{children:" NAME TOPIC URL\n my-webhook my-webhook-topic https://infinyon.cloud/webhooks/v1/[random string]\n"})}),"\n",(0,t.jsx)(o.h3,{id:"send-data-to-webhook",children:"Send data to webhook"}),"\n",(0,t.jsxs)(o.p,{children:["We'll be sending json data ",(0,t.jsx)(o.code,{children:'{"key": "value"}'})," to our webhook using ",(0,t.jsx)(o.code,{children:"curl"}),". Replace the url so ",(0,t.jsx)(o.code,{children:"[random string]"})," matches your unique url. Keep this command close because we'll refer to this example curl command later."]}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{className:"language-shell",metastring:'copy="fl"',children:"$ curl -v -X POST -d 'Hello World!' https://infinyon.cloud/webhooks/v1/[uri-key]\n"})}),"\n",(0,t.jsx)(o.p,{children:"In another terminal, star a consumer that reads form the beginning:"}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{className:"language-shell",metastring:'copy="fl"',children:"$ fluvio consume my-webhook-topic -B\n"})}),"\n",(0,t.jsx)(o.p,{children:"We should see the following output:"}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{className:"language-bash",children:"Hello World!\n"})}),"\n",(0,t.jsx)(o.h2,{id:"create-a-json-webhook-and-embed-http-parts",children:"Create a JSON Webhook and embed HTTP parts"}),"\n",(0,t.jsxs)(o.p,{children:["Next we'll send json records, but before we do that we'll modify ",(0,t.jsx)(o.code,{children:"outputParts"}),", ",(0,t.jsx)(o.code,{children:"outputType"}),", and ",(0,t.jsx)(o.code,{children:"outputUri"})," in the ",(0,t.jsx)(o.code,{children:"example-webhook.yaml"})," configuration file:"]}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{className:"language-yaml",children:"# example-webhook.yaml\nmeta:\n name: my-webhook\n topic: my-webhook-topic\n\nwebhook:\n outputParts: full\n outputType: json\n outputUri: full\n"})}),"\n",(0,t.jsx)(o.p,{children:"Run this command to update your webhook."}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{className:"language-shell",children:'$ fluvio cloud webhook update --config example-webhook.yaml\nWebhook "my-webhook" updated\n'})}),"\n",(0,t.jsx)(o.p,{children:"Let's restart the consumer to a JSON formatter:"}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{className:"language-shell",children:"$ fluvio consume my-webhook-topic -O json\n"})}),"\n",(0,t.jsxs)(o.p,{children:["Run another curl with a ",(0,t.jsx)(o.code,{children:"json"})," payload:"]}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{className:"language-bash",children:'$ curl -v -X POST -H "Content-Type: application/json" -d \'{"key": "value"}\' https://infinyon.cloud/webhooks/v1/[uri-key]\n'})}),"\n",(0,t.jsx)(o.p,{children:"The consumer should now show the following output:"}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{className:"language-json",children:'{\n "body": {\n "ke
1y": "value"\n },\n "headers": {\n "accept": "*/*",\n "accept-encoding": "gzip, br",\n "content-length": "16",\n "content-type": "application/json",\n "host": "infinyon.cloud",\n "user-agent": "curl/x.y.z",\n "x-forwarded-for": "..."\n },\n "path": "",\n "query": ""\n}\n'})}),"\n",(0,t.jsx)(o.h3,{id:"webhook-path-and-query-info",children:"Webhook Path and Query info"}),"\n",(0,t.jsxs)(o.p,{children:["A curl with path and query info to ",(0,t.jsx)(o.code,{children:"https://infinyon.cloud/webhooks/v1/[uri-key]/path_a/path_b?param_a=1¶m_b=2"})," can be sent as follows: ",(0,t.jsx)(o.em,{children:"(note the single quotes around the URI)"})]}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{className:"language-bash",children:'$ curl -v -X POST -H "Content-Type: application/json" -d \'{"key": "value"}\' \\\n \'https://infinyon.cloud/webhooks/v1/[uri-key]/path_a/path_b?param_a=1¶m_b=2\'\n'})}),"\n",(0,t.jsx)(o.p,{children:"The consumer should show return path and query information as follows:"}),"\n",(0,t.jsx)(o.pre,{children:(0,t.jsx)(o.code,{className:"language-json",children:'{\n "body": {\n "key": "value"\n },\n "headers": {\n "accept": "*/*",\n "accept-encoding": "gzip, br",\n "content-length": "16",\n "content-type": "application/json",\n "host": "infinyon.cloud",\n "user-agent": "curl/x.y.z",\n "x-forwarded-for": "..."\n },\n "path": "path_a/path_b",\n "query": "param_a=1¶m_b=2"\n}\n'})}),"\n",(0,t.jsx)(o.admonition,{type:"note",children:(0,t.jsxs)(o.p,{children:["Json output is the recommended way to receive uri ",(0,t.jsx)(o.code,{children:"path"})," and ",(0,t.jsx)(o.code,{children:"query"})," information\nso that Smartmodule transformation can be directly applied. See ",(0,t.jsx)(o.a,{href:"/docs/cloud/concepts/webhook-config",children:"Webhook Config"})," for more details."]})}),"\n",(0,t.jsx)(o.h2,{id:"conclusion",children:"Conclusion"}),"\n",(0,t.jsxs)(o.p,{children:["You now know how to create and configure the output of Webhooks. Check out the ",(0,t.jsx)(o.a,{href:"/docs/cloud/concepts/webhook-config",children:"Webhook Config"})," reference to see how to configure other transformations."]})]})}function h(e={}){const{wrapper:o}={...(0,s.R)(),...e.components};return o?(0,t.jsx)(o,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}},28453:(e,o,n)=>{n.d(o,{R:()=>i,x:()=>l});var t=n(96540);const s={},a=t.createContext(s);function i(e){const o=t.useContext(a);return t.useMemo((function(){return"function"==typeof e?e(o):{...o,...e}}),[o,e])}function l(e){let o;return o=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),t.createElement(a.Provider,{value:o},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.