https://github.com/keygen-sh/example-webhook-handler
An example Node.js app that handles webhook events from Keygen
https://github.com/keygen-sh/example-webhook-handler
keygen platform-example sample-code webhook-events webhook-handler webhook-server
Last synced: 6 months ago
JSON representation
An example Node.js app that handles webhook events from Keygen
- Host: GitHub
- URL: https://github.com/keygen-sh/example-webhook-handler
- Owner: keygen-sh
- License: mit
- Created: 2018-01-02T17:33:50.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T18:59:28.000Z (about 3 years ago)
- Last Synced: 2025-06-30T00:38:32.262Z (6 months ago)
- Topics: keygen, platform-example, sample-code, webhook-events, webhook-handler, webhook-server
- Language: JavaScript
- Homepage: https://keygen.sh
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Example Keygen Webhook Handler
The following web app is written in Node.js and shows how to set up a simple
webhook handler for [Keygen](https://keygen.sh), allowing you to listen for
and act upon particular events on your Keygen account.
> **This example application is not 100% production-ready**, but it should
> get you 90% of the way there. You may need to add additional logging,
> error handling, validation, features, etc.
## Running the app
First up, configure a few environment variables:
```bash
# Your Keygen account's Ed25519 verify key
export KEYGEN_VERIFY_KEY="YOUR_KEYGEN_ED25519_VERIFY_KEY"
# Your Keygen account ID.
export KEYGEN_ACCOUNT_ID="YOUR_KEYGEN_ACCOUNT_ID"
```
You can either run each line above within your terminal session before
starting the app, or you can add the above contents to your `~/.bashrc`
file and then run `source ~/.bashrc` after saving the file.
Next, install dependencies with [`yarn`](https://yarnpkg.comg):
```
yarn
```
Then start the app:
```
yarn start
```
## Testing webhooks locally
For local development, create an [`ngrok`](https://ngrok.com) tunnel:
```
ngrok http 8080
```
Next up, add the secure `ngrok` URL to your Keygen account to listen
for webhook events.
1. **Keygen:** add `https://{YOUR_NGROK_URL}/keygen` to https://app.keygen.sh/webhook-endpoints
You can now create events within your Keygen account, e.g. create a new
license, and the webhook event will be sent to your local server.
## Questions?
Reach out at [support@keygen.sh](mailto:support@keygen.sh) if you have any
questions or concerns!