Webhooks

Register one URL in your panel and we call it when data you contracted changes. The notice carries no data: when it arrives, call the API.

Setting it up

  • In your panel, on the key page: the URL, the events, then Save. The signing secret (whsec_…) is shown only once.
  • The URL must be https, on port 443 or 8443, with a public host name or address.
  • Send test delivers a webhook.test notice, so you can check your endpoint.

Events

EventWhenPlan
market.world.updatedThe market of a world in your plan changed; one per world.market
coins.updatedCoin resellers or P2P offers changed.Any plan
npc_profit.updatedNPC Profit changed.npc-profit
webhook.testYou pressed Send test in your panel.Always

You choose the events; only those of the modules in force are delivered.

The request

POST /tgm HTTP/1.1
Host: hooks.example.com
Content-Type: application/json
User-Agent: TGM-Webhooks/1
X-TGM-Signature: t=1763380800,v1=<64 hex>

{"id":"3f0c2d9e-8a51-4c47-9b3e-1f2a6d7c8e90","type":"market.world.updated","created_at":"2026-11-17T12:00:00.000Z","data":{"world":"Antica","data_version":"efd2cda81ebbb612","etag":"\"efd2cda81ebbb612\""}}
  • id is unique per notice and stays the same on retries: use it to ignore repeats.
  • data says what changed: world (when there is one), data_version and the new etag. Fetch the data from the API as usual; it costs units as usual.
  • Requests come from our delivery service with User-Agent: TGM-Webhooks/1. There is no fixed list of addresses: trust the signature, never the IP.

Checking the signature

Every request carries X-TGM-Signature: t=<unix>,v1=<hex>. v1 is the HMAC-SHA256, in hex, of "<t>.<body>" with your secret as the key.

  • Use the body exactly as received, before parsing the JSON.
  • Compare in constant time.
  • Reject a notice whose t is more than 5 minutes away from your clock.
  • Each attempt is signed again, with a new t.
webhook-verify.sh
#!/usr/bin/env bash
# Checks one Tibia Global Market webhook notice (needs openssl).
#   TGM_WEBHOOK_SECRET=whsec_... bash webhook-verify.sh "<X-TGM-Signature>" < body.json
# The body must be the raw bytes you received, before any JSON parsing.
set -euo pipefail

header="${1:-}"
if [ -z "${TGM_WEBHOOK_SECRET:-}" ] || [ -z "$header" ]; then
  echo "Set TGM_WEBHOOK_SECRET and pass the X-TGM-Signature header as the first argument." >&2
  exit 2
fi

t=""
sigs=()
IFS=',' read -ra parts <<< "$header"
for p in "${parts[@]}"; do
  p="${p// /}"
  case "$p" in
    t=*) t="${p#t=}" ;;
    v1=*) sigs+=("${p#v1=}") ;;
  esac
done
if ! [[ "$t" =~ ^[0-9]+$ ]] || [ "${#sigs[@]}" -eq 0 ]; then
  echo "rejected: malformed signature header" >&2
  exit 1
fi

# HMAC-SHA256 over "<t>.<raw body>", straight from stdin (no trailing newline added).
expected=$( { printf '%s.' "$t"; cat; } | openssl dgst -sha256 -hmac "$TGM_WEBHOOK_SECRET" | awk '{print $NF}')

# Constant-time comparison: compare HMACs of both values under a random key.
nonce=$(openssl rand -hex 16)
mac() { printf '%s' "$1" | openssl dgst -sha256 -hmac "$nonce" | awk '{print $NF}'; }
want=$(mac "$expected")
match=0
for s in "${sigs[@]}"; do
  if [ "$(mac "$s")" = "$want" ]; then match=1; fi
done
if [ "$match" -ne 1 ]; then
  echo "rejected: bad signature" >&2
  exit 1
fi

now=$(date +%s)
age=$(( now > t ? now - t : t - now ))
if [ "$age" -gt $(( 5 * 60 )) ]; then
  echo "rejected: timestamp too old" >&2
  exit 1
fi
echo "ok"

The scripts read the secret from TGM_WEBHOOK_SECRET, the header as the first argument and the body from standard input, and print ok or the reason.

Answering

Answer 2xx within 10 seconds and do the work after. Redirects (3xx) are not followed and count as a failure.

Retries

Any other answer, or none in 10 seconds, is a failure. We retry the same notice after 1 min, 5 min, 30 min, 2 h and 6 h, then give up on it.

After 20 failures in a row the webhook is turned off and your panel shows why. Save it again to turn it back on.

Limits

LimitValue
URLs per account1
market.world.updated per world1 every 5 minutes
Notices per day2,000
Tests per day (webhook.test)5

Your panel lists the last 20 deliveries with their status.