> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opigno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Notification

In-built site notifications can be created in the following cases (there is an API notification type in brackets):

1. When someone registers the user to a training (`USER_REGISTERED_TO_TRAINING`);
2. One month before a certification expiration (`ONE_MONTH_CERT_EXPIRATION`);
3. When a certification has expired (`CERT_EXPIRED`);
4. When a user completes a training (`TRAINING_COMPLETED`);
5. When a new badge is earned (`BADGE_EARNED`);
6. For all community members (except the post author) when a new post is added  (if the related setting is enabled for the community) (`NEW_COMMUNITY_POST`);
7. When someone added a comment on the user's post (`POST_COMMENTED`);
8. When someone liked the user's post or comment (`POST_LIKED`);
9. When a new connection invitation is created (`NEW_USER_INVITATION`);
10. When a user's connection invitation is accepted (`USER_INVITATION_ACCEPTED`);
11. When a new [challenge](/OpignoEnterpriseAPI/Challenge/GetChallenge) opens (`NEW_CHALLENGE_STARTED`);
12. Every 5 days when an available challenge is in progress, and a user did not complete it yet (`ONGOING_CHALLENGE_NOT_COMPLETED`);
13. When someone challenged a user for a battle (`NEW_BATTLE`);
14. When the user has won the battle (`BATTLE_WIN`);
15. When the user has lost the battle (`BATTLE_LOST`);
16. When the battle has finished with the status "draw". (`BATTLE_DRAW`).

## Notification API object

`Notification` object represents a single notification data:

| Parameter       | Type                        | Description                                                                                            |
| :-------------- | :-------------------------- | :----------------------------------------------------------------------------------------------------- |
| `id`            | `ID`                        | **Required**. The notification ID.                                                                     |
| `text`          | `String`                    | **Required**. The notification text.                                                                   |
| `type`          | `NotificationType`          | **Required**. The type of the notification that can be used for the results filtering.                 |
| `created`       | `Int`                       | **Required**. A timestamp when the notification was created.                                           |
| `status`        | `NotificationStatus`        | **Required**. The notification status (read/unread). Can be used to filter the query results.          |
| `relatedEntity` | `NotificationRelatedEntity` | An entity that triggered the notification creation. Contains an API object that represents the entity. |
| `cta`           | `[Cta]`                     | Contains the list of [Call To Action](#notification-cta) objects available for the given notification. |

## Notification CTA

The list of available CTAs can differ depending on the notification type.

| Action ID                 | Description                                                                                                                      | Corresponding mutation/query                                                                                  |
| :------------------------ | :------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------ |
| `ACCEPT_USER_INVITATION`  | Allows to accept the user invitation related to the notification and add the invitation initiator to the current user's network. | [`acceptUserInvitation`](/OpignoEnterpriseAPI/UserConnection/AcceptDeclineUserInvitation#accept-invitation)   |
| `CREATE_BATTLE_ATTEMPT`   | Allows to create an attempt for the battle where the current API user has been selected as an opponent.                          | [`createBattleAttempt`](/OpignoEnterpriseAPI/Battle/RespondToBattle)                                          |
| `DECLINE_USER_INVITATION` | Allows to decline the user invitation related to the notification.                                                               | [`declineUserInvitation`](/OpignoEnterpriseAPI/UserConnection/AcceptDeclineUserInvitation#decline-invitation) |
| `VIEW_BADGES_LIST`        | View the list of earned badges.                                                                                                  | [`getBadges`](/OpignoEnterpriseAPI/Badges#getbadges)                                                          |
| `VIEW_BATTLE_RESULTS`     | View the related battle results.                                                                                                 | [`getBattle`](/OpignoEnterpriseAPI/Battle/GetBattle)                                                          |
| `VIEW_CHALLENGE`          | View the related challenge.                                                                                                      | [`getChallenge`](/OpignoEnterpriseAPI/Challenge/GetChallenge)                                                 |
| `VIEW_POST`               | Allows to view the post/comment related to the notification.                                                                     | [`getPost`](/OpignoEnterpriseAPI/Post/GetPost)                                                                |
| `VIEW_LP`                 | Allows to view the learning path related to the notification.                                                                    | `getLearningPath`, [example](/OpignoEnterpriseAPI/LearningPathHomepage#retrieving-a-learning-path-object)     |
| `VIEW_USER_CONTEXT`       | View the related user context.                                                                                                   | [`getUserContext`](/OpignoEnterpriseAPI/UserContextManagement#retrieving-a-user-context)                      |
