Injury alert notifications

Push an alert to users the moment an injury report changes. Fantasy users, especially DFS, will pay for this — minutes matter.

What you'll build

A webhook receiver that takes injury updates from sportapi and fans out push notifications to users who have the affected player on their roster.

Create a webhook subscription

curl https://api.sportapi.io/v1/webhooks \
  -X POST \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "url": "https://yourapp.com/webhooks/injuries",
    "events": ["news.injuries"],
    "filter": { "league": "nba" }
  }'

Verify the signature

Skipping this is a security hole. See webhook signature verification for the full pattern.

Send push notifications

// app/api/webhooks/injuries/route.ts
export async function POST(req: Request) {
  const body = await req.text();
  verifySignature(req.headers, body, process.env.WEBHOOK_SECRET);

  const event = JSON.parse(body);
  const { players, designation } = event.data;

  // Look up which users have these players on their roster
  const userIds = await db.findUsersOwningPlayers(players);

  // Fan out via your push provider (Expo, FCM, OneSignal, …)
  await sendPush(userIds, {
    title: `Injury update: ${event.data.headline}`,
    body: `Status: ${designation}`,
  });

  return new Response(null, { status: 200 });
}