diff --git a/docs/docs/api/routes/clients.md b/docs/docs/api/routes/clients.md index fff00d566..44d125f88 100644 --- a/docs/docs/api/routes/clients.md +++ b/docs/docs/api/routes/clients.md @@ -2,7 +2,7 @@ These endpoints relate to managing your Tachi API clients, such as creating new ones or deleting them. -For a detailed explaination on how to use the OAuth2 flow, you can check [Using OAuth2 With Tachi](../../tachi-server/infrastructure/oauth2.md) +For a detailed explaination on how to use the OAuth2 flow, you can check [Using OAuth2 With Tachi](../../tachi-server/infrastructure/oauth2.md). ***** diff --git a/docs/docs/api/webhooks/main.md b/docs/docs/api/webhooks/main.md new file mode 100644 index 000000000..290907efe --- /dev/null +++ b/docs/docs/api/webhooks/main.md @@ -0,0 +1,33 @@ +# About Webhooks + +Tachi supports webhooks. You can set a `webhookUri` as part of your +[Tachi API Client](../routes/clients.md). + +## Usage and Security + +When a given event happens on Tachi, your webhookUri will recieve a POST +request with some content and the type of event. + +You **MUST** validate that this request was from Tachi! Otherwise, anyone +could post fake data to your webhook URI and potentially compromise it. + +To secure your webhook implementation, Tachi will send an Authorization header with `Bearer CLIENT_SECRET`. You should check that that value aligns with your client secret. If it doesn't, someone might be trying to perform an attack! + +## Data Format + +Data is sent as follows: + +```json +{ + "type": "EVENT_TYPE", + "content": {} // Content specific to that EVENT_TYPE! +} +``` + +The current Events are: + +| Type | Description | +| :: | :: | +| `class-update/v1` | Fires whenever a user has had a class update positively, such as going from 9th Dan to 10th Dan. | +| `goal-achieved/v1` | Fires whenever a user has achieved a goal. | +| `milestone-achieved/v1` | Fires whenever a user has achieved a milestone. | diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index ba5d66a96..78fb5dafd 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -64,6 +64,9 @@ nav: - "api/routes/oauth2.md" - "api/routes/clients.md" + - Webhooks: + - "api/webhooks/main.md" + - Tachi Server Reference: - "tachi-server/overview.md" - "tachi-server/contributing.md"