2018-11-20 20:34:42 +01:00
---
title: /api/admin/events
---
2022-07-01 13:51:26 +02:00
2022-06-07 12:33:30 +02:00
import ApiRequest from '@site/src/components/ApiRequest'
2018-11-20 20:34:42 +01:00
2022-08-04 11:10:41 +02:00
:::note
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
In order to access the admin API endpoints you need to identify yourself. Unless you're using the `none` authentication method, you'll need to [create an ADMIN token ](/how-to/how-to-create-api-tokens ) and add an Authorization header using the token.
2022-08-04 11:10:41 +02:00
:::
2020-12-03 21:29:01 +01:00
2023-07-19 11:25:27 +02:00
The Events API lets you retrieve [events ](/reference/event-types.mdx ) from your Unleash instance.
2016-11-30 21:17:39 +01:00
2022-06-07 12:33:30 +02:00
## Event endpoints
2016-11-30 21:17:39 +01:00
2022-06-07 12:33:30 +02:00
### Get all events
2016-11-30 21:17:39 +01:00
2022-06-07 12:33:30 +02:00
< ApiRequest verb = "get" url = "api/admin/events" title = "Retrieve all events from the Unleash instance." / >
2016-11-30 21:17:39 +01:00
2022-06-07 12:33:30 +02:00
#### Query parameters
2022-07-01 13:51:26 +02:00
| Query parameter | Description | Required |
| --- | --- | --- |
| `project` | When applied, the endpoint will only return events from the given project. | No |
2022-06-07 12:33:30 +02:00
2022-07-01 13:51:26 +02:00
When called without any query parameters, the endpoint will return the **last 100 events** from the Unleash instance. When called with a `project` query parameter, it will return only events related to that project, but it will return **all the events** , and not just the last 100.
2022-06-07 12:33:30 +02:00
#### Get events by project
< ApiRequest verb = "get" url = "api/admin/events?project=<project-name>" title = "Retrieve all events belonging to the given project." / >
2022-07-01 13:51:26 +02:00
Use the `project` query parameter to make the API return _all_ events pertaining to the given project.
2022-06-07 12:33:30 +02:00
#### Responses
< details >
< summary > Responses< / summary >
##### 200 OK
The last 100 events from the Unleash server when called without a `project` query parameter.
When called with a `project` query parameter: all events related to that project.
2022-07-01 13:51:26 +02:00
```json title="Successful response; a list of events"
2022-06-07 12:33:30 +02:00
{
"version": 1,
"events": [
{
"id": 842,
"type": "feature-environment-enabled",
"createdBy": "user@company.com",
"createdAt": "2022-05-12T08:49:49.521Z",
"data": null,
"preData": null,
"tags": [],
"featureName": "my-constrained-toggle",
"project": "my-project",
"environment": "development"
},
{
"id": 841,
"type": "feature-environment-disabled",
"createdBy": "user@company.com",
"createdAt": "2022-05-12T08:49:45.986Z",
"data": null,
"preData": null,
"tags": [],
"featureName": "my-constrained-toggle",
"project": "my-project",
"environment": "development"
}
]
}
```
< / details >
### Get events for a specific toggle
< ApiRequest verb = "get" url = "api/admin/events/<toggle-name>" title = "Retrieve all events related to the given toggle." / >
Fetch all events related to a specified toggle.
#### Responses
< details >
< summary > Responses< / summary >
###### 200 OK
The list of events related to the given toggle.
2022-07-01 13:51:26 +02:00
```json title="Successful response; all events relating to the specified toggle"
2022-06-07 12:33:30 +02:00
{
"toggleName": "my-constrained-toggle",
"events": [
{
"id": 842,
"type": "feature-environment-enabled",
"createdBy": "user@company.com",
"createdAt": "2022-05-12T08:49:49.521Z",
"data": null,
"preData": null,
"tags": [],
"featureName": "my-constrained-toggle",
"project": "my-project",
"environment": "development"
},
{
"id": 841,
"type": "feature-environment-disabled",
"createdBy": "user@company.com",
"createdAt": "2022-05-12T08:49:45.986Z",
"data": null,
"preData": null,
"tags": [],
"featureName": "my-constrained-toggle",
"project": "my-project",
"environment": "development"
}
]
}
```
< / details >
## Event type description
2023-07-19 11:25:27 +02:00
:::note Content moved
2022-06-07 12:33:30 +02:00
2023-07-19 11:25:27 +02:00
This section has been moved to a dedicated [event type reference document ](/reference/event-types.mdx ).
2022-08-04 11:10:41 +02:00
:::