Webhooks Guide
The webhooks are free to use, but it costs money to run and maintain, if you can, please contribute.
- The following webhook types are available:
newBasho- contains start/end date and bashoId. Sent once when a new banzuke is released - typically 2 weeks before the start of the basho.newMatches- contains an array of match objects from one division. Sent whenever a new torikumi is discovered for that division - typically after 18:00 JST each day of a basho. One webhook is sent per subscribed division.matchResults- contains an array of match objects from one division containing all match details including the winner and winnerId. Sent once per day at 18:10 JST. One webhook is sent per subscribed division.endBasho- contains the basho object with the yusho and special prize details included. Send once when the basho concludes at 18:15 JST on the final day.newMatchesandmatchResultsare subscribed per division using an object. The divisions aremakuuchi,juryo,makushita,sandanme,jonidanandjonokuchi(any letter case is accepted). Divisions that are omitted or set tofalseare not sent.newBashoandendBashoremaintrue/false. Each match object contains its division. UsingtrueorfalsefornewMatchesormatchResultsis not accepted and will fail with a 400 error.- Other types can be added upon request.
- When a webhook is issued by sumo-api a POST request will be sent to the subscribed endpoints. Please see the details of the requests below:
- Return a 204 response from your webhook endpoint to acknowledge reciept of the webhook.
- A webhook sent from sumo-api will always contain the following header:
X-Webhook-Signature
This header is derived from your secret and the payload. Please use this to verify that this is a genuine request from the sumo-api. - Verification example snippet in Golang
hmacHash := hmac.New(sha256.New, yourSecret) hmacHash.Write([]byte(url)) hmacHash.Write(body) calculatedSignature := hex.EncodeToString(hmacHash.Sum(nil)) if incomingHeaderSignature != calculatedSignature { //invalid signature } - The webhook body will contain a JSON object in the following format:
{ "type":"webhook type (see list)", "payload":"some JSON object depending on the type. Execute tests to see the formats" } - How to Subscribe to webhooks
- POST
/api/webhook/subscribe - Body of request must contain a valid JSON object in the following format:
{ "name":"someUniqueIdentifier", "destination":"http://www.yourdomain.com/webhookIngestionEndpoint", "secret":"your secret to encode the response", "subscriptions":{ "newBasho":true, "endBasho":false, "newMatches":{"makuuchi":true,"juryo":true}, "matchResults":{"makuuchi":true,"juryo":true,"makushita":true} } }
- POST
- How to modify your subscription to webhooks
- PATCH
/api/webhook/subscribe - Body of request must contain a valid JSON object in the following format:
{ "name":"someUniqueIdentifier", "destination":"http://www.yourdomain.com/webhookIngestionEndpoint", "secret":"your secret to encode the response", "subscriptions":{ "newBasho":true, "newMatches":{"makuuchi":true,"juryo":false}, "matchResults":{"makuuchi":true} } } - If the provided name and secret do not match, your update will fail with 400 error
- PATCH
- How to delete your subscription to webhooks
- DELETE
/api/webhook/subscribe - Body of request must contain a valid JSON object in the following format:
{ "name":"someUniqueIdentifier", "secret":"your secret to encode the response", } - If the provided name and secret do not match, your delete will fail with 400 error
- DELETE
- How to test webhooks subscriptions
- POST
/api/webhook/test?type=newMatches&division=juryo - Body of request must contain a valid JSON object in the following format:
{ "name":"someUniqueIdentifier", "destination":"http://www.yourdomain.com/webhookIngestionEndpoint", "secret":"your secret to encode the response", "subscriptions":{ "newMatches":{"juryo":true} } } - The test hooks always send the same data, read from the live database for the 202311 basho.
- The
typein the URL and in thesubscriptionsobject must match. - For
newMatchesandmatchResults, the optionaldivisionin the URL (defaultmakuuchi) must also be set totruein thesubscriptionsobject.
- POST