Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): add webhook docs #1346

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ easily integrated into any web app with as little as two lines of code.
- [Rate Limiting](#rate-limiting)
- [Social logins](#social-logins)
- [User import](#user-import)
- [Webhooks](#webhooks)
- [API specification](#api-specification)
- [Configuration reference](#configuration-reference)
- [License](#license)
Expand Down Expand Up @@ -489,6 +490,39 @@ To import users run:
> hanko user import -i ./path/to/import_file.json


### Webhooks

#### Events
Webhooks are an easy way to get informed about changes in your Hanko instance (e.g. user or email updates).
Hanko provides the following event structure:

| Event | Triggers on |
|---------------------------|----------------------------------------------------------------------------------------------------|
| user | user creation, user deletion, user update, email creation, email deletion, change of primary email |
| user.create | user creation |
| user.delete | user deletion |
| user.update | user update, email creation, email deletion, change of primary email |
| user.update.email | email creation, email deletion, change of primary email |
| user.update.email.create | email creation |
| user.update.email.delete | email deletion |
| user.update.email.primary | change of primary email |

As you can see, events can have subevents. You are able to filter which events you want to receive by either selecting
a parent event when you want to receive all subevents or selecting specific subevents.

#### Enabling Webhooks

You can activate webhooks by adding the following snippet to your configuration file:

```yaml
webhooks:
enabled: true
hooks:
- callback: <YOUR WEBHOOK ENDPOINT>
events:
- user
```

## API specification

- [Hanko Public API](https://docs.hanko.io/api/public)
Expand Down
72 changes: 71 additions & 1 deletion backend/docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,77 @@ saml:
phone: "<PHONE_ATTRIBUTE_IN_IDP_ASSERTION>"
##
#
# E-Phone Verified - attribute of the user
# Phone Verified - attribute of the user
#
phone_verified: "<PHONE_VERIFIED_ATTRIBUTE_IN_IDP_ASSERTION>"
##
#
# Webhook Config Section
#
webhooks:
##
#
# Enabled - Enables the webhook feature
#
enabled: false
##
#
# Allow timely expiration - Toggle for disabling webhooks when unused for 30 days (only for database webhooks)
#
allow_time_expiration: false
##
#
# Hooks - List of webhooks to inform when a change occurs
#
hooks:
##
#
# Callback - Endpoint URL to which the change data will be sent
#
- callback: "<YOUR WEBHOOK ENDPOINT URL>"
##
#
# Events - Webhook events to listen for
#
events:
##
#
# User - Triggers on: user creation, user deletion, user update, email creation, email deletion, change of primary email
#
- user
##
#
# User Creation - Triggers on: user creation
#
- user.create
##
#
# User Deletion - Triggers on: user deletion
#
- user.delete
##
#
# User Update - Triggers on: user update, email creation, email deletion, change of primary email
#
- user.update
##
#
# Email - Triggers on: email creation, email deletion, change of primary email
#
- user.update.email
##
#
# Email - Triggers on: email creation
#
- user.update.email.create
##
#
# Email - Triggers on: email deletion
#
- user.update.email.delete
##
#
# Email - Triggers on: change of primary email
#
- user.update.email.primary
```