Server-SideREST APIEndpoints

Webhook Events

Send retention and custom events via the webhook endpoint

The Webhook endpoint is the primary event ingestion API. Use it to send retention events and custom events such as purchases, ads, or any custom action.

Endpoint

POST /webhook

Request Body

Required Fields

Prop

Type

Example: Retention Event

curl -X POST https://analytics.geeklab.app/webhook \
  -H "Content-Type: application/json" \
  -H "geeklab-api-key: your_api_key" \
  -d '{
    "type": "retention",
    "created_at": "2024-10-10 10:15:00",
    "creativeToken": "abc123def456",
    "device_name": "MacBook Pro",
    "device_model": "MacBookPro18,3",
    "os_system": "macOS 14.5",
    "utc_offset": "-07:00",
    "retention_day": "0",
    "payload": {
      "session_id": "session_001"
    }
  }'

Example: Purchase Event

curl -X POST https://analytics.geeklab.app/webhook \
  -H "Content-Type: application/json" \
  -H "geeklab-api-key: your_api_key" \
  -d '{
    "type": "custom.purchase",
    "created_at": "2024-10-10 10:25:00",
    "creativeToken": "abc123def456",
    "device_name": "MacBook Pro",
    "device_model": "MacBookPro18,3",
    "os_system": "macOS 14.5",
    "utc_offset": "-07:00",
    "retention_day": "0",
    "payload": {
      "item_id": "premium_monthly",
      "item_name": "Premium Monthly Subscription",
      "value": 9.99,
      "currency": "usd",
      "status": "completed",
      "total_purchase_value": 19.98,
      "tr_id": "txn_123456"
    }
  }'

Example: Ad Event

curl -X POST https://analytics.geeklab.app/webhook \
  -H "Content-Type: application/json" \
  -H "geeklab-api-key: your_api_key" \
  -d '{
    "type": "custom.ad",
    "created_at": "2024-10-10 10:35:00",
    "creativeToken": "abc123def456",
    "device_name": "MacBook Pro",
    "device_model": "MacBookPro18,3",
    "os_system": "macOS 14.5",
    "utc_offset": "-07:00",
    "retention_day": "0",
    "payload": {
      "ad_id": "rewarded_level_complete",
      "name": "Level Complete Reward",
      "source": "rewarded_video",
      "watch_time": 30,
      "reward": true,
      "media_source": "admob",
      "channel": "paid",
      "value": 0.015,
      "currency": "usd",
      "total_ad_value": 0.045
    }
  }'

Example: Custom Event

curl -X POST https://analytics.geeklab.app/webhook \
  -H "Content-Type: application/json" \
  -H "geeklab-api-key: your_api_key" \
  -d '{
    "type": "custom",
    "created_at": "2024-10-10 10:40:00",
    "creativeToken": "abc123def456",
    "device_name": "MacBook Pro",
    "device_model": "MacBookPro18,3",
    "os_system": "macOS 14.5",
    "utc_offset": "-07:00",
    "retention_day": "0",
    "payload": {
      "event_name": "level_complete",
      "params": {
        "value": "7",
        "id": "level_7",
        "key": "difficulty:hard"
      }
    }
  }'

Response

Webhook responses vary by event type, but a successful request returns 200 OK.

Error Responses

  • 400 Bad Request: Payload is invalid
  • 401 Unauthorized: API key is missing or invalid
  • 500 Server Error: Unexpected error