{"openapi":"3.1.0","info":{"title":"Alerting Microservice API","summary":"Config-driven alert dispatch service","description":"Receives internal alert events, applies threshold/cooldown controls, resolves recipients, and sends notifications asynchronously.","version":"1.0.0"},"paths":{"/alerts/trigger":{"post":{"tags":["alerts"],"summary":"Trigger alert","description":"Accepts an alert event and runs threshold + cooldown + recipient + email dispatch workflow.","operationId":"trigger_alert_alerts_trigger_post","parameters":[{"name":"x-api-key","in":"header","required":true,"schema":{"type":"string","title":"X-Api-Key"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertRequest"}}}},"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/webhooks/alertmanager":{"post":{"tags":["webhooks"],"summary":"Prometheus Alertmanager webhook","description":"Receives alerts from Prometheus Alertmanager (firing and resolved). Validates X-API-Key header (or query param) and dispatches alerts.\n\n**Authentication:**\n- Header: `X-API-Key: your-api-key`\n- Query Param: `?X-API-Key=your-api-key`\n\n**Status Handling:**\n- `firing` → Sends outage alert\n- `resolved` → Sends recovery notification","operationId":"alertmanager_webhook_webhooks_alertmanager_post","parameters":[{"name":"x-api-key","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"API key for authentication (e.g., 'your-api-key')","title":"X-Api-Key"},"description":"API key for authentication (e.g., 'your-api-key')"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertmanagerWebhookPayload"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"ApiKeyAuth":[]}]}},"/health":{"get":{"tags":["health"],"summary":"Health check","operationId":"health_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":{"type":"string"},"type":"object","title":"Response Health Health Get"}}}}}}}},"components":{"schemas":{"AlertRequest":{"properties":{"org_id":{"type":"string","title":"Org Id","description":"Organization identifier"},"alert_type":{"$ref":"#/components/schemas/AlertType","description":"Configured alert type"},"context":{"additionalProperties":true,"type":"object","title":"Context","description":"Optional diagnostic metadata"}},"type":"object","required":["org_id","alert_type"],"title":"AlertRequest","example":{"alert_type":"LLM_PROVIDER_FAILURE","context":{"error_code":"500","provider":"openai","trace_id":"abc-123"},"org_id":"org_123"}},"AlertResponse":{"properties":{"status":{"type":"string","title":"Status"},"reason":{"type":"string","title":"Reason"}},"type":"object","required":["status","reason"],"title":"AlertResponse"},"AlertType":{"type":"string","enum":["BILLING_LIMIT","LLM_PROVIDER_FAILURE","BRAINSTORMER_CORE_ERROR","MAINTENANCE","SERVER_OUTAGE","THIRD_PARTY_FAILURE","MESSAGE_UNDELIVERED","SERVICE_RECOVERED"],"title":"AlertType"},"AlertmanagerAlert":{"properties":{"status":{"type":"string","title":"Status"},"labels":{"additionalProperties":true,"type":"object","title":"Labels"},"annotations":{"additionalProperties":true,"type":"object","title":"Annotations"},"startsAt":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Startsat"},"endsAt":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Endsat"},"generatorURL":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Generatorurl"},"fingerprint":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Fingerprint"}},"type":"object","required":["status"],"title":"AlertmanagerAlert"},"AlertmanagerWebhookPayload":{"properties":{"receiver":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Receiver"},"status":{"type":"string","title":"Status"},"alerts":{"items":{"$ref":"#/components/schemas/AlertmanagerAlert"},"type":"array","title":"Alerts"},"groupLabels":{"additionalProperties":true,"type":"object","title":"Grouplabels"},"commonLabels":{"additionalProperties":true,"type":"object","title":"Commonlabels"},"commonAnnotations":{"additionalProperties":true,"type":"object","title":"Commonannotations"},"externalURL":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Externalurl"},"version":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Version"},"gKey":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Gkey"},"truncatedAlerts":{"type":"integer","title":"Truncatedalerts","default":0}},"type":"object","required":["status","alerts"],"title":"AlertmanagerWebhookPayload","description":"Prometheus Alertmanager webhook payload structure.","example":{"alerts":[{"annotations":{"description":"https://example.com is DOWN","summary":"🚨 Website Down"},"endsAt":"0001-01-01T00:00:00Z","fingerprint":"abc123","generatorURL":"http://prometheus:9090/graph","labels":{"alertname":"WebsiteDown","instance":"https://example.com","job":"blackbox_http","severity":"critical"},"startsAt":"2026-04-07T12:48:21.878Z","status":"firing"}],"commonAnnotations":{"description":"https://example.com is DOWN","summary":"🚨 Website Down"},"commonLabels":{"alertname":"WebsiteDown","instance":"https://example.com","severity":"critical"},"externalURL":"http://alertmanager:9093","groupLabels":{},"receiver":"combined-alerts","status":"firing","version":"4"}},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"WebhookResponse":{"properties":{"ok":{"type":"boolean","title":"Ok"},"status":{"type":"string","title":"Status"},"reason":{"type":"string","title":"Reason"}},"type":"object","required":["ok","status","reason"],"title":"WebhookResponse"}}},"tags":[{"name":"alerts","description":"Internal alert ingestion endpoints"},{"name":"webhooks","description":"External webhook ingestion endpoints"},{"name":"health","description":"Service health endpoints"}]}