Skip to main content

Webhooks

For every parsed match of your player we send an update to your address. Below: the request format, signature verification, retries and what to do if the webhook is disabled.

Address​

  • All updates go to one address, which you set on the "Webhook settings" page. One account, one address.
  • The address must start with https://.
  • The same page sets the webhook token, at least 16 characters. Every request is signed with it.

Request format​

  • Method POST, JSON body (Content-Type: application/json).
  • One update per request. There are no batches.
  • Header Authorization: Bearer <webhook token>.
  • The signature is in the X-Nickname-Timestamp and X-Nickname-Signature headers (see Verifying signatures). The header names come from the service's former name and will not change.

Example request​

POST /your-webhook-endpoint HTTP/1.1
Authorization: Bearer YOUR_WEBHOOK_TOKEN
Content-Type: application/json
X-Nickname-Timestamp: 1793600000
X-Nickname-Signature: sha256=HMAC_SHA256_HEX

{
"id": "550e8400-e29b-41d4-a716-446655440000",
"event": "game_parsed",
"payload": {
"game": { "...": "..." },
"player": { "...": "..." }
}
}
  • id is the update identifier (UUID), used to drop repeats.
  • event is the event type. There is one event today: game_parsed.
  • payload is the event data.

Verifying signatures​

Every request is signed with your webhook token using HMAC-SHA256. Checking the signature proves that the request came from us and that its body was not changed. We recommend it over comparing the Authorization header: a signature seen in your logs cannot be used to forge another request.

To verify a request:

  1. Read the raw request body exactly as received, before any JSON parsing.
  2. Build the signed string: the X-Nickname-Timestamp value, a dot, then the raw body.
  3. Compute HMAC-SHA256 of that string with your webhook token as the key, in lowercase hex.
  4. Compare sha256=<your result> with X-Nickname-Signature using a constant-time comparison.
  5. Reject the request if the timestamp is more than 5 minutes away from your current time. This stops an old captured request from being sent again.

PHP example​

$body = file_get_contents('php://input');
$timestamp = $_SERVER['HTTP_X_NICKNAME_TIMESTAMP'] ?? '';
$signature = $_SERVER['HTTP_X_NICKNAME_SIGNATURE'] ?? '';

$expected = 'sha256='.hash_hmac('sha256', $timestamp.'.'.$body, $webhookToken);

if (! hash_equals($expected, $signature) || abs(time() - (int) $timestamp) > 300) {
http_response_code(401);
exit;
}

$update = json_decode($body, true);

Repeated updates​

The same update may arrive twice, for example if you processed it but did not answer in time. Store the id of processed updates and skip the ones you have already seen.

The delivery order is not guaranteed: take the match time from played_at.

Response​

  • A delivery succeeds if you answer with any 2xx code, for example 200 OK.
  • You have 10 seconds to answer. Answer right away and do heavy work after the response.
  • Any other code, a timeout or a connection error is a failed delivery.

Retries​

After a failed delivery we retry the same update with a growing pause: after 1, 2, 4, 8, 16 and 32 minutes, then every hour. An update that could not be delivered within 72 hours of its first failure is no longer sent.

While your address does not accept updates, we send at most one request a minute: the oldest waiting update. The rest wait and go out as soon as the address answers again.

  • 10 failed deliveries in a row: we email you (about a new outage, at most once a day). When deliveries work again after such a series, the waiting updates go out at once, without pauses, and if we emailed you about the outage, you get an email that deliveries are restored.
  • 72 hours without a single successful delivery: the webhook is disabled, and we email you about it.

Enabling the webhook again​

Open "Webhook settings", check the address and save: the webhook is enabled and the waiting updates go out. If some updates could not be delivered within 72 hours and you need them, write to hello@bemvp.net. Your players' matches are always available through the API: GET /v1/players/{steam_id}/games.

During a suspension​

If deliveries are suspended (no BeMVP link or not enough money), webhooks are not sent and the games pile up. After the fix everything collected goes out in order. Details: Suspension.