{"openapi":"3.1.0","info":{"title":"notification-service","description":"## Authentication\n\nAll endpoints require a short-lived Bearer token issued by the API service.\n\n```\nPOST /api/v4/notifications/token/\nAuthorization: Bearer <user JWT>\n```\n\nPass the returned token as `Authorization: Bearer <token>` on every request.\n\n## Endpoints\n\n- **notifications** — list, read, unread, delete individual and bulk notifications\n- **device-tokens** — register APNs / FCM tokens for push delivery (iOS, Android, Web)","version":"0.1.0"},"paths":{"/notifications/":{"get":{"tags":["notifications"],"summary":"List notifications","description":"Returns a paginated list of notifications for the authenticated user, ordered by creation date descending.","operationId":"list_notifications_notifications__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":100,"minimum":1,"default":20,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}},{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Comma-separated statuses, e.g. sent,read","title":"Status"},"description":"Comma-separated statuses, e.g. sent,read"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotificationListOut"}}}},"401":{"description":"Missing or invalid Bearer token"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["notifications"],"summary":"Delete all notifications","description":"Deletes all notifications for the authenticated user.","operationId":"delete_all_notifications_notifications__delete","security":[{"HTTPBearer":[]}],"responses":{"200":{"description":"Count of deleted notifications","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkActionOut"}}}},"401":{"description":"Missing or invalid Bearer token"}}}},"/notifications/{notification_id}/read":{"patch":{"tags":["notifications"],"summary":"Mark a notification as read","description":"Marks the specified notification as read for the authenticated user. Requires a Bearer token issued by `POST /api/v4/notifications/token/` on the API service. The `user_id` embedded in the token must match the owner of the notification.","operationId":"mark_notification_read_notifications__notification_id__read_patch","security":[{"HTTPBearer":[]}],"parameters":[{"name":"notification_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Notification Id"}}],"responses":{"200":{"description":"Notification marked as read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarkReadOut"}}}},"401":{"description":"Missing or invalid Bearer token"},"403":{"description":"Notification belongs to a different user"},"404":{"description":"Notification not found"},"409":{"description":"Notification is already read"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/notifications/{notification_id}/unread":{"patch":{"tags":["notifications"],"summary":"Mark a notification as unread","description":"Marks the specified notification as unread. Returns 409 if already unread.","operationId":"mark_notification_unread_notifications__notification_id__unread_patch","security":[{"HTTPBearer":[]}],"parameters":[{"name":"notification_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Notification Id"}}],"responses":{"200":{"description":"Notification marked as unread","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarkReadOut"}}}},"401":{"description":"Missing or invalid Bearer token"},"403":{"description":"Notification belongs to a different user"},"404":{"description":"Notification not found"},"409":{"description":"Notification is already unread"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/notifications/{notification_id}":{"delete":{"tags":["notifications"],"summary":"Delete a notification","description":"Deletes the specified notification and all its delivery records.","operationId":"delete_notification_notifications__notification_id__delete","security":[{"HTTPBearer":[]}],"parameters":[{"name":"notification_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Notification Id"}}],"responses":{"200":{"description":"Notification deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarkReadOut"}}}},"401":{"description":"Missing or invalid Bearer token"},"403":{"description":"Notification belongs to a different user"},"404":{"description":"Notification not found"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/notifications/read-all":{"patch":{"tags":["notifications"],"summary":"Mark all notifications as read","description":"Marks all unread notifications for the authenticated user as read.","operationId":"mark_all_read_notifications_read_all_patch","responses":{"200":{"description":"Count of notifications marked as read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkActionOut"}}}},"401":{"description":"Missing or invalid Bearer token"}},"security":[{"HTTPBearer":[]}]}},"/devices/tokens/":{"post":{"tags":["device-tokens"],"summary":"Register or upsert a device token","description":"Registers a push token for the authenticated user. If the token value already exists for this user, updates `last_seen_at`. Returns 409 if the token value is already registered to a different user. Safe to call on every app launch.","operationId":"register_token_devices_tokens__post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeviceTokenIn"}}},"required":true},"responses":{"200":{"description":"Token registered or updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeviceTokenOut"}}}},"401":{"description":"Missing or invalid Bearer token"},"409":{"description":"Token already registered to a different account"},"422":{"description":"Invalid platform or token"},"429":{"description":"Rate limit exceeded"}},"security":[{"HTTPBearer":[]}]}},"/devices/tokens/{token_id}/":{"put":{"tags":["device-tokens"],"summary":"Rotate a device token","description":"Replaces the stored push token string for an existing registration. Use when the platform SDK issues a new token for the same device. Returns 404 if the record does not belong to the authenticated user, or if the new token value is already registered.","operationId":"rotate_token_devices_tokens__token_id___put","security":[{"HTTPBearer":[]}],"parameters":[{"name":"token_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Token Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeviceTokenRotateIn"}}}},"responses":{"200":{"description":"Token rotated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeviceTokenOut"}}}},"401":{"description":"Missing or invalid Bearer token"},"404":{"description":"Token not found"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["device-tokens"],"summary":"Revoke a device token","description":"Permanently removes a push token registration. Returns 404 if the record does not belong to the authenticated user.","operationId":"revoke_token_devices_tokens__token_id___delete","security":[{"HTTPBearer":[]}],"parameters":[{"name":"token_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Token Id"}}],"responses":{"204":{"description":"Token revoked"},"401":{"description":"Missing or invalid Bearer token"},"404":{"description":"Token not found"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/health":{"get":{"summary":"Health","operationId":"health_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}}},"components":{"schemas":{"BulkActionOut":{"properties":{"count":{"type":"integer","title":"Count"}},"type":"object","required":["count"],"title":"BulkActionOut"},"DevicePlatform":{"type":"string","enum":["ios","android","web"],"title":"DevicePlatform"},"DeviceTokenIn":{"properties":{"token":{"type":"string","maxLength":500,"minLength":1,"title":"Token"},"platform":{"$ref":"#/components/schemas/DevicePlatform"}},"type":"object","required":["token","platform"],"title":"DeviceTokenIn"},"DeviceTokenOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"platform":{"$ref":"#/components/schemas/DevicePlatform"},"is_active":{"type":"boolean","title":"Is Active"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"last_seen_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Seen At"}},"type":"object","required":["id","platform","is_active","created_at","last_seen_at"],"title":"DeviceTokenOut"},"DeviceTokenRotateIn":{"properties":{"token":{"type":"string","maxLength":500,"minLength":1,"title":"Token"}},"type":"object","required":["token"],"title":"DeviceTokenRotateIn"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"MarkReadOut":{"properties":{"status":{"type":"string","title":"Status"}},"type":"object","required":["status"],"title":"MarkReadOut"},"NotificationListOut":{"properties":{"items":{"items":{"$ref":"#/components/schemas/NotificationOut"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total"},"has_more":{"type":"boolean","title":"Has More"},"unread_count":{"type":"integer","title":"Unread Count"}},"type":"object","required":["items","total","has_more","unread_count"],"title":"NotificationListOut"},"NotificationOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"user_id":{"type":"string","format":"uuid","title":"User Id"},"event_type":{"type":"string","title":"Event Type"},"title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Title"},"body":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Body"},"status":{"type":"string","title":"Status"},"idempotency_key":{"type":"string","title":"Idempotency Key"},"metadata":{"additionalProperties":true,"type":"object","title":"Metadata"},"created_at":{"type":"string","format":"date-time","title":"Created At"}},"type":"object","required":["id","user_id","event_type","title","body","status","idempotency_key","created_at"],"title":"NotificationOut"},"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"}},"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer"}}},"tags":[{"name":"notifications","description":"Read, acknowledge, and delete in-app notifications for the authenticated user."},{"name":"device-tokens","description":"Register and manage push-notification device tokens. Call `POST /devices/tokens/` on every app launch to keep the token current. Platforms: `ios` (APNs), `android` (FCM), `web` (FCM webpush)."}]}