How Do I Trigger An Event From A Bash Shell Script?

This solution was originally taken from this StackOverflow answer.

Please note that it is essential that you validate the parameters you are sending if the content of your events are user generated.

Please also note that the channel name, event name and event data used in the following example is hard-coded and you would need to extract that into a parameter.

Finally update the values for key, secret, appId and cluster. The list of clusters can be found here



timestamp=$(date +%s)
# Be sure to use `printf %s` to prevent a trailing \n from being added to the data.
md5data=$(printf '%s' "$data" | md5)


# Be sure to use a multi-line, double quoted string that doesn't end in \n as 
# input for the SHA-256 HMAC.
authSig=$(printf '%s' "POST
$queryString" | openssl dgst -sha256 -hex -hmac "$secret")

curl -H "Content-Type:application/json" -d "$data" "https://api-${cluster}${path}?${queryString}&auth_signature=${authSig}"

Still have questions? Please reach out to our Support team by visiting this page.

Last updated