Configure Content Ingestion Webhook

User Intent

"How do I get notified when content is ingested? Show me webhook configuration."

Operation

SDK Method: Configure webhook in Developer Portal Use Case: Real-time content ingestion notifications


Configuration

  1. Developer Portal → Webhooks → Create Webhook

  2. URL: Your webhook endpoint

  3. Events: Select content.ingested, content.updated

  4. Secret: Webhook signing secret


Webhook Payload

{
  "event": "content.ingested",
  "contentId": "content-123",
  "name": "document.pdf",
  "type": "FILE",
  "status": "COMPLETED",
  "timestamp": "2024-01-15T10:30:00Z"
}

Handling Webhooks (TypeScript)

import express from 'express';
import crypto from 'crypto';

const app = express();
app.use(express.json());

app.post('/graphlit-webhook', (req, res) => {
  // Verify signature
  const signature = req.headers['x-graphlit-signature'];
  const payload = JSON.stringify(req.body);
  const secret = process.env.WEBHOOK_SECRET!;
  
  const expectedSig = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');
  
  if (signature !== expectedSig) {
    return res.status(401).send('Invalid signature');
  }
  
  // Process event
  const { event, contentId } = req.body;
  console.log(`Received ${event} for ${contentId}`);
  
  // Your logic here
  
  res.status(200).send('OK');
});

app.listen(3000);

Last updated

Was this helpful?