2021-01-29 00:20:46 +05:30
---
2022-10-11 01:57:18 +05:30
stage: Govern
2021-06-08 01:23:25 +05:30
group: Compliance
2021-02-22 17:27:13 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2021-01-29 00:20:46 +05:30
---
2021-11-11 11:23:49 +05:30
# Events API **(FREE)**
2017-09-10 17:25:29 +05:30
## Filter parameters
2021-12-11 22:18:48 +05:30
### Actions
2017-09-10 17:25:29 +05:30
2022-06-21 17:19:12 +05:30
See [User contribution events ](../user/profile/index.md#user-contribution-events ) for available types for the `action` parameter.
2021-10-27 15:23:28 +05:30
These options are in lowercase.
2017-09-10 17:25:29 +05:30
### Target Types
Available target types for the `target_type` parameter are:
- `issue`
- `milestone`
- `merge_request`
- `note`
- `project`
- `snippet`
- `user`
2021-10-27 15:23:28 +05:30
These options are in lowercase.
2021-12-11 22:18:48 +05:30
Events associated with epics are not available using the API.
2017-09-10 17:25:29 +05:30
### Date formatting
Dates for the `before` and `after` parameters should be supplied in the following format:
2020-04-08 14:13:33 +05:30
```plaintext
2017-09-10 17:25:29 +05:30
YYYY-MM-DD
```
2018-05-09 12:01:36 +05:30
### Event Time Period Limit
2021-10-27 15:23:28 +05:30
GitLab removes events older than 3 years from the events table for performance reasons.
2018-05-09 12:01:36 +05:30
2017-09-10 17:25:29 +05:30
## List currently authenticated user's events
2018-11-20 20:47:30 +05:30
Get a list of events for the authenticated user. Scope `read_user` or `api` is required.
2021-12-11 22:18:48 +05:30
Events associated with epics are not available using the API.
2017-09-10 17:25:29 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2017-09-10 17:25:29 +05:30
GET /events
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-12-11 22:18:48 +05:30
| `action` | string | no | Include only events of a particular [action type ](#actions ) |
2020-05-24 23:13:21 +05:30
| `target_type` | string | no | Include only events of a particular [target type ](#target-types ) |
2021-06-08 01:23:25 +05:30
| `before` | date | no | Include only events created before a particular date. [View how to format dates ](#date-formatting ). |
| `after` | date | no | Include only events created after a particular date. [View how to format dates ](#date-formatting ). |
2020-03-13 15:44:24 +05:30
| `scope` | string | no | Include all events across a user's projects. |
2021-06-08 01:23:25 +05:30
| `sort` | string | no | Sort events in `asc` or `desc` order by `created_at` . Default is `desc` . |
2017-09-10 17:25:29 +05:30
Example request:
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/events?target_type=issue& action=created& after=2017-01-31& before=2017-03-01& scope=all"
2017-09-10 17:25:29 +05:30
```
Example response:
```json
[
{
2020-10-24 23:57:45 +05:30
"id": 1,
2017-09-10 17:25:29 +05:30
"title":null,
"project_id":1,
"action_name":"opened",
"target_id":160,
"target_type":"Issue",
"author_id":25,
"target_title":"Qui natus eos odio tempore et quaerat consequuntur ducimus cupiditate quis.",
"created_at":"2017-02-09T10:43:19.667Z",
"author":{
"name":"User 3",
"username":"user3",
"id":25,
"state":"active",
"avatar_url":"http://www.gravatar.com/avatar/97d6d9441ff85fdc730e02a6068d267b?s=80\u0026d=identicon",
"web_url":"https://gitlab.example.com/user3"
},
"author_username":"user3"
},
{
2020-10-24 23:57:45 +05:30
"id": 2,
2017-09-10 17:25:29 +05:30
"title":null,
"project_id":1,
"action_name":"opened",
"target_id":159,
"target_type":"Issue",
"author_id":21,
"target_title":"Nostrum enim non et sed optio illo deleniti non.",
"created_at":"2017-02-09T10:43:19.426Z",
"author":{
"name":"Test User",
"username":"ted",
"id":21,
"state":"active",
"avatar_url":"http://www.gravatar.com/avatar/80fb888c9a48b9a3f87477214acaa63f?s=80\u0026d=identicon",
"web_url":"https://gitlab.example.com/ted"
},
"author_username":"ted"
}
]
```
### Get user contribution events
2018-11-20 20:47:30 +05:30
Get the contribution events for the specified user, sorted from newest to oldest. Scope `read_user` or `api` is required.
2021-12-11 22:18:48 +05:30
Events associated with epics are not available using API.
2017-09-10 17:25:29 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2017-09-10 17:25:29 +05:30
GET /users/:id/events
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID or Username of the user |
2021-12-11 22:18:48 +05:30
| `action` | string | no | Include only events of a particular [action type ](#actions ) |
2020-05-24 23:13:21 +05:30
| `target_type` | string | no | Include only events of a particular [target type ](#target-types ) |
2021-06-08 01:23:25 +05:30
| `before` | date | no | Include only events created before a particular date. [View how to format dates ](#date-formatting ). |
| `after` | date | no | Include only events created after a particular date. [View how to format dates ](#date-formatting ). |
| `sort` | string | no | Sort events in `asc` or `desc` order by `created_at` . Default is `desc` . |
2021-04-29 21:17:54 +05:30
| `page` | integer | no | The page of results to return. Defaults to 1. |
| `per_page` | integer | no | The number of results per page. Defaults to 20. |
2017-09-10 17:25:29 +05:30
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/users/:id/events"
2017-09-10 17:25:29 +05:30
```
Example response:
```json
[
{
2020-10-24 23:57:45 +05:30
"id": 3,
2017-09-10 17:25:29 +05:30
"title": null,
"project_id": 15,
"action_name": "closed",
"target_id": 830,
"target_type": "Issue",
"author_id": 1,
"target_title": "Public project search field",
"author": {
"name": "Dmitriy Zaporozhets",
"username": "root",
"id": 1,
"state": "active",
"avatar_url": "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png",
"web_url": "http://localhost:3000/root"
},
"author_username": "root"
},
{
2020-10-24 23:57:45 +05:30
"id": 4,
2017-09-10 17:25:29 +05:30
"title": null,
"project_id": 15,
"action_name": "pushed",
"target_id": null,
"target_type": null,
"author_id": 1,
"author": {
"name": "Dmitriy Zaporozhets",
"username": "root",
"id": 1,
"state": "active",
"avatar_url": "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png",
"web_url": "http://localhost:3000/root"
},
"author_username": "john",
"push_data": {
"commit_count": 1,
"action": "pushed",
"ref_type": "branch",
"commit_from": "50d4420237a9de7be1304607147aec22e4a14af7",
"commit_to": "c5feabde2d8cd023215af4d2ceeb7a64839fc428",
"ref": "master",
"commit_title": "Add simple search to projects in public area"
},
"target_title": null
},
{
2020-10-24 23:57:45 +05:30
"id": 5,
2017-09-10 17:25:29 +05:30
"title": null,
"project_id": 15,
"action_name": "closed",
"target_id": 840,
"target_type": "Issue",
"author_id": 1,
"target_title": "Finish & merge Code search PR",
"author": {
"name": "Dmitriy Zaporozhets",
"username": "root",
"id": 1,
"state": "active",
"avatar_url": "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png",
"web_url": "http://localhost:3000/root"
},
"author_username": "root"
},
{
2020-10-24 23:57:45 +05:30
"id": 7,
2017-09-10 17:25:29 +05:30
"title": null,
"project_id": 15,
"action_name": "commented on",
"target_id": 1312,
"target_type": "Note",
"author_id": 1,
"target_title": null,
"created_at": "2015-12-04T10:33:58.089Z",
"note": {
"id": 1312,
"body": "What an awesome day!",
"attachment": null,
"author": {
"name": "Dmitriy Zaporozhets",
"username": "root",
"id": 1,
"state": "active",
"avatar_url": "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png",
"web_url": "http://localhost:3000/root"
},
"created_at": "2015-12-04T10:33:56.698Z",
"system": false,
"noteable_id": 377,
"noteable_type": "Issue"
},
"author": {
"name": "Dmitriy Zaporozhets",
"username": "root",
"id": 1,
"state": "active",
"avatar_url": "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png",
"web_url": "http://localhost:3000/root"
},
"author_username": "root"
}
]
```
## List a Project's visible events
2021-02-22 17:27:13 +05:30
NOTE:
2020-10-24 23:57:45 +05:30
This endpoint has been around longer than the others. Documentation was formerly located in the [Projects API pages ](projects.md ).
2017-09-10 17:25:29 +05:30
Get a list of visible events for a particular project.
2020-04-08 14:13:33 +05:30
```plaintext
2018-11-20 20:47:30 +05:30
GET /projects/:project_id/events
2017-09-10 17:25:29 +05:30
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-09-30 23:02:18 +05:30
| `project_id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) |
2021-12-11 22:18:48 +05:30
| `action` | string | no | Include only events of a particular [action type ](#actions ) |
2020-05-24 23:13:21 +05:30
| `target_type` | string | no | Include only events of a particular [target type ](#target-types ) |
2021-06-08 01:23:25 +05:30
| `before` | date | no | Include only events created before a particular date. [View how to format dates ](#date-formatting ). |
| `after` | date | no | Include only events created after a particular date. [View how to format dates ](#date-formatting ). |
| `sort` | string | no | Sort events in `asc` or `desc` order by `created_at` . Default is `desc` . |
2017-09-10 17:25:29 +05:30
Example request:
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/:project_id/events?target_type=issue& action=created& after=2017-01-31& before=2017-03-01"
2017-09-10 17:25:29 +05:30
```
Example response:
```json
[
{
2021-06-08 01:23:25 +05:30
"id": 8,
2017-09-10 17:25:29 +05:30
"title":null,
"project_id":1,
"action_name":"opened",
"target_id":160,
"target_iid":160,
"target_type":"Issue",
"author_id":25,
"target_title":"Qui natus eos odio tempore et quaerat consequuntur ducimus cupiditate quis.",
"created_at":"2017-02-09T10:43:19.667Z",
"author":{
"name":"User 3",
"username":"user3",
"id":25,
"state":"active",
"avatar_url":"http://www.gravatar.com/avatar/97d6d9441ff85fdc730e02a6068d267b?s=80\u0026d=identicon",
"web_url":"https://gitlab.example.com/user3"
},
"author_username":"user3"
},
{
2020-10-24 23:57:45 +05:30
"id": 9,
2017-09-10 17:25:29 +05:30
"title":null,
"project_id":1,
"action_name":"opened",
"target_id":159,
"target_iid":159,
"target_type":"Issue",
"author_id":21,
"target_title":"Nostrum enim non et sed optio illo deleniti non.",
"created_at":"2017-02-09T10:43:19.426Z",
"author":{
"name":"Test User",
"username":"ted",
"id":21,
"state":"active",
"avatar_url":"http://www.gravatar.com/avatar/80fb888c9a48b9a3f87477214acaa63f?s=80\u0026d=identicon",
"web_url":"https://gitlab.example.com/ted"
},
"author_username":"ted"
},
{
2020-10-24 23:57:45 +05:30
"id": 10,
2017-09-10 17:25:29 +05:30
"title": null,
"project_id": 1,
"action_name": "commented on",
"target_id": 1312,
"target_iid": 1312,
"target_type": "Note",
"author_id": 1,
"data": null,
"target_title": null,
"created_at": "2015-12-04T10:33:58.089Z",
"note": {
"id": 1312,
"body": "What an awesome day!",
"attachment": null,
"author": {
"name": "Dmitriy Zaporozhets",
"username": "root",
"id": 1,
"state": "active",
2019-12-04 20:38:33 +05:30
"avatar_url": "https://gitlab.example.com/uploads/user/avatar/1/fox_avatar.png",
"web_url": "https://gitlab.example.com/root"
2017-09-10 17:25:29 +05:30
},
"created_at": "2015-12-04T10:33:56.698Z",
"system": false,
"noteable_id": 377,
"noteable_type": "Issue",
"noteable_iid": 377
},
"author": {
"name": "Dmitriy Zaporozhets",
"username": "root",
"id": 1,
"state": "active",
2019-12-04 20:38:33 +05:30
"avatar_url": "https://gitlab.example.com/uploads/user/avatar/1/fox_avatar.png",
"web_url": "https://gitlab.example.com/root"
2017-09-10 17:25:29 +05:30
},
"author_username": "root"
}
]
```