Magneteco
API Reference

Webhooks

Receive webhooks from external services and send webhooks from Magneteco

Receive Webhooks

Receive webhooks from external services.

POST /webhooks/:source

Supported Sources

SourceDescription
stripeStripe payment events
githubGitHub repository events
netsuiteNetSuite record events
salesforceSalesforce CRM events
slackSlack messaging events
customGeneric webhook handler

Example: Stripe Webhook

curl -X POST https://api.magneteco.io/v1/webhooks/stripe \
  -H "Content-Type: application/json" \
  -H "Stripe-Signature: $STRIPE_SIGNATURE" \
  -d '{
    "type": "invoice.paid",
    "data": {
      "object": {
        "customer": "cus_123",
        "amount_paid": 9900,
        "currency": "usd"
      }
    }
  }'

Response

{
  "status": "processed" | "ignored",
  "eventId"?: "evt-456"  // Only if processed
}

Custom Webhook Handler

For sources not natively supported:

curl -X POST https://api.magneteco.io/v1/webhooks/custom \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "appId": "my-app",
    "userId": "user-123",
    "eventType": "custom_event",
    "data": {
      "key": "value"
    }
  }'

Send Webhooks from Magneteco

Magneteco can send webhooks to your app for certain events.

Configuring Outbound Webhooks

curl -X POST https://api.magneteco.io/v1/config/webhooks \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "appId": "tanda",
    "url": "https://your-app.com/magneteco-webhook",
    "events": ["memory.processed", "entity.created", "conflict.detected"],
    "secret": "your-webhook-secret"
  }'

Webhook Events

EventDescription
memory.processedContent has been processed and memorized
entity.createdNew entity discovered
entity.updatedEntity properties updated
relationship.createdNew relationship discovered
conflict.detectedConflicting information detected
maintenance.completedMaintenance job completed

Webhook Payload

{
  "event": "memory.processed",
  "timestamp": "2024-01-15T14:30:00Z",
  "appId": "tanda",
  "userId": "user-123",
  "data": {
    "resourceId": "res-789",
    "itemsCreated": 3,
    "entitiesCreated": 2,
    "categoriesUpdated": ["client_preferences"]
  }
}

Verify Webhook Signature

const crypto = require('crypto');

function verifyWebhook(
  payload: string,
  signature: string,
  secret: string
): boolean {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(`sha256=${expected}`)
  );
}

Webhook Retry Policy

Failed webhooks are retried with exponential backoff:

AttemptDelay
1Immediate
21 minute
35 minutes
430 minutes
52 hours

After 5 failed attempts, the webhook is marked as failed and requires manual intervention.

On this page