Integrations - Usage Examples
Last Updated: 2026-02-27
Authentication
All Integrations endpoints (except the Sanity webhook receiver) require a Bearer token.
# Step 1: Obtain token
curl -s -X POST https://api.djanity.com/auth/login/ \
-H "Content-Type: application/json" \
-d '{"username": "[email protected]", "password": "..."}'
# Returns: {"access": "<jwt>", "refresh": "<jwt>"}
# Step 2: All subsequent requests use:
# -H "Authorization: Bearer <token>"
Webhook Processing
Test webhook endpoint accessibility
curl -s https://api.djanity.com/integrations/sanity-webhook/
Response:
{
"status": "ok",
"message": "Sanity webhook endpoint is accessible",
"endpoint": "/integrations/sanity-webhook/",
"methods": ["GET", "POST"]
}
Receive a Sanity CMS webhook
The webhook endpoint uses HMAC-SHA256 signature verification rather than Bearer auth. Sanity sends these automatically — this shows the expected request shape.
curl -s -X POST https://api.djanity.com/integrations/sanity-webhook/ \
-H "Content-Type: application/json" \
-H "Sanity-Dataset: production" \
-H "Sanity-Webhook-Signature: t=1709030400000,v1=<hmac_signature>" \
-d '{
"_type": "product",
"_id": "prod-classic-tee-001",
"_rev": "abc123xyz",
"title": "Classic Tee",
"slug": {"current": "classic-tee"}
}'
Response (202 Accepted — webhook queued):
{
"status": "accepted",
"message": "Webhook received and queued for buffered processing",
"task_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"webhook_signature": "5f4dcc3b5aa765d61d8327deb882cf99",
"document_type": "product",
"sanity_id": "prod-classic-tee-001",
"processing_path": "redis_buffered"
}
Manual Sync (Django → Sanity)
Trigger a manual sync for a specific document
curl -s -X POST https://api.djanity.com/integrations/manual-sync/ \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"sanity_id": "prod-classic-tee-001",
"document_type": "product"
}'
Response (200 OK):
{
"success": true,
"sanity_id": "prod-classic-tee-001",
"document_type": "product",
"model_type": "products.Product",
"instance_id": "550e8400-e29b-41d4-a716-446655440000",
"message": "Django data successfully pushed to Sanity",
"django_updated_at": "2026-02-27T10:00:00Z"
}
Analytics Sync Monitoring
Check overall sync health
curl -s https://api.djanity.com/integrations/analytics/sync-health/ \
-H "Authorization: Bearer <token>"
Response:
{
"status": "healthy",
"last_sync": "2026-02-27T09:58:12Z",
"pending_events": 2,
"error_rate": 0.01
}
Check sync throughput over the last 24 hours
curl -s "https://api.djanity.com/integrations/analytics/sync-throughput/?hours=24" \
-H "Authorization: Bearer <token>"
Response:
{
"granularity": "hour",
"data": [
{
"hour": "2026-02-27T08:00:00+00:00",
"inbound_count": 42,
"outbound_count": 15,
"failed_count": 0,
"total": 57
}
]
}
Check webhook pipeline status
curl -s https://api.djanity.com/integrations/analytics/webhook-pipeline/ \
-H "Authorization: Bearer <token>"
Response:
{
"total_received_24h": 156,
"by_status": {
"completed": 150,
"failed": 4,
"processing": 2
},
"by_document_type": [
{"document_type": "product", "count": 80},
{"document_type": "salesTransaction", "count": 45}
],
"avg_processing_ms": 230
}
Check per-model revision health
curl -s https://api.djanity.com/integrations/analytics/revision-health/ \
-H "Authorization: Bearer <token>"