-
Notifications
You must be signed in to change notification settings - Fork 40
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
Adds Webhook Documentation #205
Open
cforbes
wants to merge
9
commits into
SuperEvilMegacorp:master
Choose a base branch
from
cforbes:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6b03099
Webhook docs.
cforbes 4b2cbed
Added verification event.
cforbes 3a5086b
Added documentation for deleting a webhook.
cforbes 15fbc75
Added docs for updating a webhook.
cforbes 7216d5e
Added limits documentation.
cforbes 6834adc
Changed the order of sections.
cforbes 84d2171
Updated webhook docs with request signing info.
cforbes 492482e
Updated webhooks signing docs again.
cforbes 6e82fc4
Fixes json in sections.json
cforbes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
# Webhooks (Coming Soon!) | ||
|
||
Webhooks allow events to be sent to a specified url when an event matches the provided topic. | ||
|
||
## Topic | ||
|
||
A topic is composed of a subject, the subject's id, a verb, and an output type. For example the topic "player.examplePlayer.played.match" would receive events when a player with the id of examplePlayer played a match and the payload would be of type "match". | ||
|
||
### Supported Topics | ||
|
||
- player.playerId.played.match | ||
- webhook.webhookId.verify.event | ||
|
||
## Post a Webhook | ||
|
||
```shell | ||
curl -XPOST "https://api.dc01.gamelockerapp.com/shards/na/webhooks" \ | ||
-H "Authorization: Bearer <api-key>" \ | ||
-H "Accept: application/vnd.api+json" | ||
``` | ||
|
||
This endpoint creates a webhook | ||
|
||
Note: A verification event will be sent to the url (see supported events above). If the request does not succeed, the webhook will not be created. | ||
|
||
### HTTP Request | ||
|
||
`POST https://api.dc01.gamelockerapp.com/shards/shard_id/webhooks` | ||
|
||
### Parameters | ||
|
||
Parameter | Default | Description | ||
--------- | ------- | ----------- | ||
url | | The callback url (must be accepting requests when the webhook is stored and will receive a verification event) | ||
topic | | The subscription topic (i.e. player.ExamplePlayerID.playedMatch) | ||
|
||
## Get Webhooks | ||
|
||
```shell | ||
curl "https://api.dc01.gamelockerapp.com/webhooks \ | ||
-H "Authorization: Bearer <api-key>" \ | ||
-H "Accept: application/vnd.api+json" | ||
``` | ||
|
||
This endpoint returns all webhooks | ||
|
||
### HTTP Request | ||
|
||
`GET https://api.dc01.gamelockerapp.com/webhooks` | ||
|
||
### Query Parameters | ||
|
||
Parameter | Default | Description | ||
--------- | ------- | ----------- | ||
|
||
## Update Webhook | ||
|
||
```shell | ||
curl -XPUT "https://api.dc01.gamelockerapp.com/webhooks/{id} \ | ||
-H "Authorization: Bearer <api-key>" \ | ||
-H "Accept: application/vnd.api+json" | ||
``` | ||
|
||
This endpoint updates a webhook | ||
|
||
### HTTP Request | ||
|
||
`PUT https://api.dc01.gamelockerapp.com/webhooks/{id}` | ||
|
||
### Query Parameters | ||
|
||
Parameter | Default | Description | ||
--------- | ------- | ----------- | ||
id | | The id of the webhook as provided with the POST request to create it. | ||
|
||
## Delete Webhook | ||
|
||
```shell | ||
curl -XDELETE "https://api.dc01.gamelockerapp.com/webhooks/{id} \ | ||
-H "Authorization: Bearer <api-key>" \ | ||
-H "Accept: application/vnd.api+json" | ||
``` | ||
|
||
This endpoint removes a webhook | ||
|
||
### HTTP Request | ||
|
||
`DELETE https://api.dc01.gamelockerapp.com/webhooks/{id}` | ||
|
||
### Query Parameters | ||
|
||
Parameter | Default | Description | ||
--------- | ------- | ----------- | ||
id | | The id of the webhook as provided with the POST request to create it. | ||
|
||
## Limits | ||
|
||
The number of webhooks that can be created is limited to 100 per app. All create requests after the limit has been exceeded will return a response code of 400. | ||
|
||
## Webhook | ||
|
||
```json | ||
{ | ||
"attributes": { | ||
"url": "http://test.callbackurl.com", | ||
"topic": "player.playerId.playedMatch" | ||
}, | ||
"id": "fb374a7b-78be-4fcc-83ed-6a532a8a6f55", | ||
"type": "webhook" | ||
} | ||
``` | ||
|
||
## Event | ||
|
||
### Authorization | ||
|
||
For signing requests we use the HMAC authentication scheme (similar to AWS) with your JWT used as the secret. | ||
|
||
The authorization header is in the following format: | ||
|
||
``` | ||
Authorization: gamelocker APP:SIGNATURE | ||
``` | ||
|
||
The signature includes the following: | ||
|
||
- request method | ||
- Content-MD5 header | ||
- Content-Type header | ||
- Date header | ||
- request url path | ||
|
||
Note: Content-MD5 is the md5 sum of the request body and can be used to verify that the body has not been modified. | ||
|
||
### Payload | ||
|
||
```json | ||
{ | ||
"attributes": { | ||
"topic": "player.playerId.played.match" | ||
"payload": "{"type":"match"}" | ||
}, | ||
"id": "fb374a7b-78be-4fcc-83ed-6a532a8a6f55", | ||
"type": "event" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we refer to 'supported events', where as previously we referred to 'supported topics'. Should we keep terminology the same?