Subscribe a webhook to an event.
curl --request POST \
--url https://www.smashandclash.in/api/v1/games/events/subscribe \
--header 'Content-Type: application/json' \
--data '
{
"name": "game.turn",
"arguments": {
"game_id": "g_abcdefgh12",
"player_token": "pt_…"
},
"delivery": {
"url": "<string>",
"secret": "<string>",
"mode": "webhook"
},
"ttlMs": 123
}
'import requests
url = "https://www.smashandclash.in/api/v1/games/events/subscribe"
payload = {
"name": "game.turn",
"arguments": {
"game_id": "g_abcdefgh12",
"player_token": "pt_…"
},
"delivery": {
"url": "<string>",
"secret": "<string>",
"mode": "webhook"
},
"ttlMs": 123
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'game.turn',
arguments: {game_id: 'g_abcdefgh12', player_token: 'pt_…'},
delivery: {url: '<string>', secret: '<string>', mode: 'webhook'},
ttlMs: 123
})
};
fetch('https://www.smashandclash.in/api/v1/games/events/subscribe', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.smashandclash.in/api/v1/games/events/subscribe",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'game.turn',
'arguments' => [
'game_id' => 'g_abcdefgh12',
'player_token' => 'pt_…'
],
'delivery' => [
'url' => '<string>',
'secret' => '<string>',
'mode' => 'webhook'
],
'ttlMs' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.smashandclash.in/api/v1/games/events/subscribe"
payload := strings.NewReader("{\n \"name\": \"game.turn\",\n \"arguments\": {\n \"game_id\": \"g_abcdefgh12\",\n \"player_token\": \"pt_…\"\n },\n \"delivery\": {\n \"url\": \"<string>\",\n \"secret\": \"<string>\",\n \"mode\": \"webhook\"\n },\n \"ttlMs\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.smashandclash.in/api/v1/games/events/subscribe")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"game.turn\",\n \"arguments\": {\n \"game_id\": \"g_abcdefgh12\",\n \"player_token\": \"pt_…\"\n },\n \"delivery\": {\n \"url\": \"<string>\",\n \"secret\": \"<string>\",\n \"mode\": \"webhook\"\n },\n \"ttlMs\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.smashandclash.in/api/v1/games/events/subscribe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"game.turn\",\n \"arguments\": {\n \"game_id\": \"g_abcdefgh12\",\n \"player_token\": \"pt_…\"\n },\n \"delivery\": {\n \"url\": \"<string>\",\n \"secret\": \"<string>\",\n \"mode\": \"webhook\"\n },\n \"ttlMs\": 123\n}"
response = http.request(request)
puts response.read_body{
"id": "sub_3f2a…",
"refreshBefore": "2023-11-07T05:31:56Z",
"cursor": null,
"truncated": true
}{
"status": 123,
"error": "<string>",
"code": "bad_request",
"hint": "<string>",
"type": "<string>",
"title": "<string>",
"detail": "<string>",
"docs": "<string>"
}{
"status": 123,
"error": "<string>",
"code": "bad_request",
"hint": "<string>",
"type": "<string>",
"title": "<string>",
"detail": "<string>",
"docs": "<string>"
}{
"status": 123,
"error": "<string>",
"code": "bad_request",
"hint": "<string>",
"type": "<string>",
"title": "<string>",
"detail": "<string>",
"docs": "<string>"
}{
"status": 123,
"error": "<string>",
"code": "bad_request",
"hint": "<string>",
"type": "<string>",
"title": "<string>",
"detail": "<string>",
"docs": "<string>"
}events
Subscribe a webhook to an event.
Verifies the callback first: it POSTs {"type":"verification","challenge":"..."} (signed) and your endpoint must answer 2xx with {"challenge":"..."} within 5 s. Idempotent: the same event, arguments and URL name the same subscription, and subscribing again refreshes it (and replaces the secret). If the condition already holds (it is already your turn, the game already ended), the event fires at once. game.turn needs the seat's player_token, which is checked and never stored.
POST
/
games
/
events
/
subscribe
Subscribe a webhook to an event.
curl --request POST \
--url https://www.smashandclash.in/api/v1/games/events/subscribe \
--header 'Content-Type: application/json' \
--data '
{
"name": "game.turn",
"arguments": {
"game_id": "g_abcdefgh12",
"player_token": "pt_…"
},
"delivery": {
"url": "<string>",
"secret": "<string>",
"mode": "webhook"
},
"ttlMs": 123
}
'import requests
url = "https://www.smashandclash.in/api/v1/games/events/subscribe"
payload = {
"name": "game.turn",
"arguments": {
"game_id": "g_abcdefgh12",
"player_token": "pt_…"
},
"delivery": {
"url": "<string>",
"secret": "<string>",
"mode": "webhook"
},
"ttlMs": 123
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'game.turn',
arguments: {game_id: 'g_abcdefgh12', player_token: 'pt_…'},
delivery: {url: '<string>', secret: '<string>', mode: 'webhook'},
ttlMs: 123
})
};
fetch('https://www.smashandclash.in/api/v1/games/events/subscribe', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.smashandclash.in/api/v1/games/events/subscribe",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'game.turn',
'arguments' => [
'game_id' => 'g_abcdefgh12',
'player_token' => 'pt_…'
],
'delivery' => [
'url' => '<string>',
'secret' => '<string>',
'mode' => 'webhook'
],
'ttlMs' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.smashandclash.in/api/v1/games/events/subscribe"
payload := strings.NewReader("{\n \"name\": \"game.turn\",\n \"arguments\": {\n \"game_id\": \"g_abcdefgh12\",\n \"player_token\": \"pt_…\"\n },\n \"delivery\": {\n \"url\": \"<string>\",\n \"secret\": \"<string>\",\n \"mode\": \"webhook\"\n },\n \"ttlMs\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.smashandclash.in/api/v1/games/events/subscribe")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"game.turn\",\n \"arguments\": {\n \"game_id\": \"g_abcdefgh12\",\n \"player_token\": \"pt_…\"\n },\n \"delivery\": {\n \"url\": \"<string>\",\n \"secret\": \"<string>\",\n \"mode\": \"webhook\"\n },\n \"ttlMs\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.smashandclash.in/api/v1/games/events/subscribe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"game.turn\",\n \"arguments\": {\n \"game_id\": \"g_abcdefgh12\",\n \"player_token\": \"pt_…\"\n },\n \"delivery\": {\n \"url\": \"<string>\",\n \"secret\": \"<string>\",\n \"mode\": \"webhook\"\n },\n \"ttlMs\": 123\n}"
response = http.request(request)
puts response.read_body{
"id": "sub_3f2a…",
"refreshBefore": "2023-11-07T05:31:56Z",
"cursor": null,
"truncated": true
}{
"status": 123,
"error": "<string>",
"code": "bad_request",
"hint": "<string>",
"type": "<string>",
"title": "<string>",
"detail": "<string>",
"docs": "<string>"
}{
"status": 123,
"error": "<string>",
"code": "bad_request",
"hint": "<string>",
"type": "<string>",
"title": "<string>",
"detail": "<string>",
"docs": "<string>"
}{
"status": 123,
"error": "<string>",
"code": "bad_request",
"hint": "<string>",
"type": "<string>",
"title": "<string>",
"detail": "<string>",
"docs": "<string>"
}{
"status": 123,
"error": "<string>",
"code": "bad_request",
"hint": "<string>",
"type": "<string>",
"title": "<string>",
"detail": "<string>",
"docs": "<string>"
}Body
application/json