{
  "openapi": "3.0.1",
  "info": {
    "title": "Notifications API",
    "description": "Notification hub service",
    "version": "v1.0.0"
  },
  "servers": [
    {
      "url": "https://notifications.api.test.snokam.no"
    }
  ],
  "paths": {
    "/v1.0/protected/health/{provider}": {
      "get": {
        "tags": [
          "Health"
        ],
        "summary": "Checks an integration's connectivity",
        "operationId": "NotificationsIntegrationHealth",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Health result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/integrationHealthResult"
                }
              }
            }
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.0/protected/newsletter/trigger": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Trigger newsletter summarizer",
        "description": "Manually runs the weekly knowledge-summarizer cron (iterates active newsletterSeries, posts Olaf's summary to the configured Slack channel per series, and emails subscribers for series with sendEmails=true).",
        "operationId": "TriggerKnowledgeSummarizer",
        "responses": {
          "200": {
            "description": "Summarizer run completed",
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.0/protected/newsletter/debug": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Preview newsletters by email",
        "description": "Generates Olaf's summary for each active newsletterSeries and emails the rendered body (same composition the real cron uses) to the caller-supplied address. Skips Sanity persistence, Slack posts, and the 7-day dedup check — subscribers are never touched. Defaults to utvikling@snokam.no.",
        "operationId": "DebugNewsletterEmail",
        "parameters": [
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-ms-summary": "Recipient email (defaults to utvikling@snokam.no)"
          }
        ],
        "responses": {
          "200": {
            "description": "Payload of Object",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "x-ms-summary": "Preview sent"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.0/protected/alerts/azure": {
      "post": {
        "tags": [
          "Alerts"
        ],
        "summary": "Receive Azure Monitor alert",
        "description": "Action Group webhook receiver for the Azure Monitor common alert schema. Posts a formatted summary to the channel given by ?channel= (defaults to #feed-errors).",
        "operationId": "ReceiveAzureAlert",
        "parameters": [
          {
            "name": "channel",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-ms-summary": "Slack channel including the leading # (defaults to #feed-errors)"
          }
        ],
        "responses": {
          "200": {
            "description": "Alert relayed",
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.0/protected/routing": {
      "get": {
        "tags": [
          "Notifications"
        ],
        "summary": "Get notification routing",
        "description": "Returns the tenant's notification routing plus the known keys and active chat provider.",
        "operationId": "GetNotificationRouting",
        "responses": {
          "200": {
            "description": "Payload of NotificationRoutingResponse",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/notificationRoutingResponse"
                }
              }
            },
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      },
      "put": {
        "tags": [
          "Notifications"
        ],
        "summary": "Update notification routing",
        "description": "Upserts the tenant's notification routing (routes + default destination).",
        "operationId": "UpdateNotificationRouting",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/updateNotificationRoutingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No description",
            "x-ms-summary": "Saved"
          },
          "400": {
            "description": "No description",
            "x-ms-summary": "Invalid body"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.0/protected/push/register": {
      "post": {
        "tags": [
          "Push"
        ],
        "summary": "Register device for push notifications",
        "description": "Creates or updates a device installation in Azure Notification Hub",
        "operationId": "RegisterDevice",
        "requestBody": {
          "description": "Device registration data",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/deviceInstallation"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Device registered successfully",
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.0/protected/push/register/{installationId}": {
      "delete": {
        "tags": [
          "Push"
        ],
        "summary": "Unregister device from push notifications",
        "description": "Removes a device installation from Azure Notification Hub",
        "operationId": "UnregisterDevice",
        "responses": {
          "200": {
            "description": "Device unregistered successfully",
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.0/protected/slack": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Send Slack notification",
        "description": "Queues a Slack message for delivery",
        "operationId": "SendSlackNotification",
        "requestBody": {
          "description": "Slack notification to send",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/sendSlackRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Notification queued successfully",
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.0/protected/sms": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Send SMS notification",
        "description": "Queues an SMS message for delivery",
        "operationId": "SendSmsNotification",
        "requestBody": {
          "description": "SMS notification to send",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/sendSmsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Notification queued successfully",
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.0/protected/email": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Send email notification",
        "description": "Queues an email for delivery",
        "operationId": "SendEmailNotification",
        "requestBody": {
          "description": "Email notification to send",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/sendEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Notification queued successfully",
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.0/protected/push": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Send push notification",
        "description": "Queues a push notification for delivery",
        "operationId": "SendPushNotification",
        "requestBody": {
          "description": "Push notification to send",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/sendPushRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Notification queued successfully",
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.0/protected/notify": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Send notification",
        "description": "Queues a notification for delivery to one or more channels (Slack, SMS, email)",
        "operationId": "SendNotification",
        "requestBody": {
          "description": "Notification with one or more channels",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/sendNotificationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Notification queued successfully",
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.0/protected/sprint-notification/trigger": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Trigger weekly sprint summary",
        "description": "Manually triggers the weekly sprint summary notification to Slack #general",
        "operationId": "TriggerSprintNotification",
        "responses": {
          "200": {
            "description": "Summary sent successfully",
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.0/protected/sprint-notification/debug": {
      "get": {
        "tags": [
          "Notifications"
        ],
        "summary": "Debug friday summary",
        "description": "Returns the full friday summary including the AI output for debugging",
        "operationId": "DebugSprintSummary",
        "responses": {
          "200": {
            "description": "Payload of Object",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "x-ms-summary": "Debug data"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          }
        ]
      }
    },
    "/v1.0/protected/time-logging/reminder/trigger": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Trigger the time-logging SMS reminder",
        "description": "Manually runs the personal time-logging SMS reminder for the calling tenant: texts active employees who have not yet locked their hours for the current month. Ignores the last-day-of-month gate.",
        "operationId": "TriggerTimeLoggingReminder",
        "responses": {
          "200": {
            "description": "Reminder run completed",
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.0/protected/time-logging/shame/trigger": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Trigger the monthly time-logging shame",
        "description": "Manually runs the monthly time-logging shame for the calling tenant: reads employees without all hours approved for last month from accounting/PowerOffice and posts the public reminder to #general.",
        "operationId": "TriggerTimeLoggingShame",
        "responses": {
          "200": {
            "description": "Shame run completed",
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "deviceInstallation": {
        "type": "object",
        "properties": {
          "installationId": {
            "type": "string"
          },
          "platform": {
            "type": "string"
          },
          "pushChannel": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "integrationHealthResult": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "notificationKnownKeyDto": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "group": {
            "type": "string"
          }
        }
      },
      "notificationRouteDto": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "destination": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          }
        }
      },
      "notificationRoutingResponse": {
        "type": "object",
        "properties": {
          "routes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/notificationRouteDto"
            }
          },
          "defaultDestination": {
            "type": "string"
          },
          "knownKeys": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/notificationKnownKeyDto"
            }
          },
          "activeChatProvider": {
            "type": "string"
          }
        }
      },
      "sendEmailAttachmentRequest": {
        "type": "object",
        "properties": {
          "content": {
            "type": "string"
          },
          "filename": {
            "type": "string"
          },
          "contentType": {
            "type": "string"
          }
        }
      },
      "sendEmailRequest": {
        "type": "object",
        "properties": {
          "receiver": {
            "type": "string"
          },
          "receivers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "title": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "htmlBody": {
            "type": "string"
          },
          "sender": {
            "type": "string"
          },
          "senderName": {
            "type": "string"
          },
          "replyTo": {
            "type": "string"
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/sendEmailAttachmentRequest"
            }
          }
        }
      },
      "sendNotificationRequest": {
        "type": "object",
        "properties": {
          "slack": {
            "$ref": "#/components/schemas/sendSlackRequest"
          },
          "sms": {
            "$ref": "#/components/schemas/sendSmsRequest"
          },
          "email": {
            "$ref": "#/components/schemas/sendEmailRequest"
          },
          "push": {
            "$ref": "#/components/schemas/sendPushRequest"
          }
        }
      },
      "sendPushRequest": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "data": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "sendSlackRequest": {
        "type": "object",
        "properties": {
          "channelId": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "blocksJson": {
            "type": "string"
          },
          "attachmentsJson": {
            "type": "string"
          },
          "iconEmoji": {
            "type": "string"
          },
          "username": {
            "type": "string"
          }
        }
      },
      "sendSmsRequest": {
        "type": "object",
        "properties": {
          "phoneNumber": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "updateNotificationRoutingRequest": {
        "type": "object",
        "properties": {
          "routes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/notificationRouteDto"
            }
          },
          "defaultDestination": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "Implicit": {
        "type": "oauth2",
        "flows": {
          "implicit": {
            "authorizationUrl": "https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize",
            "tokenUrl": "https://login.microsoftonline.com/organizations/oauth2/v2.0/token",
            "refreshUrl": "https://login.microsoftonline.com/organizations/oauth2/v2.0/token",
            "scopes": {
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default": "Default function scope"
            }
          }
        }
      },
      "ApiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  }
}