Webhooks Integration

Set up webhooks to receive real-time notifications for price changes.

6 min read Last updated: 2025-06-13

What are Webhooks?

Webhooks allow MetalAPI to send real-time notifications to your server when metal prices change.

Setting Up Webhooks

1. Go to Dashboard > Webhooks
2. Add your webhook URL
3. Select events to subscribe to
4. Configure filters (optional)
5. Save and test

Webhook Payload

Example webhook payload for price change:
{
  "event": "price.changed",
  "timestamp": 1749752411,
  "data": {
    "symbol": "XAU",
    "old_price": 1850.50,
    "new_price": 1856.90,
    "change_percent": 0.35
  }
}

Verifying Webhooks

Verify webhook signatures for security:
$signature = $_SERVER['HTTP_X_METALAPI_SIGNATURE'];
$payload = file_get_contents('php://input');
$expected = hash_hmac('sha256', $payload, $webhook_secret);

if (hash_equals($expected, $signature)) {
    // Webhook is valid
}

Ready for the next step?

Continue learning with our next guide:

Next: Error Handling