# List release policies

GET https://app.launchdarkly.com/api/v2/projects/{projectKey}/release-policies

Get a list of release policies for the specified project with optional filtering.

Reference: https://launchdarkly.com/docs/api/release-policies-beta/get-release-policies

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/projects/{projectKey}/release-policies:
    get:
      operationId: get-release-policies
      summary: List release policies
      description: >-
        Get a list of release policies for the specified project with optional
        filtering.
      tags:
        - subpackage_releasePoliciesBeta
      parameters:
        - name: projectKey
          in: path
          description: The project key
          required: true
          schema:
            type: string
        - name: excludeDefault
          in: query
          description: >-
            When true, exclude the default release policy from the response.
            When false or omitted, include the default policy if an environment
            filter is present.
          required: false
          schema:
            type: boolean
            default: false
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
        - name: LD-API-Version
          in: header
          description: Version of the endpoint.
          required: true
          schema:
            $ref: >-
              #/components/schemas/ApiV2ProjectsProjectKeyReleasePoliciesGetParametersLdApiVersion
      responses:
        '200':
          description: List of release policies
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReleasePoliciesResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Invalid access token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    ApiV2ProjectsProjectKeyReleasePoliciesGetParametersLdApiVersion:
      type: string
      enum:
        - beta
      title: ApiV2ProjectsProjectKeyReleasePoliciesGetParametersLdApiVersion
    ActionSpecifier:
      type: string
      title: ActionSpecifier
    ReleasePoliciesAccessDeniedReasonEffect:
      type: string
      enum:
        - allow
        - deny
      description: Whether this statement should allow or deny actions on the resources.
      title: ReleasePoliciesAccessDeniedReasonEffect
    ReleasePoliciesAccessDeniedReason:
      type: object
      properties:
        resources:
          type: array
          items:
            type: string
          description: Resource specifier strings
        notResources:
          type: array
          items:
            type: string
          description: >-
            Targeted resources are the resources NOT in this list. The
            <code>resources</code> and <code>notActions</code> fields must be
            empty to use this field.
        actions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: Actions to perform on a resource
        notActions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: >-
            Targeted actions are the actions NOT in this list. The
            <code>actions</code> and <code>notResources</code> fields must be
            empty to use this field.
        effect:
          $ref: '#/components/schemas/ReleasePoliciesAccessDeniedReasonEffect'
          description: >-
            Whether this statement should allow or deny actions on the
            resources.
        role_name:
          type: string
      required:
        - effect
      title: ReleasePoliciesAccessDeniedReason
    ReleasePoliciesAccessDenied:
      type: object
      properties:
        action:
          type: string
        reason:
          $ref: '#/components/schemas/ReleasePoliciesAccessDeniedReason'
      required:
        - action
        - reason
      title: ReleasePoliciesAccessDenied
    ReleasePoliciesAccessAllowedReasonEffect:
      type: string
      enum:
        - allow
        - deny
      description: Whether this statement should allow or deny actions on the resources.
      title: ReleasePoliciesAccessAllowedReasonEffect
    ReleasePoliciesAccessAllowedReason:
      type: object
      properties:
        resources:
          type: array
          items:
            type: string
          description: Resource specifier strings
        notResources:
          type: array
          items:
            type: string
          description: >-
            Targeted resources are the resources NOT in this list. The
            <code>resources</code> and <code>notActions</code> fields must be
            empty to use this field.
        actions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: Actions to perform on a resource
        notActions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: >-
            Targeted actions are the actions NOT in this list. The
            <code>actions</code> and <code>notResources</code> fields must be
            empty to use this field.
        effect:
          $ref: '#/components/schemas/ReleasePoliciesAccessAllowedReasonEffect'
          description: >-
            Whether this statement should allow or deny actions on the
            resources.
        role_name:
          type: string
      required:
        - effect
      title: ReleasePoliciesAccessAllowedReason
    ReleasePoliciesAccessAllowedRep:
      type: object
      properties:
        action:
          type: string
        reason:
          $ref: '#/components/schemas/ReleasePoliciesAccessAllowedReason'
      required:
        - action
        - reason
      title: ReleasePoliciesAccessAllowedRep
    ReleasePoliciesAccessRep:
      type: object
      properties:
        denied:
          type: array
          items:
            $ref: '#/components/schemas/ReleasePoliciesAccessDenied'
        allowed:
          type: array
          items:
            $ref: '#/components/schemas/ReleasePoliciesAccessAllowedRep'
      required:
        - denied
        - allowed
      title: ReleasePoliciesAccessRep
    ReleasePolicyScope:
      type: object
      properties:
        environmentKeys:
          type: array
          items:
            type: string
          description: List of environment keys this policy applies to
        flagTagKeys:
          type: array
          items:
            type: string
          description: List of flag tag keys this policy applies to
      title: ReleasePolicyScope
    ReleaseMethod:
      type: string
      enum:
        - guarded-release
        - progressive-release
      description: The release method for this policy
      title: ReleaseMethod
    ReleasePolicyStage:
      type: object
      properties:
        allocation:
          type: integer
        durationMillis:
          type: integer
          format: int64
      required:
        - allocation
        - durationMillis
      title: ReleasePolicyStage
    GuardedReleaseConfig:
      type: object
      properties:
        rolloutContextKindKey:
          type: string
          description: Context kind key to use as the randomization unit for the rollout
        minSampleSize:
          type: integer
          description: The minimum number of samples required to make a decision
        rollbackOnRegression:
          type: boolean
          description: Whether to roll back on regression
        metricKeys:
          type: array
          items:
            type: string
          description: List of metric keys
        metricGroupKeys:
          type: array
          items:
            type: string
          description: List of metric group keys
        stages:
          type: array
          items:
            $ref: '#/components/schemas/ReleasePolicyStage'
          description: List of stages
      description: Configuration for guarded releases
      title: GuardedReleaseConfig
    ProgressiveReleaseConfig:
      type: object
      properties:
        rolloutContextKindKey:
          type: string
          description: Context kind key to use as the randomization unit for the rollout
        stages:
          type: array
          items:
            $ref: '#/components/schemas/ReleasePolicyStage'
          description: List of stages
      description: Configuration for progressive releases
      title: ProgressiveReleaseConfig
    ReleasePolicy:
      type: object
      properties:
        _access:
          $ref: '#/components/schemas/ReleasePoliciesAccessRep'
        _id:
          type: string
          description: The unique identifier of the release policy
        scope:
          $ref: '#/components/schemas/ReleasePolicyScope'
        rank:
          type: integer
          description: The rank/priority of the release policy
        releaseMethod:
          $ref: '#/components/schemas/ReleaseMethod'
        guardedReleaseConfig:
          $ref: '#/components/schemas/GuardedReleaseConfig'
        progressiveReleaseConfig:
          $ref: '#/components/schemas/ProgressiveReleaseConfig'
        name:
          type: string
          description: The name of the release policy
        key:
          type: string
          description: The human-readable key of the release policy
      required:
        - _id
        - rank
        - releaseMethod
        - name
        - key
      title: ReleasePolicy
    ReleasePoliciesResponse:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/ReleasePolicy'
          description: List of release policies
        totalCount:
          type: integer
          description: Total number of release policies
      required:
        - items
        - totalCount
      title: ReleasePoliciesResponse
    Error:
      type: object
      properties:
        message:
          type: string
        code:
          type: string
      required:
        - message
        - code
      title: Error
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

```

## SDK Code Examples

```python
import requests

url = "https://app.launchdarkly.com/api/v2/projects/default/release-policies"

querystring = {"excludeDefault":"false"}

headers = {
    "LD-API-Version": "beta",
    "Authorization": "<apiKey>"
}

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

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/projects/default/release-policies?excludeDefault=false';
const options = {method: 'GET', headers: {'LD-API-Version': 'beta', 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/projects/default/release-policies?excludeDefault=false"

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

	req.Header.Add("LD-API-Version", "beta")
	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/projects/default/release-policies?excludeDefault=false")

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

request = Net::HTTP::Get.new(url)
request["LD-API-Version"] = 'beta'
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/projects/default/release-policies?excludeDefault=false")
  .header("LD-API-Version", "beta")
  .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/projects/default/release-policies?excludeDefault=false', [
  'headers' => [
    'Authorization' => '<apiKey>',
    'LD-API-Version' => 'beta',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/projects/default/release-policies?excludeDefault=false");
var request = new RestRequest(Method.GET);
request.AddHeader("LD-API-Version", "beta");
request.AddHeader("Authorization", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "LD-API-Version": "beta",
  "Authorization": "<apiKey>"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/projects/default/release-policies?excludeDefault=false")! 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()
```