# Get stale flags chart data

GET https://app.launchdarkly.com/api/v2/engineering-insights/charts/flags/stale

Get stale flags chart data. Engineering insights displays stale flags data in the [flag health metric view](https://launchdarkly.com/docs/home/observability/flag-health).

### Expanding the chart response

LaunchDarkly supports expanding the chart response to include additional fields.

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

* `metrics` includes details on the metrics related to stale flags

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


Reference: https://launchdarkly.com/docs/api/insights-charts-beta/get-stale-flags-chart

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/engineering-insights/charts/flags/stale:
    get:
      operationId: get-stale-flags-chart
      summary: Get stale flags chart data
      description: >
        Get stale flags chart data. Engineering insights displays stale flags
        data in the [flag health metric
        view](https://launchdarkly.com/docs/home/observability/flag-health).


        ### Expanding the chart response


        LaunchDarkly supports expanding the chart response to include additional
        fields.


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


        * `metrics` includes details on the metrics related to stale flags


        For example, use `?expand=metrics` to include the `metrics` field in the
        response. By default, this field is **not** included in the response.
      tags:
        - subpackage_insightsChartsBeta
      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: groupBy
          in: query
          description: 'Property to group results by. Options: `maintainer`'
          required: false
          schema:
            type: string
            format: string
        - name: maintainerId
          in: query
          description: Comma-separated list of individual maintainers to filter results.
          required: false
          schema:
            type: string
            format: string
        - name: maintainerTeamKey
          in: query
          description: Comma-separated list of team maintainer keys to filter results.
          required: false
          schema:
            type: string
            format: string
        - name: expand
          in: query
          description: 'Options: `metrics`'
          required: false
          schema:
            type: string
            format: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Chart response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InsightsChart'
        '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:
    InsightsChartMetadataCustomValues:
      type: object
      additionalProperties:
        description: Any type
      title: InsightsChartMetadataCustomValues
    InsightsMetricTierDefinition:
      type: object
      properties:
        indicator:
          type: string
          description: Metric indicator tier
        description:
          type: string
          description: Metric indicator description
      required:
        - indicator
        - description
      title: InsightsMetricTierDefinition
    InsightsChartMetric:
      type: object
      properties:
        indicator:
          type: string
          description: Metric indicator tier
        value:
          type: number
          format: double
          description: Metric value
        unit:
          type: string
          description: Metric unit
        modifier:
          type: string
          description: Metric modifier
        tiers:
          type: array
          items:
            $ref: '#/components/schemas/InsightsMetricTierDefinition'
          description: Metric indicator tiers
      required:
        - indicator
        - value
        - unit
        - modifier
        - tiers
      title: InsightsChartMetric
    InsightsChartMetrics:
      type: object
      additionalProperties:
        $ref: '#/components/schemas/InsightsChartMetric'
      title: InsightsChartMetrics
    InsightsChartSeriesMetadataAxis:
      type: object
      properties:
        unit:
          type: string
          description: Unit of the axis
      required:
        - unit
      title: InsightsChartSeriesMetadataAxis
    InsightsChartMetadata:
      type: object
      properties:
        summary:
          $ref: '#/components/schemas/InsightsChartMetadataCustomValues'
          description: Metadata values
        name:
          type: string
          description: Name of the chart
        metrics:
          $ref: '#/components/schemas/InsightsChartMetrics'
          description: Metrics for the given chart data, included when expanded
        xAxis:
          $ref: '#/components/schemas/InsightsChartSeriesMetadataAxis'
          description: X-axis metadata
        yAxis:
          $ref: '#/components/schemas/InsightsChartSeriesMetadataAxis'
          description: Y-axis metadata
      required:
        - summary
        - xAxis
        - yAxis
      title: InsightsChartMetadata
    InsightsChartBounds:
      type: object
      properties:
        name:
          type: string
          description: Name of the bound
        value:
          type: integer
          format: int64
          description: Value of the bound
      required:
        - name
        - value
      title: InsightsChartBounds
    InsightsChartSeriesMetadata:
      type: object
      properties:
        name:
          type: string
          description: Name of the series
        count:
          type: integer
          format: int64
          description: Aggregate count of the series values
        bounds:
          type: array
          items:
            $ref: '#/components/schemas/InsightsChartBounds'
          description: Bounds for the series data
      required:
        - name
      title: InsightsChartSeriesMetadata
    InsightsChartSeriesDataPoint:
      type: object
      properties:
        x:
          type: integer
          format: int64
          description: X-axis value
        'y':
          type: integer
          format: int64
          description: Y-axis value
        values:
          type: object
          additionalProperties:
            description: Any type
          description: Additional values for the data point
      required:
        - x
        - 'y'
      title: InsightsChartSeriesDataPoint
    InsightsChartSeries:
      type: object
      properties:
        metadata:
          $ref: '#/components/schemas/InsightsChartSeriesMetadata'
          description: Metadata for the series
        data:
          type: array
          items:
            $ref: '#/components/schemas/InsightsChartSeriesDataPoint'
          description: Data points for the series
      required:
        - metadata
        - data
      title: InsightsChartSeries
    InsightsChart:
      type: object
      properties:
        metadata:
          $ref: '#/components/schemas/InsightsChartMetadata'
          description: Metadata for the chart
        series:
          type: array
          items:
            $ref: '#/components/schemas/InsightsChartSeries'
          description: Series data for the chart
      required:
        - metadata
        - series
      title: InsightsChart
    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/charts/flags/stale"

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/charts/flags/stale?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/charts/flags/stale?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/charts/flags/stale?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/charts/flags/stale?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/charts/flags/stale?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/charts/flags/stale?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/charts/flags/stale?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()
```