---
title: Events
slug: infra/events
createdAt: 2023-06-28T11:51:19.441Z
---

Socratease gives you a variety of webhooks you can listen to, to notify your application that an event has occurred.&#x20;

Currently, Socratease supports webhooks for events on `assessments` and`units`.  The events are mentioned below.

# Unit Events

::::ExpandableHeading{isOpen="true"}
## Unit Created `unit.created`

Emitted when a unit is created. The payload below gives you the details of the unit created.

:::CodeblockTabs
unit.created

```json
{
"data": {
  "int_id": 10,
  "unit_id": "abc-def-ghi",
  "title": "Python Quiz",
  "type": "quiz", //can be 'quiz', 'lesson', 'question_bank', etc
  "meta_data": {
    "thumbnail": "https://cdn.socratease.co/abc.png"
  },
  "access_level": "logged_in", //must be logged in to attempt it
  "settings": {
    "randomize_options": true,
    "disable_copy_paste": false    
  },
  ...
},
"event_type": "unit.created"
  
}
```
:::
::::

::::ExpandableHeading{isOpen="true"}
## Unit Deleted `unit.deleted`

Emitted when a unit is deleted. The payload below gives you the unit\_id of the unit which has been deleted.

:::CodeblockTabs
unit.deleted

```json
{
  "data": {
    "unit_id": "abc-def-ghi",
    ...
  },
  "event_type": "unit.deleted"
  
}
```
:::
::::

::::ExpandableHeading{isOpen="true"}
## Unit Started `unit.started`

Emitted when a user starts attempting a unit. The payload below gives you the details of the when the unit was started, and the user's details&#x20;

:::CodeblockTabs
unit.started

```json
{
  "data": {
    "unit_id": "abc-def-ghi",
    "started_at": "2023-02-14T06:22:58+00:00",
    "user": {
      "email": "abcd@gmail.com",
      "user_id": "aXsweqW",
      "username": "abcd@gmail.com",
    }
    ...
  },
  "event_type": "unit.started"
  
}
```
:::
::::

::::ExpandableHeading{isOpen="true"}
## Unit Submitted `unit.submitted`&#x20;

Emitted when a user submits a unit. The payload below gives you the details of the assessment submission, and the user's details&#x20;

:::CodeblockTabs
unit.submitted

```json
{
  "data": {
    "unit_id": "abc-def-ghi",
    "started_at": "2023-02-14T06:12:58+00:00",
    "finished_at": "2023-02-14T06:14:35+00:00", 
    "points_aggregate": 70,
    "percentage_decimal": 0.7,
    "total_points": 100,
    "grade_finalized": true,
    "attempt_num": 1,
    "unit_type": "quiz",
    "user": {
      "user_id": "aXsweqW",
      "username": "abcd@gmail.com",
      "email": "abcd@gmail.com",
    }
    ...
  },
  "event_type": "unit.submitted"

}
```
:::
::::

# Assessment Events

::::ExpandableHeading{isOpen="true"}
## Assessment Created `assessment.created`&#x20;

Emitted when an assessment is created. The payload below gives you all the details of the assessment which is created and the units present within the assessment.

:::CodeblockTabs
assessment.created

```json
{
"data": {
  "access_level": public,
  "assessment_id": "kpu-nsg-hoi",
  "event_type": "assessment.created"
  "max_attempts": 1,
  "meta_data": {"thumbnail_url": "https://image.com"},
  "settings": {
     "auto_submit":false,
    },
  "status": active
  "title": "Your Assessment Title"
  "units": [
     {
        "title":"Test 1",
        "unit_id":"ntg-wtk-pfk",
        "type":"quiz",
        "meta_data":{
           "thumbnail_url":"https://image2.com",
        },
        "weightage":10000
     }
    ]
    ...
  },
"event_type": "assessment.created"
  
}
```
:::
::::

::::ExpandableHeading{isOpen="true"}
## Assessment Deleted `assessment.deleted`

Emitted when an assessment is deleted. The payload below gives you `assessment_id` of the assessment which has been deleted.

:::CodeblockTabs
assessment.deleted

```json
{
  "data": {
    "assessment_id": "kpu-nsg-hoi",
    ...
  },
  "event_type": "assessment.deleted"
  
}
```
:::
::::

::::ExpandableHeading{isOpen="true"}
## Assessment Started `assessment.started`

Emitted when a user starts attempting an assessment. The payload below gives you the details of the when the assessment was started, and the user's details&#x20;

:::CodeblockTabs
assessment.started

```json
{
  "data": {
    "assessment_id": "kpu-nsg-hoi",
    "started_at": "2023-02-14T06:22:58+00:00",
    "user": {
      "email": "abcd@gmail.com",
      "user_id": "aXsweqW",
      "username": "abcd@gmail.com",
    }
    ...
  },
  "event_type": "assessment.started"
  
}
```
:::
::::

::::ExpandableHeading{isOpen="true"}
## Assessment Submitted `assessment.submitted`&#x20;

Emitted when a user submits an assessment. The payload below gives you the details of the assessment submission, and the user's details&#x20;

:::CodeblockTabs
assessment.submitted

```json
{
  "data": {
    "assessment_id": "kpu-nsg-hoi",
    "started_at": "2023-02-14T06:12:58+00:00",
    "finished_at": "2023-02-14T06:14:35+00:00", 
    "overall_score": 7000,
    "grade_finalized": true,
    "attempt_num": 1,
    "unit_results": [
      {
        "unit_id": "aGh-wWq-nJW",
        "points_aggregate": 70",
        "total_points": 100,
        "percentage_decimal": 0.7
        ... 
      }
    ]
    "user": {
      "user_id": "aXsweqW",
      "username": "abcd@gmail.com",
      "email": "abcd@gmail.com",
    }
    ...
  },
  "event_type": "assessment.submitted"

}
```
:::


::::







