# Get release for flag

GET https://app.launchdarkly.com/api/v2/flags/{projectKey}/{flagKey}/release

Get currently active release for a flag

Reference: https://launchdarkly.com/docs/api/releases-beta/get-release-by-flag-key

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/flags/{projectKey}/{flagKey}/release:
    get:
      operationId: get-release-by-flag-key
      summary: Get release for flag
      description: Get currently active release for a flag
      tags:
        - subpackage_releasesBeta
      parameters:
        - name: projectKey
          in: path
          description: The project key
          required: true
          schema:
            type: string
            format: string
        - name: flagKey
          in: path
          description: The flag key
          required: true
          schema:
            type: string
            format: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Release response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Release'
        '404':
          description: Invalid resource identifier
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundErrorRep'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    Link:
      type: object
      properties:
        href:
          type: string
          description: The URL of the link
        type:
          type: string
          description: The type of the link
      title: Link
    UnixMillis:
      type: integer
      format: int64
      title: UnixMillis
    MemberSummary:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        _id:
          type: string
          description: The member's ID
        firstName:
          type: string
          description: The member's first name
        lastName:
          type: string
          description: The member's last name
        role:
          type: string
          description: >-
            The member's base role. If the member has no additional roles, this
            role will be in effect.
        email:
          type: string
          description: The member's email address
      required:
        - _links
        - _id
        - role
        - email
      title: MemberSummary
    TokenSummary:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
        _id:
          type: string
        name:
          type: string
          description: The name of the token
        ending:
          type: string
          description: The last few characters of the token
        serviceToken:
          type: boolean
          description: Whether this is a service token
      title: TokenSummary
    CompletedBy:
      type: object
      properties:
        member:
          $ref: '#/components/schemas/MemberSummary'
          description: The LaunchDarkly member who marked this phase as complete
        token:
          $ref: '#/components/schemas/TokenSummary'
          description: The service token used to mark this phase as complete
      title: CompletedBy
    EnvironmentSummary:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        key:
          type: string
          description: A project-unique key for the environment
        name:
          type: string
          description: A human-friendly name for the environment
        color:
          type: string
          description: The color used to indicate this environment in the UI
      required:
        - _links
        - key
        - name
        - color
      title: EnvironmentSummary
    ReleaseStrategy:
      type: string
      title: ReleaseStrategy
    ReleaseGuardianConfiguration:
      type: object
      properties:
        monitoringWindowMilliseconds:
          type: integer
          format: int64
          description: The monitoring window in milliseconds
        rolloutWeight:
          type: integer
          description: The rollout weight percentage
        rollbackOnRegression:
          type: boolean
          description: Whether or not to roll back on regression
        randomizationUnit:
          type: string
          description: The randomization unit for the measured rollout
      required:
        - monitoringWindowMilliseconds
        - rolloutWeight
        - rollbackOnRegression
      title: ReleaseGuardianConfiguration
    AudienceConfiguration:
      type: object
      properties:
        releaseStrategy:
          $ref: '#/components/schemas/ReleaseStrategy'
          description: The release strategy
        requireApproval:
          type: boolean
          description: Whether or not the audience requires approval
        notifyMemberIds:
          type: array
          items:
            type: string
          description: >-
            An array of member IDs. These members are notified to review the
            approval request.
        notifyTeamKeys:
          type: array
          items:
            type: string
          description: >-
            An array of team keys. The members of these teams are notified to
            review the approval request.
        releaseGuardianConfiguration:
          $ref: '#/components/schemas/ReleaseGuardianConfiguration'
          description: The configuration for the release guardian.
      required:
        - releaseStrategy
        - requireApproval
      title: AudienceConfiguration
    AudienceStatus:
      type: string
      title: AudienceStatus
    ReleaseAudience:
      type: object
      properties:
        _id:
          type: string
          description: The audience ID
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        environment:
          $ref: '#/components/schemas/EnvironmentSummary'
          description: >-
            Details about the environment. If the environment is deleted, this
            field will be omitted.
        name:
          type: string
          description: The release phase name
        configuration:
          $ref: '#/components/schemas/AudienceConfiguration'
          description: The audience configuration
        segmentKeys:
          type: array
          items:
            type: string
          description: A list of segment keys
        status:
          $ref: '#/components/schemas/AudienceStatus'
          description: The audience status
        _ruleIds:
          type: array
          items:
            type: string
          description: The rules IDs added or updated by this audience
      required:
        - _id
        - name
      title: ReleaseAudience
    PhaseStatus:
      type: string
      title: PhaseStatus
    PhaseConfiguration:
      type: object
      properties: {}
      title: PhaseConfiguration
    ReleasePhase:
      type: object
      properties:
        _id:
          type: string
          description: The phase ID
        _name:
          type: string
          description: The release phase name
        complete:
          type: boolean
          description: Whether this phase is complete
        _creationDate:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the release phase was created
        _completionDate:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the release phase was completed
        _completedBy:
          $ref: '#/components/schemas/CompletedBy'
          description: Details about how this phase was marked as complete
        _audiences:
          type: array
          items:
            $ref: '#/components/schemas/ReleaseAudience'
          description: >-
            A logical grouping of one or more environments that share attributes
            for rolling out changes
        status:
          $ref: '#/components/schemas/PhaseStatus'
          description: Status of the phase
        started:
          type: boolean
          description: Whether or not this phase has started
        _startedDate:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the release phase was started
        configuration:
          $ref: '#/components/schemas/PhaseConfiguration'
          description: The phase configuration
      required:
        - _id
        - _name
        - complete
        - _creationDate
        - _audiences
      title: ReleasePhase
    Release:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        name:
          type: string
          description: The release pipeline name
        releasePipelineKey:
          type: string
          description: The release pipeline key
        releasePipelineDescription:
          type: string
          description: The release pipeline description
        phases:
          type: array
          items:
            $ref: '#/components/schemas/ReleasePhase'
          description: An ordered list of the release pipeline phases
        _version:
          type: integer
          description: The release version
        _releaseVariationId:
          type: string
          description: >-
            The chosen release variation ID to use across all phases of a
            release
        _canceledAt:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the release was canceled
      required:
        - name
        - releasePipelineKey
        - releasePipelineDescription
        - phases
        - _version
      title: Release
    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
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

```

## SDK Code Examples

```python
import requests

url = "https://app.launchdarkly.com/api/v2/flags/projectKey/flagKey/release"

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

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

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/flags/projectKey/flagKey/release';
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/flags/projectKey/flagKey/release"

	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/flags/projectKey/flagKey/release")

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/flags/projectKey/flagKey/release")
  .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/flags/projectKey/flagKey/release', [
  'headers' => [
    'Authorization' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/flags/projectKey/flagKey/release");
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/flags/projectKey/flagKey/release")! 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()
```