Stateful Services (private release) Build composable event-driven data pipelines in minutes.

Request access

Webhook Basics

This tutorial assumes that fluvio is installed, and logged-in to InfinyOn Cloud. Follow the Quick Start to get set up.

Webhooks are special connectors with an associated external url. Users can send data to their topics via a HTTP POST request.

 

Create a Webhook via CLI

Copy this example Webhook config file and save it as example-webhook.yaml

# example-webhook.yaml
meta:
  name: my-webhook
  topic: my-webhook-topic 

# optional
webhook:
  outputParts: full
  outputType: json

Create the webhook using the example config file

$ fluvio cloud webhook create --config example-webhook.yaml

Your output should look similar to this. We’ll cover sending data to this url.

Webhook "my-webhook" created with url: https://infinyon.cloud/webhooks/v1/[random string]

If you need this url again, you can run this command to list your webhooks, and their urls.

$ fluvio cloud webhook list

Example output

 NAME        TOPIC             URL                                                      
 my-webhook  my-webhook-topic  https://infinyon.cloud/webhooks/v1/[random string]
 

Send data to webhook

We’ll be sending json data {"key": "value"} to our webhook using curl. Replace the url so [random string] matches your unique url. Keep this command close because we’ll refer to this example curl command later.

$ curl -v -X POST https://infinyon.cloud/webhooks/v1/[random string] -H "Content-Type: application/json" -d '{"key": "value"}'

Expected output is a long json request with the HTTP headers and body

{"headers":{"accept":"*/*","accept-encoding":"gzip","content-length":"16","content-type":"application/json","host":"infinyon.cloud","user-agent":"curl/7.88.1","x-forwarded-for":"..."},"body":{"key":"value"}}
 

Remove HTTP request headers from output

We don’t need the headers. Just the data we sent. We can update the output so it only includes body data.

Modify the outputParts value from our webhook config example-webhook.yaml to the value body

# example-webhook.yaml
meta:
  name: my-webhook
  topic: my-webhook-topic 

# optional
webhook:
  outputParts: body
  outputType: json

Run this command to update your webhook.

$ fluvio cloud webhook update -c example-webhook.yaml
Webhook "my-webhook" updated

Running the example curl command output only the body of the request. Our request data is included, but it was automatically modified so it can be a valid json value.

{"key": "value"}
 

Conclusion

You now know how to create and configure the output of Webhooks. Check out the Webhook Config reference to see how to configure other transformations.