# Generic Alert Ingestion API

Trigger and update incidents programmatically from scripts, CI/CD pipelines, custom monitoring agents, or external webhook systems using a straightforward HTTP JSON POST request.

## Endpoint

```http
POST /api/v2/generic/incoming
```

## Request Headers

- `Content-Type: application/json`
- `Authorization: Bearer <INTEGRATION_KEY>` (or pass via `?token=<INTEGRATION_KEY>` query parameter)

## Request Body

| Field | Type | Required | Description |
|---|---|---|---|
| `summary` | String | **Yes** | Short headline describing the incident (max 500 chars). |
| `details` | String | No | Detailed context, stack trace, links, or logs (max 4,000 chars). |
| `dedup` | String | No | Deduplication string. Multiple alerts with the same `dedup` update the existing open alert rather than creating new pages. |

## Example Usage

### cURL

```bash
curl -X POST https://oncall.yourcompany.com/api/v2/generic/incoming \
  -H "Authorization: Bearer <INTEGRATION_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "summary": "Production Redis Out of Memory",
    "details": "Replica node memory saturation exceeded 95% on pod redis-0",
    "dedup": "redis-mem-prod"
  }'
```

### Python

```python
import requests

requests.post(
    "https://oncall.yourcompany.com/api/v2/generic/incoming",
    headers={"Authorization": "Bearer <INTEGRATION_KEY>"},
    json={
        "summary": "Payment Service API Elevated Error Rate (5xx)",
        "details": "HTTP 502 Bad Gateway rate exceeded 5% over 5m window",
        "dedup": "payments-5xx",
    },
)
```

## Response

- `200 OK`: Alert was successfully created or updated with existing dedup key.
- `401 Unauthorized`: Invalid or missing integration key token.
- `400 Bad Request`: Payload missing required `summary` field.
