# Notifications

## GET /notifications/v1/channels/emails

> List all email notification channels for an organisation

```json
{"openapi":"3.1.1","info":{"title":"MariaDB Cloud DBaaS API","version":"1.0"},"servers":[{"url":"https://api.skysql.com/"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"apiKey","name":"X-API-Key","in":"header"}},"schemas":{"dto.ChannelEmail":{"type":"object","properties":{"categories":{"type":"array","items":{"type":"string"}},"channel_name":{"type":"string"},"id":{"type":"string"},"org_id":{"type":"string"},"receivers":{"type":"array","items":{"$ref":"#/components/schemas/dto.EmailRecipients"}},"subscriber_id":{"type":"string"}}},"dto.EmailRecipients":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"}}},"errr.ErrorResponse":{"type":"object","properties":{"code":{"type":"integer"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/errr.ErrorDetails"}},"exception":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"path":{"type":"string"},"timestamp":{"type":"integer"},"trace_id":{"type":"string"}}},"errr.ErrorDetails":{"type":"object","properties":{"error":{"type":"string"},"location":{"type":"string"},"message":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"solution":{"type":"string"},"type":{"$ref":"#/components/schemas/errr.Type"}}},"errr.Type":{"type":"string","enum":["fatal","error","warning"]}}},"paths":{"/notifications/v1/channels/emails":{"get":{"consumes":["application/json"],"tags":["Notifications"],"summary":"List all email notification channels for an organisation","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/dto.ChannelEmail"}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errr.ErrorResponse"}}}}}}}}}
```

## POST /notifications/v1/channels/emails

> Create email notification channel for an organisation

```json
{"openapi":"3.1.1","info":{"title":"MariaDB Cloud DBaaS API","version":"1.0"},"servers":[{"url":"https://api.skysql.com/"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"apiKey","name":"X-API-Key","in":"header"}},"schemas":{"dto.ChannelEmail":{"type":"object","properties":{"categories":{"type":"array","items":{"type":"string"}},"channel_name":{"type":"string"},"id":{"type":"string"},"org_id":{"type":"string"},"receivers":{"type":"array","items":{"$ref":"#/components/schemas/dto.EmailRecipients"}},"subscriber_id":{"type":"string"}}},"dto.EmailRecipients":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"}}},"errr.ErrorResponse":{"type":"object","properties":{"code":{"type":"integer"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/errr.ErrorDetails"}},"exception":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"path":{"type":"string"},"timestamp":{"type":"integer"},"trace_id":{"type":"string"}}},"errr.ErrorDetails":{"type":"object","properties":{"error":{"type":"string"},"location":{"type":"string"},"message":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"solution":{"type":"string"},"type":{"$ref":"#/components/schemas/errr.Type"}}},"errr.Type":{"type":"string","enum":["fatal","error","warning"]},"dto.CreateChannelEmail":{"type":"object","properties":{"categories":{"type":"array","items":{"type":"string"}},"channel_name":{"type":"string"},"receivers":{"type":"array","items":{"$ref":"#/components/schemas/dto.EmailRecipients"}}}}}},"paths":{"/notifications/v1/channels/emails":{"post":{"tags":["Notifications"],"summary":"Create email notification channel for an organisation","responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/dto.ChannelEmail"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errr.ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/dto.CreateChannelEmail"}}},"description":"Request Body","required":true}}}}}
```

## GET /notifications/v1/channels/emails/{channel\_id}

> Get email notification channel

```json
{"openapi":"3.1.1","info":{"title":"MariaDB Cloud DBaaS API","version":"1.0"},"servers":[{"url":"https://api.skysql.com/"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"apiKey","name":"X-API-Key","in":"header"}},"schemas":{"dto.ChannelEmail":{"type":"object","properties":{"categories":{"type":"array","items":{"type":"string"}},"channel_name":{"type":"string"},"id":{"type":"string"},"org_id":{"type":"string"},"receivers":{"type":"array","items":{"$ref":"#/components/schemas/dto.EmailRecipients"}},"subscriber_id":{"type":"string"}}},"dto.EmailRecipients":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"}}},"errr.ErrorResponse":{"type":"object","properties":{"code":{"type":"integer"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/errr.ErrorDetails"}},"exception":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"path":{"type":"string"},"timestamp":{"type":"integer"},"trace_id":{"type":"string"}}},"errr.ErrorDetails":{"type":"object","properties":{"error":{"type":"string"},"location":{"type":"string"},"message":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"solution":{"type":"string"},"type":{"$ref":"#/components/schemas/errr.Type"}}},"errr.Type":{"type":"string","enum":["fatal","error","warning"]}}},"paths":{"/notifications/v1/channels/emails/{channel_id}":{"get":{"tags":["Notifications"],"summary":"Get email notification channel","parameters":[{"schema":{"type":"string"},"description":"channel id","name":"channel_id","in":"path","required":true}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/dto.ChannelEmail"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errr.ErrorResponse"}}}}}}}}}
```

## DELETE /notifications/v1/channels/emails/{channel\_id}

> Delete email notification channel

```json
{"openapi":"3.1.1","info":{"title":"MariaDB Cloud DBaaS API","version":"1.0"},"servers":[{"url":"https://api.skysql.com/"}],"paths":{"/notifications/v1/channels/emails/{channel_id}":{"delete":{"tags":["Notifications"],"summary":"Delete email notification channel","parameters":[{"schema":{"type":"string"},"description":"channel id","name":"channel_id","in":"path","required":true}],"responses":{"200":{"description":"OK"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errr.ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errr.ErrorResponse"}}}}}}}},"components":{"schemas":{"errr.ErrorResponse":{"type":"object","properties":{"code":{"type":"integer"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/errr.ErrorDetails"}},"exception":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"path":{"type":"string"},"timestamp":{"type":"integer"},"trace_id":{"type":"string"}}},"errr.ErrorDetails":{"type":"object","properties":{"error":{"type":"string"},"location":{"type":"string"},"message":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"solution":{"type":"string"},"type":{"$ref":"#/components/schemas/errr.Type"}}},"errr.Type":{"type":"string","enum":["fatal","error","warning"]}}}}
```

## PATCH /notifications/v1/channels/emails/{channel\_id}

> Update email notification channel

```json
{"openapi":"3.1.1","info":{"title":"MariaDB Cloud DBaaS API","version":"1.0"},"servers":[{"url":"https://api.skysql.com/"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"apiKey","name":"X-API-Key","in":"header"}},"schemas":{"errr.ErrorResponse":{"type":"object","properties":{"code":{"type":"integer"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/errr.ErrorDetails"}},"exception":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"path":{"type":"string"},"timestamp":{"type":"integer"},"trace_id":{"type":"string"}}},"errr.ErrorDetails":{"type":"object","properties":{"error":{"type":"string"},"location":{"type":"string"},"message":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"solution":{"type":"string"},"type":{"$ref":"#/components/schemas/errr.Type"}}},"errr.Type":{"type":"string","enum":["fatal","error","warning"]},"dto.UpdateChannelEmail":{"type":"object","properties":{"categories":{"type":"array","items":{"type":"string"}},"channel_name":{"type":"string"},"receivers":{"type":"array","items":{"$ref":"#/components/schemas/dto.EmailRecipients"}}}},"dto.EmailRecipients":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"}}}}},"paths":{"/notifications/v1/channels/emails/{channel_id}":{"patch":{"tags":["Notifications"],"summary":"Update email notification channel","parameters":[{"schema":{"type":"string"},"description":"channel id","name":"channel_id","in":"path","required":true}],"responses":{"200":{"description":"OK"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errr.ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errr.ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/dto.UpdateChannelEmail"}}},"description":"Request Body","required":true}}}}}
```

## GET /notifications/v1/notifications

> Get notifications of organisation

```json
{"openapi":"3.1.1","info":{"title":"MariaDB Cloud DBaaS API","version":"1.0"},"servers":[{"url":"https://api.skysql.com/"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"apiKey","name":"X-API-Key","in":"header"}},"schemas":{"dto.Notification":{"type":"object","properties":{"category":{"type":"string"},"created_by":{"type":"string"},"created_on":{"type":"integer"},"display_string":{"type":"string"},"event_type":{"type":"string"},"id":{"type":"string"},"level":{"type":"string"},"marked_read":{"type":"boolean"},"org_id":{"type":"string"},"subscriber_id":{"type":"string"}}},"errr.ErrorResponse":{"type":"object","properties":{"code":{"type":"integer"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/errr.ErrorDetails"}},"exception":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"path":{"type":"string"},"timestamp":{"type":"integer"},"trace_id":{"type":"string"}}},"errr.ErrorDetails":{"type":"object","properties":{"error":{"type":"string"},"location":{"type":"string"},"message":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"solution":{"type":"string"},"type":{"$ref":"#/components/schemas/errr.Type"}}},"errr.Type":{"type":"string","enum":["fatal","error","warning"]}}},"paths":{"/notifications/v1/notifications":{"get":{"tags":["Notifications"],"summary":"Get notifications of organisation","parameters":[{"schema":{"type":"integer"},"description":"Number of records per page.","name":"page_size","in":"query"},{"schema":{"type":"string"},"description":"Page token to fetch next or previous page.","name":"page_token","in":"query"},{"schema":{"type":"string"},"description":"comma separated list of categories to filter","name":"category","in":"query"},{"schema":{"type":"string"},"description":"service name filter","name":"service_name","in":"query"},{"schema":{"type":"string"},"description":"timestamp(epoch). return rows where created_on < created_before","name":"created_before","in":"query"},{"schema":{"type":"string"},"description":"timestamp(epoch). return rows where created_on > created_after","name":"created_after","in":"query"}],"responses":{"200":{"description":"OK","headers":{"X-SkySQL-Page-Token-Previous":{"schema":{"type":"string"},"description":"Page token to fetch previous page"},"X-SkySQL-Page-Token-Next":{"schema":{"type":"string"},"description":"Page token to fetch next page"}},"content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/dto.Notification"}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errr.ErrorResponse"}}}}}}}}}
```

## PUT /notifications/v1/notifications/read

> mark notifications as read

```json
{"openapi":"3.1.1","info":{"title":"MariaDB Cloud DBaaS API","version":"1.0"},"servers":[{"url":"https://api.skysql.com/"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"apiKey","name":"X-API-Key","in":"header"}},"schemas":{"errr.ErrorResponse":{"type":"object","properties":{"code":{"type":"integer"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/errr.ErrorDetails"}},"exception":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"path":{"type":"string"},"timestamp":{"type":"integer"},"trace_id":{"type":"string"}}},"errr.ErrorDetails":{"type":"object","properties":{"error":{"type":"string"},"location":{"type":"string"},"message":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"solution":{"type":"string"},"type":{"$ref":"#/components/schemas/errr.Type"}}},"errr.Type":{"type":"string","enum":["fatal","error","warning"]},"dto.SaveLastReadNotification":{"type":"object","properties":{"last_read_on":{"type":"integer"}}}}},"paths":{"/notifications/v1/notifications/read":{"put":{"tags":["Notifications"],"summary":"mark notifications as read","responses":{"200":{"description":"OK"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errr.ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/dto.SaveLastReadNotification"}}},"description":"Request Body","required":true}}}}}
```

## GET /notifications/v1/preferences

> Get notification preference/subscription of a subscriber

```json
{"openapi":"3.1.1","info":{"title":"MariaDB Cloud DBaaS API","version":"1.0"},"servers":[{"url":"https://api.skysql.com/"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"apiKey","name":"X-API-Key","in":"header"}},"schemas":{"dto.Preference":{"type":"object","properties":{"categories":{"type":"object","additionalProperties":{"type":"boolean"}},"org_id":{"type":"string"},"subscriber_id":{"type":"string"}}},"errr.ErrorResponse":{"type":"object","properties":{"code":{"type":"integer"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/errr.ErrorDetails"}},"exception":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"path":{"type":"string"},"timestamp":{"type":"integer"},"trace_id":{"type":"string"}}},"errr.ErrorDetails":{"type":"object","properties":{"error":{"type":"string"},"location":{"type":"string"},"message":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"solution":{"type":"string"},"type":{"$ref":"#/components/schemas/errr.Type"}}},"errr.Type":{"type":"string","enum":["fatal","error","warning"]}}},"paths":{"/notifications/v1/preferences":{"get":{"consumes":["application/json"],"tags":["Notifications"],"summary":"Get notification preference/subscription of a subscriber","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/dto.Preference"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errr.ErrorResponse"}}}}}}}}}
```

## PUT /notifications/v1/preferences

> update notification preference/subscription of a subscriber

```json
{"openapi":"3.1.1","info":{"title":"MariaDB Cloud DBaaS API","version":"1.0"},"servers":[{"url":"https://api.skysql.com/"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"apiKey","name":"X-API-Key","in":"header"}},"schemas":{"errr.ErrorResponse":{"type":"object","properties":{"code":{"type":"integer"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/errr.ErrorDetails"}},"exception":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"path":{"type":"string"},"timestamp":{"type":"integer"},"trace_id":{"type":"string"}}},"errr.ErrorDetails":{"type":"object","properties":{"error":{"type":"string"},"location":{"type":"string"},"message":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"solution":{"type":"string"},"type":{"$ref":"#/components/schemas/errr.Type"}}},"errr.Type":{"type":"string","enum":["fatal","error","warning"]},"dto.UpdatePreference":{"type":"object","properties":{"categories":{"type":"object","additionalProperties":{"type":"boolean"}}}}}},"paths":{"/notifications/v1/preferences":{"put":{"tags":["Notifications"],"summary":"update notification preference/subscription of a subscriber","responses":{"200":{"description":"OK"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errr.ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errr.ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/dto.UpdatePreference"}}},"description":"Request Body","required":true}}}}}
```
