Notifications

GET /api/notifications

Get authenticated user notifications.

Scope: notifications:read

Example requests:

  • without parameters:

GET /api/notifications HTTP/1.1
  • with some query parameters:

GET /api/notifications?page=2&status=unread  HTTP/1.1

Example responses:

  • returning at least one notification:

HTTP/1.1 200 OK
Content-Type: application/json

  {
    "notifications": [
      {
        "created_at": "Wed, 04 Dec 2024 10:06:35 GMT",
        "from": {
          "created_at": "Wed, 04 Dec 2024 09:07:08 GMT",
          "followers": 0,
          "following": 0,
          "follows": "pending",
          "is_followed_by": "false",
          "nb_workouts": 0,
          "picture": true,
          "role": "admin",
          "suspended_at": null,
          "username": "admin"
        },
        "id": "be26f35a-1239-44ff-a012-12fb835fa26c",
        "marked_as_read": false,
        "type": "follow_request"
      }
    ],
    "pagination": {
      "has_next": false,
      "has_prev": false,
      "page": 1,
      "pages": 1,
      "total": 1
    },
    "status": "success"
  }
  • returning no notifications

HTTP/1.1 200 OK
Content-Type: application/json

  {
    "notifications": [],
    "pagination": {
      "has_next": false,
      "has_prev": false,
      "page": 1,
      "pages": 0,
      "total": 0
    },
    "status": "success"
  }
Query Parameters:
  • page (integer) – page if using pagination (default: 1)

  • order (string) – sorting order: asc, desc (default: desc)

  • status (string) – notification read status (read, unread)

Request Headers:
Status Codes:
  • 200 OKsuccess

  • 401 Unauthorized

    • provide a valid auth token

    • signature expired, please log in again

    • invalid token, please log in again

  • 403 Forbidden

    • you do not have permissions, your account is suspended

PATCH /api/notifications/(string: notification_id)

Update authenticated user notification read status.

Scope: notifications:write

Example request:

PATCH /api/notifications/be26f35a-1239-44ff-a012-12fb835fa26c HTTP/1.1

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

 {
    "notification": {
      "created_at": "Wed, 04 Dec 2024 10:06:35 GMT",
      "from": {
        "created_at": "Wed, 04 Dec 2024 09:07:08 GMT",
        "followers": 0,
        "following": 0,
        "follows": "pending",
        "is_followed_by": "false",
        "nb_workouts": 0,
        "picture": true,
        "role": "admin",
        "suspended_at": null,
        "username": "admin"
      },
      "id": "be26f35a-1239-44ff-a012-12fb835fa26c",
      "marked_as_read": true,
      "type": "follow_request"
    },
    "status": "success"
  }
Parameters:
  • notification_id (string) – notification short id

Request JSON Object:
  • read_status (boolean) – notification read status

Request Headers:
Status Codes:
GET /api/notifications/unread

Get if unread notifications exist for authenticated user.

Scope: notifications:read

Example request:

GET /api/notifications/unread HTTP/1.1

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

 {
    "status": "success",
    "unread": false
  }
Request Headers:
Status Codes:
  • 200 OKsuccess

  • 401 Unauthorized

    • provide a valid auth token

    • signature expired, please log in again

    • invalid token, please log in again

  • 403 Forbidden

    • you do not have permissions, your account is suspended

POST /api/notifications/mark-all-as-read

Mark all authenticated user notifications as read.

Scope: notifications:write

Example request:

POST /api/notifications/mark-all-as-read HTTP/1.1

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

 {
    "status": "success"
  }
Request JSON Object:
  • type (boolean) – notification type (optional)

Request Headers:
Status Codes:
GET /api/notifications/types

Get types of notifications received by authenticated user.

Scope: notifications:read

Example requests:

  • without parameters:

GET /api/notifications/types HTTP/1.1
  • with query parameter:

GET /api/notifications/types?status=unread  HTTP/1.1

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

 {
    "notification_types": [
      "mention"
    ],
    "status": "success"
 }
Query Parameters:
  • status (string) – notification read status (read, unread)

Request Headers:
Status Codes:
  • 200 OKsuccess

  • 401 Unauthorized

    • provide a valid auth token

    • signature expired, please log in again

    • invalid token, please log in again

  • 403 Forbidden

    • you do not have permissions, your account is suspended