# List projects

GET https://app.launchdarkly.com/api/v2/projects

Return a list of projects.

By default, this returns the first 20 projects. Page through this list with the `limit` parameter and by following the `first`, `prev`, `next`, and `last` links in the `_links` field that returns. If those links do not appear, the pages they refer to don't exist. For example, the `first` and `prev` links will be missing from the response on the first page, because there is no previous page and you cannot return to the first page when you are already on the first page.

### Filtering projects

LaunchDarkly supports three fields for filters:
- `query` is a string that matches against the projects' names and keys. It is not case sensitive.
- `tags` is a `+`-separated list of project tags. It filters the list of projects that have all of the tags in the list.
- `keys` is a `|` separated list of project keys. It filters the list to projects that have any of the keys in the list.

For example, the filter `filter=query:abc,tags:tag-1+tag-2` matches projects with the string `abc` in their name or key and also are tagged with `tag-1` and `tag-2`. The filter is not case-sensitive.

The documented values for `filter` query parameters are prior to URL encoding. For example, the `+` in `filter=tags:tag-1+tag-2` must be encoded to `%2B`.

### Sorting projects

LaunchDarkly supports two fields for sorting:
- `name` sorts by project name.
- `createdOn` sorts by the creation date of the project.

For example, `sort=name` sorts the response by project name in ascending order.

### Expanding the projects response

LaunchDarkly supports one field for expanding the "List projects" response. By default, these fields are **not** included in the response.

To expand the response, append the `expand` query parameter and add a comma-separated list with the `environments` field.

* `environments` includes a paginated list of the project environments.

For example, `expand=environments` includes the `environments` field for each project in the response.


Reference: https://launchdarkly.com/docs/api/projects/get-projects

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/projects:
    get:
      operationId: get-projects
      summary: List projects
      description: >
        Return a list of projects.


        By default, this returns the first 20 projects. Page through this list
        with the `limit` parameter and by following the `first`, `prev`, `next`,
        and `last` links in the `_links` field that returns. If those links do
        not appear, the pages they refer to don't exist. For example, the
        `first` and `prev` links will be missing from the response on the first
        page, because there is no previous page and you cannot return to the
        first page when you are already on the first page.


        ### Filtering projects


        LaunchDarkly supports three fields for filters:

        - `query` is a string that matches against the projects' names and keys.
        It is not case sensitive.

        - `tags` is a `+`-separated list of project tags. It filters the list of
        projects that have all of the tags in the list.

        - `keys` is a `|` separated list of project keys. It filters the list to
        projects that have any of the keys in the list.


        For example, the filter `filter=query:abc,tags:tag-1+tag-2` matches
        projects with the string `abc` in their name or key and also are tagged
        with `tag-1` and `tag-2`. The filter is not case-sensitive.


        The documented values for `filter` query parameters are prior to URL
        encoding. For example, the `+` in `filter=tags:tag-1+tag-2` must be
        encoded to `%2B`.


        ### Sorting projects


        LaunchDarkly supports two fields for sorting:

        - `name` sorts by project name.

        - `createdOn` sorts by the creation date of the project.


        For example, `sort=name` sorts the response by project name in ascending
        order.


        ### Expanding the projects response


        LaunchDarkly supports one field for expanding the "List projects"
        response. By default, these fields are **not** included in the response.


        To expand the response, append the `expand` query parameter and add a
        comma-separated list with the `environments` field.


        * `environments` includes a paginated list of the project environments.


        For example, `expand=environments` includes the `environments` field for
        each project in the response.
      tags:
        - subpackage_projects
      parameters:
        - name: limit
          in: query
          description: The number of projects to return in the response. Defaults to 20.
          required: false
          schema:
            type: integer
            format: int64
        - name: offset
          in: query
          description: >-
            Where to start in the list. Use this with pagination. For example,
            an offset of 10 skips the first ten items and returns the next
            `limit` items.
          required: false
          schema:
            type: integer
            format: int64
        - name: filter
          in: query
          description: >-
            A comma-separated list of filters. Each filter is constructed as
            `field:value`.
          required: false
          schema:
            type: string
            format: string
        - name: sort
          in: query
          description: >-
            A comma-separated list of fields to sort by. Fields prefixed by a
            dash ( - ) sort in descending order.
          required: false
          schema:
            type: string
            format: string
        - name: expand
          in: query
          description: >-
            A comma-separated list of properties that can reveal additional
            information in the response.
          required: false
          schema:
            type: string
            format: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Project collection response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Projects'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidRequestErrorRep'
        '401':
          description: Invalid access token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorRep'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenErrorRep'
        '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:
    Link:
      type: object
      properties:
        href:
          type: string
          description: The URL of the link
        type:
          type: string
          description: The type of the link
      title: Link
    ClientSideAvailability:
      type: object
      properties:
        usingMobileKey:
          type: boolean
        usingEnvironmentId:
          type: boolean
      title: ClientSideAvailability
    ActionIdentifier:
      type: string
      title: ActionIdentifier
    ActionSpecifier:
      type: string
      title: ActionSpecifier
    AccessDeniedReasonEffect:
      type: string
      enum:
        - allow
        - deny
      description: Whether this statement should allow or deny actions on the resources.
      title: AccessDeniedReasonEffect
    AccessDeniedReason:
      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/AccessDeniedReasonEffect'
          description: >-
            Whether this statement should allow or deny actions on the
            resources.
        role_name:
          type: string
      required:
        - effect
      title: AccessDeniedReason
    AccessDenied:
      type: object
      properties:
        action:
          $ref: '#/components/schemas/ActionIdentifier'
        reason:
          $ref: '#/components/schemas/AccessDeniedReason'
      required:
        - action
        - reason
      title: AccessDenied
    AccessAllowedReasonEffect:
      type: string
      enum:
        - allow
        - deny
      description: Whether this statement should allow or deny actions on the resources.
      title: AccessAllowedReasonEffect
    AccessAllowedReason:
      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/AccessAllowedReasonEffect'
          description: >-
            Whether this statement should allow or deny actions on the
            resources.
        role_name:
          type: string
      required:
        - effect
      title: AccessAllowedReason
    AccessAllowedRep:
      type: object
      properties:
        action:
          $ref: '#/components/schemas/ActionIdentifier'
        reason:
          $ref: '#/components/schemas/AccessAllowedReason'
      required:
        - action
        - reason
      title: AccessAllowedRep
    Access:
      type: object
      properties:
        denied:
          type: array
          items:
            $ref: '#/components/schemas/AccessDenied'
        allowed:
          type: array
          items:
            $ref: '#/components/schemas/AccessAllowedRep'
      required:
        - denied
        - allowed
      title: Access
    ApprovalSettings:
      type: object
      properties:
        required:
          type: boolean
          description: If approvals are required for this environment
        bypassApprovalsForPendingChanges:
          type: boolean
          description: Whether to skip approvals for pending changes
        minNumApprovals:
          type: integer
          description: >-
            Sets the amount of approvals required before a member can apply a
            change. The minimum is one and the maximum is five.
        canReviewOwnRequest:
          type: boolean
          description: >-
            Allow someone who makes an approval request to apply their own
            change
        canApplyDeclinedChanges:
          type: boolean
          description: >-
            Allow applying the change as long as at least one person has
            approved
        autoApplyApprovedChanges:
          type: boolean
          description: >-
            Automatically apply changes that have been approved by all
            reviewers. This field is only applicable for approval services other
            than LaunchDarkly.
        serviceKind:
          type: string
          description: Which service to use for managing approvals
        serviceConfig:
          type: object
          additionalProperties:
            description: Any type
        requiredApprovalTags:
          type: array
          items:
            type: string
          description: >-
            Require approval only on flags with the provided tags. Otherwise all
            flags will require approval.
        serviceKindConfigurationId:
          type: string
          description: >-
            Optional field for integration configuration ID of a custom approval
            integration. This is an Enterprise-only feature.
      required:
        - required
        - bypassApprovalsForPendingChanges
        - minNumApprovals
        - canReviewOwnRequest
        - canApplyDeclinedChanges
        - serviceKind
        - serviceConfig
        - requiredApprovalTags
      title: ApprovalSettings
    Environment:
      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 ID for the environment. Use this as the client-side ID for
            authorization in some client-side SDKs, and to associate
            LaunchDarkly environments with CDN integrations in edge SDKs.
        key:
          type: string
          description: A project-unique key for the new environment
        name:
          type: string
          description: A human-friendly name for the new environment
        apiKey:
          type: string
          description: >-
            The SDK key for the environment. Use this for authorization in
            server-side SDKs.
        mobileKey:
          type: string
          description: >-
            The mobile key for the environment. Use this for authorization in
            mobile SDKs.
        color:
          type: string
          description: The color used to indicate this environment in the UI
        defaultTtl:
          type: integer
          description: >-
            The default time (in minutes) that the PHP SDK can cache feature
            flag rules locally
        secureMode:
          type: boolean
          description: >-
            Ensures that one end user of the client-side SDK cannot inspect the
            variations for another end user
        _access:
          $ref: '#/components/schemas/Access'
        defaultTrackEvents:
          type: boolean
          description: Enables tracking detailed information for new flags by default
        requireComments:
          type: boolean
          description: >-
            Whether members who modify flags and segments through the
            LaunchDarkly user interface are required to add a comment
        confirmChanges:
          type: boolean
          description: >-
            Whether members who modify flags and segments through the
            LaunchDarkly user interface are required to confirm those changes
        tags:
          type: array
          items:
            type: string
          description: A list of tags for this environment
        approvalSettings:
          $ref: '#/components/schemas/ApprovalSettings'
          description: Details about the approval settings for flags in this environment
        resourceApprovalSettings:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/ApprovalSettings'
          description: >-
            Details about the approval settings for other resources in this
            environment, organized by resource kind (for example, "aiconfig" and
            "segment")
        critical:
          type: boolean
          description: Whether the environment is critical
      required:
        - _links
        - _id
        - key
        - name
        - apiKey
        - mobileKey
        - color
        - defaultTtl
        - secureMode
        - defaultTrackEvents
        - requireComments
        - confirmChanges
        - tags
        - critical
      title: Environment
    Environments:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        totalCount:
          type: integer
          description: The number of environments returned
        items:
          type: array
          items:
            $ref: '#/components/schemas/Environment'
          description: An array of environments
      required:
        - items
      title: Environments
    Project:
      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 ID of this project
        key:
          type: string
          description: The key of this project
        includeInSnippetByDefault:
          type: boolean
          description: >-
            Whether or not flags created in this project are made available to
            the client-side JavaScript SDK by default
        defaultClientSideAvailability:
          $ref: '#/components/schemas/ClientSideAvailability'
          description: Describes which client-side SDKs can use new flags by default
        name:
          type: string
          description: A human-friendly name for the project
        _access:
          $ref: '#/components/schemas/Access'
          description: Details on the allowed and denied actions for this project
        tags:
          type: array
          items:
            type: string
          description: A list of tags for the project
        defaultReleasePipelineKey:
          type: string
          description: The key of the default release pipeline for this project
        environments:
          $ref: '#/components/schemas/Environments'
          description: >-
            A paginated list of environments for the project. By default this
            field is omitted unless expanded by the client.
      required:
        - _links
        - _id
        - key
        - includeInSnippetByDefault
        - name
        - tags
      title: Project
    Projects:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: A link to this resource.
        items:
          type: array
          items:
            $ref: '#/components/schemas/Project'
          description: List of projects.
        totalCount:
          type: integer
      required:
        - _links
        - items
      title: Projects
    InvalidRequestErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: InvalidRequestErrorRep
    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
    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/projects"

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

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

print(response.json())
```

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

	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/projects")

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

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

```csharp
using RestSharp;

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