AVENA/Webhooks

Avena Webhooks

Real-time Event Delivery. Subscribe to property market events and receive instant HTTP callbacks when prices drop, new listings appear, or market conditions shift.

Available Events

property.price_drop

Fired when a tracked property drops in price

{ "ref": "ALI-001", "old_price": 250000, "new_price": 225000, "change_pct": -10.0 }
property.new_listing

Fired when a new property is added to the dataset

{ "ref": "ALI-042", "project": "Mar Azul III", "developer": "TM", "price": 189000 }
signal.new

Fired when a new investment signal is generated

{ "signal": "BUY", "confidence": 87, "ref": "ALI-015", "reason": "Price below zone avg" }
regime.change

Market regime has changed

{ "from": "BULL", "to": "CAUTION", "score": 2, "confidence": 66 }
developer.stress_alert

Developer shows financial stress indicators

{ "developer": "Acme Homes", "stress_score": 78, "indicators": ["price_cuts", "slow_sales"] }
anomaly.detected

Statistical anomaly detected in the market

{ "type": "EXTREME_VALUE", "ref": "ALI-099", "z_score": 3.2, "reason": "Price 3.2 SD below mean" }
market.weekly_summary

Weekly digest of market activity

{ "week": "2025-W20", "new_listings": 47, "price_drops": 12, "avg_score": 58.3 }

Subscribe

Send a POST request to create a webhook subscription. You will receive a secret for signature verification.

curl -X POST https://avena.sh/api/webhooks/subscribe \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-server.com/webhook",
    "events": ["property.price_drop", "property.new_listing"],
    "description": "My price alert webhook"
  }'

Response:

{
  "id": "sub_abc123",
  "secret": "whsec_...",
  "events": ["property.price_drop", "property.new_listing"],
  "status": "active"
}

Signature Verification

Every webhook delivery includes an X-Avena-Signature header. Verify it using HMAC-SHA256 with your webhook secret to ensure the payload is authentic.

Headers sent with each delivery:

X-Avena-Event: property.price_drop
X-Avena-Delivery: del_xyz789
X-Avena-Signature: hmac-sha256=...

Code Examples

Node.jsExpress
const crypto = require('crypto');
const express = require('express');
const app = express();

app.use(express.json());

app.post('/webhook', (req, res) => {
  const event = req.headers['x-avena-event'];
  const signature = req.headers['x-avena-signature'];

  // Verify signature
  const expected = crypto
    .createHmac('sha256', process.env.WEBHOOK_SECRET)
    .update(JSON.stringify(req.body))
    .digest('hex');

  if (signature !== expected) {
    return res.status(401).json({ error: 'Invalid signature' });
  }

  console.log(`Received: ${event}`, req.body.payload);
  res.json({ received: true });
});

app.listen(3000);
PythonFlask
import hmac, hashlib, json
from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/webhook', methods=['POST'])
def webhook():
    event = request.headers.get('X-Avena-Event')
    signature = request.headers.get('X-Avena-Signature')

    # Verify signature
    expected = hmac.new(
        WEBHOOK_SECRET.encode(),
        json.dumps(request.json).encode(),
        hashlib.sha256
    ).hexdigest()

    if signature != expected:
        return jsonify(error='Invalid signature'), 401

    print(f'Received: {event}', request.json['payload'])
    return jsonify(received=True)

app.run(port=3000)