# List flag events

GET https://app.launchdarkly.com/api/v2/engineering-insights/flag-events

Get a list of flag events

### Expanding the flag event collection response

LaunchDarkly supports expanding the flag event collection response to include additional fields.

To expand the response, append the `expand` query parameter and include the following:

* `experiments` includes details on all of the experiments run on each flag

For example, use `?expand=experiments` to include the `experiments` field in the response. By default, this field is **not** included in the response.


Reference: https://launchdarkly.com/docs/api/insights-flag-events-beta/get-flag-events

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/engineering-insights/flag-events:
    get:
      operationId: get-flag-events
      summary: List flag events
      description: >
        Get a list of flag events


        ### Expanding the flag event collection response


        LaunchDarkly supports expanding the flag event collection response to
        include additional fields.


        To expand the response, append the `expand` query parameter and include
        the following:


        * `experiments` includes details on all of the experiments run on each
        flag


        For example, use `?expand=experiments` to include the `experiments`
        field in the response. By default, this field is **not** included in the
        response.
      tags:
        - subpackage_insightsFlagEventsBeta
      parameters:
        - name: projectKey
          in: query
          description: The project key
          required: true
          schema:
            type: string
            format: string
        - name: environmentKey
          in: query
          description: The environment key
          required: true
          schema:
            type: string
            format: string
        - name: applicationKey
          in: query
          description: Comma separated list of application keys
          required: false
          schema:
            type: string
            format: string
        - name: query
          in: query
          description: Filter events by flag key
          required: false
          schema:
            type: string
            format: string
        - name: impactSize
          in: query
          description: >-
            Filter events by impact size. A small impact created a less than 20%
            change in the proportion of end users receiving one or more flag
            variations. A medium impact created between a 20%-80% change. A
            large impact created a more than 80% change. Options: `none`,
            `small`, `medium`, `large`
          required: false
          schema:
            type: string
            format: string
        - name: hasExperiments
          in: query
          description: >-
            Filter events to those associated with an experiment (`true`) or
            without an experiment (`false`)
          required: false
          schema:
            type: boolean
        - name: global
          in: query
          description: >-
            Filter to include or exclude global events. Default value is
            `include`. Options: `include`, `exclude`
          required: false
          schema:
            type: string
            format: string
        - name: expand
          in: query
          description: 'Expand properties in response. Options: `experiments`'
          required: false
          schema:
            type: string
            format: string
        - name: limit
          in: query
          description: >-
            The number of deployments to return. Default is 20. Maximum allowed
            is 100.
          required: false
          schema:
            type: integer
            format: int64
        - name: from
          in: query
          description: Unix timestamp in milliseconds. Default value is 7 days ago.
          required: false
          schema:
            type: integer
            format: int64
        - name: to
          in: query
          description: Unix timestamp in milliseconds. Default value is now.
          required: false
          schema:
            type: integer
            format: int64
        - name: after
          in: query
          description: Identifier used for pagination
          required: false
          schema:
            type: string
            format: string
        - name: before
          in: query
          description: Identifier used for pagination
          required: false
          schema:
            type: string
            format: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Flag event collection response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FlagEventCollectionRep'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationFailedErrorRep'
        '401':
          description: Invalid access token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorRep'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenErrorRep'
        '404':
          description: Invalid resource identifier
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundErrorRep'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitedErrorRep'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    EventType:
      type: string
      title: EventType
    UnixMillis:
      type: integer
      format: int64
      title: UnixMillis
    FlagEventMemberRep:
      type: object
      properties:
        id:
          type: string
          description: The member ID
        email:
          type: string
          description: The member email
        firstName:
          type: string
          description: The member first name
        lastName:
          type: string
          description: The member last name
      required:
        - id
        - email
        - firstName
        - lastName
      title: FlagEventMemberRep
    FlagEventImpactRepSize:
      type: string
      enum:
        - none
        - small
        - medium
        - large
      description: >-
        The size of the flag event impact. Sizes are defined as: none (0%),
        small (0-20%), medium (20-80%), large (>80%)
      title: FlagEventImpactRepSize
    ImpactReason:
      type: string
      title: ImpactReason
    VariationEvalSummary:
      type: object
      properties:
        value:
          description: The variation value
        before:
          type: integer
          format: int64
          description: The number of evaluations in the ten minutes before the flag event
        after:
          type: integer
          format: int64
          description: The number of evaluations in the ten minutes after the flag event
      title: VariationEvalSummary
    EvaluationsSummary:
      type: object
      properties:
        variations:
          type: array
          items:
            $ref: '#/components/schemas/VariationEvalSummary'
          description: A list of variation evaluations
      title: EvaluationsSummary
    FlagEventImpactRep:
      type: object
      properties:
        size:
          $ref: '#/components/schemas/FlagEventImpactRepSize'
          description: >-
            The size of the flag event impact. Sizes are defined as: none (0%),
            small (0-20%), medium (20-80%), large (>80%)
        percentage:
          type: number
          format: double
          description: The percentage of the flag event impact
        reason:
          $ref: '#/components/schemas/ImpactReason'
          description: The reason for the flag event impact
        evaluationsSummary:
          $ref: '#/components/schemas/EvaluationsSummary'
          description: >-
            A summary of the change in variation evaluations after the flag
            event
      title: FlagEventImpactRep
    IterationStatus:
      type: string
      title: IterationStatus
    Link:
      type: object
      properties:
        href:
          type: string
          description: The URL of the link
        type:
          type: string
          description: The type of the link
      title: Link
    FlagEventExperimentIteration:
      type: object
      properties:
        id:
          type: string
          description: The experiment iteration ID
        status:
          $ref: '#/components/schemas/IterationStatus'
          description: The experiment iteration status
        startedAt:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the iteration started
        endedAt:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the iteration ended
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
      required:
        - id
        - status
        - startedAt
      title: FlagEventExperimentIteration
    FlagEventExperiment:
      type: object
      properties:
        key:
          type: string
          description: The experiment key
        name:
          type: string
          description: The experiment name
        iteration:
          $ref: '#/components/schemas/FlagEventExperimentIteration'
          description: The experiment iteration
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
      required:
        - key
        - name
        - iteration
      title: FlagEventExperiment
    FlagEventExperimentCollection:
      type: object
      properties:
        totalCount:
          type: integer
          description: The total number of experiments
        items:
          type: array
          items:
            $ref: '#/components/schemas/FlagEventExperiment'
          description: A list of experiments
      required:
        - totalCount
        - items
      title: FlagEventExperimentCollection
    FlagEventRep:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: The flag event ID
        projectId:
          type: string
          description: The project ID
        projectKey:
          type: string
          description: The project key
        environmentId:
          type: string
          description: The environment ID
        environmentKey:
          type: string
          description: The environment key
        flagKey:
          type: string
          description: The flag key
        eventType:
          $ref: '#/components/schemas/EventType'
          description: The event type
        eventTime:
          $ref: '#/components/schemas/UnixMillis'
          description: A Unix timestamp in milliseconds
        description:
          type: string
          description: The event description
        auditLogEntryId:
          type: string
          description: The audit log entry ID
        member:
          $ref: '#/components/schemas/FlagEventMemberRep'
          description: The member data
        actions:
          type: array
          items:
            type: string
          description: The resource actions
        impact:
          $ref: '#/components/schemas/FlagEventImpactRep'
          description: The flag event evaluation impact
        experiments:
          $ref: '#/components/schemas/FlagEventExperimentCollection'
          description: A list of experiment iterations related to the flag event
      required:
        - id
        - projectId
        - projectKey
        - flagKey
        - eventType
        - eventTime
        - description
        - impact
      title: FlagEventRep
    FlagEventCollectionRep:
      type: object
      properties:
        totalCount:
          type: integer
          description: The total number of flag events
        items:
          type: array
          items:
            $ref: '#/components/schemas/FlagEventRep'
          description: A list of flag events
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
      required:
        - totalCount
        - items
      title: FlagEventCollectionRep
    FailureReasonRep:
      type: object
      properties:
        attribute:
          type: string
          description: The attribute that failed validation
        reason:
          type: string
          description: The reason the attribute failed validation
      required:
        - attribute
        - reason
      title: FailureReasonRep
    ValidationFailedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
        errors:
          type: array
          items:
            $ref: '#/components/schemas/FailureReasonRep'
          description: List of validation errors
      required:
        - code
        - message
        - errors
      title: ValidationFailedErrorRep
    UnauthorizedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: UnauthorizedErrorRep
    ForbiddenErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: ForbiddenErrorRep
    NotFoundErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: NotFoundErrorRep
    RateLimitedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: RateLimitedErrorRep
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

```

## SDK Code Examples

```python
import requests

url = "https://app.launchdarkly.com/api/v2/engineering-insights/flag-events"

querystring = {"projectKey":"projectKey","environmentKey":"environmentKey"}

headers = {"Authorization": "<apiKey>"}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/engineering-insights/flag-events?projectKey=projectKey&environmentKey=environmentKey';
const options = {method: 'GET', headers: {Authorization: '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://app.launchdarkly.com/api/v2/engineering-insights/flag-events?projectKey=projectKey&environmentKey=environmentKey"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.launchdarkly.com/api/v2/engineering-insights/flag-events?projectKey=projectKey&environmentKey=environmentKey")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://app.launchdarkly.com/api/v2/engineering-insights/flag-events?projectKey=projectKey&environmentKey=environmentKey")
  .header("Authorization", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://app.launchdarkly.com/api/v2/engineering-insights/flag-events?projectKey=projectKey&environmentKey=environmentKey', [
  'headers' => [
    'Authorization' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/engineering-insights/flag-events?projectKey=projectKey&environmentKey=environmentKey");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/engineering-insights/flag-events?projectKey=projectKey&environmentKey=environmentKey")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```