API Examples

Code examples for common API operations in different programming languages.

Customer Management

Create a Customer

curl -X POST https://api.churnshield.ai/api/customers \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "customer_id": "cust_123",
    "name": "Acme Inc",
    "email": "contact@acme.com"
  }'

Health Score Updates

Update Health Score

curl -X POST https://api.churnshield.ai/api/customers/cust_123/health-score \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "factors": {
      "usage": 0.8,
      "support": 0.9,
      "billing": 1.0
    }
  }'

Webhook Configuration

Create Webhook

curl -X POST https://api.churnshield.ai/api/webhooks \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-domain.com/webhook",
    "events": ["customer.health_score.updated"],
    "description": "Monitor health score changes"
  }'