# Get workflows

GET https://app.launchdarkly.com/api/v2/projects/{projectKey}/flags/{featureFlagKey}/environments/{environmentKey}/workflows

Display workflows associated with a feature flag.

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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/projects/{projectKey}/flags/{featureFlagKey}/environments/{environmentKey}/workflows:
    get:
      operationId: get-workflows
      summary: Get workflows
      description: Display workflows associated with a feature flag.
      tags:
        - subpackage_workflows
      parameters:
        - name: projectKey
          in: path
          description: The project key
          required: true
          schema:
            type: string
            format: string
        - name: featureFlagKey
          in: path
          description: The feature flag key
          required: true
          schema:
            type: string
            format: string
        - name: environmentKey
          in: path
          description: The environment key
          required: true
          schema:
            type: string
            format: string
        - name: status
          in: query
          description: >-
            Filter results by workflow status. Valid status filters are
            `active`, `completed`, and `failed`.
          required: false
          schema:
            type: string
            format: string
        - name: sort
          in: query
          description: >-
            A field to sort the items by. Prefix field by a dash ( - ) to sort
            in descending order. This endpoint supports sorting by
            `creationDate` or `stopDate`.
          required: false
          schema:
            type: string
            format: string
        - name: limit
          in: query
          description: The maximum number of workflows to return. Defaults to 20.
          required: false
          schema:
            type: integer
            format: int64
        - name: offset
          in: query
          description: >-
            Where to start in the list. Defaults to 0. Use this with pagination.
            For example, an offset of 10 skips the first ten items and then
            returns the next items in the list, up to the query `limit`.
          required: false
          schema:
            type: integer
            format: int64
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Workflows collection response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomWorkflowsListingOutput'
        '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:
    ConflictOutput:
      type: object
      properties:
        stageId:
          type: string
          description: The stage ID
        message:
          type: string
          description: Message about the conflict
      required:
        - stageId
        - message
      title: ConflictOutput
    UnixMillis:
      type: integer
      format: int64
      title: UnixMillis
    Link:
      type: object
      properties:
        href:
          type: string
          description: The URL of the link
        type:
          type: string
          description: The type of the link
      title: Link
    ExecutionOutput:
      type: object
      properties:
        status:
          type: string
          description: The status of the execution of this workflow stage
        stopDate:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the workflow was completed.
      required:
        - status
      title: ExecutionOutput
    ScheduleKind:
      type: string
      title: ScheduleKind
    DurationUnit:
      type: string
      title: DurationUnit
    ReviewOutput:
      type: object
      properties:
        _id:
          type: string
        kind:
          type: string
        creationDate:
          $ref: '#/components/schemas/UnixMillis'
        comment:
          type: string
        memberId:
          type: string
        serviceTokenId:
          type: string
      required:
        - _id
        - kind
      title: ReviewOutput
    FormVariableConfig:
      type: object
      additionalProperties:
        description: Any type
      title: FormVariableConfig
    ConditionOutput:
      type: object
      properties:
        _id:
          type: string
        kind:
          type: string
        _execution:
          $ref: '#/components/schemas/ExecutionOutput'
        scheduleKind:
          $ref: '#/components/schemas/ScheduleKind'
        executionDate:
          $ref: '#/components/schemas/UnixMillis'
        waitDuration:
          type: integer
        waitDurationUnit:
          $ref: '#/components/schemas/DurationUnit'
        description:
          type: string
        notifyMemberIds:
          type: array
          items:
            type: string
        allReviews:
          type: array
          items:
            $ref: '#/components/schemas/ReviewOutput'
        reviewStatus:
          type: string
        appliedDate:
          $ref: '#/components/schemas/UnixMillis'
        creationConfig:
          $ref: '#/components/schemas/FormVariableConfig'
      required:
        - _id
        - _execution
        - description
        - notifyMemberIds
        - allReviews
        - reviewStatus
      title: ConditionOutput
    Instruction:
      type: object
      additionalProperties:
        description: Any type
      title: Instruction
    Instructions:
      type: array
      items:
        $ref: '#/components/schemas/Instruction'
      title: Instructions
    ActionOutput:
      type: object
      properties:
        kind:
          type: string
          description: The type of action for this stage
        instructions:
          $ref: '#/components/schemas/Instructions'
          description: >-
            An array of instructions for the stage. Each object in the array
            uses the semantic patch format for updating a feature flag.
      required:
        - kind
        - instructions
      title: ActionOutput
    StageOutput:
      type: object
      properties:
        _id:
          type: string
          description: The ID of this stage
        name:
          type: string
          description: The stage name
        conditions:
          type: array
          items:
            $ref: '#/components/schemas/ConditionOutput'
          description: An array of conditions for the stage
        action:
          $ref: '#/components/schemas/ActionOutput'
          description: >-
            The type of instruction, and an array of instructions for the stage.
            Each object in the array uses the semantic patch format for updating
            a feature flag.
        _execution:
          $ref: '#/components/schemas/ExecutionOutput'
          description: Details on the execution of this stage
      required:
        - _id
        - conditions
        - action
        - _execution
      title: StageOutput
    ObjectId:
      type: string
      title: ObjectId
    RuleClauseOp:
      type: string
      enum:
        - in
        - endsWith
        - startsWith
        - matches
        - contains
        - lessThan
        - lessThanOrEqual
        - greaterThan
        - greaterThanOrEqual
        - before
        - after
        - segmentMatch
        - semVerEqual
        - semVerLessThan
        - semVerGreaterThan
      description: The operator to apply to the given attribute
      title: RuleClauseOp
    RuleClause:
      type: object
      properties:
        attribute:
          type: string
          description: >-
            The attribute the rule applies to, for example, last name or email
            address
        op:
          $ref: '#/components/schemas/RuleClauseOp'
          description: The operator to apply to the given attribute
        negate:
          type: boolean
          description: Whether the operator should be negated
      title: RuleClause
    ParameterDefault:
      type: object
      properties:
        value:
          description: The default value for the given parameter
        booleanVariationValue:
          type: boolean
          description: >-
            Variation value for boolean flags. Not applicable for non-boolean
            flags.
        ruleClause:
          $ref: '#/components/schemas/RuleClause'
          description: Metadata related to add rule instructions
      title: ParameterDefault
    WorkflowTemplateParameter:
      type: object
      properties:
        _id:
          $ref: '#/components/schemas/ObjectId'
          description: The ID of the condition or instruction referenced by this parameter
        path:
          type: string
          description: >-
            The path of the property to parameterize, relative to its parent
            condition or instruction
        default:
          $ref: '#/components/schemas/ParameterDefault'
          description: The default value of the parameter and other relevant metadata
        valid:
          type: boolean
          description: >-
            Whether the default value is valid for the target flag and
            environment
      title: WorkflowTemplateParameter
    WorkflowTemplateMetadata:
      type: object
      properties:
        parameters:
          type: array
          items:
            $ref: '#/components/schemas/WorkflowTemplateParameter'
      title: WorkflowTemplateMetadata
    CustomWorkflowOutput:
      type: object
      properties:
        _id:
          type: string
          description: The ID of the workflow
        _version:
          type: integer
          description: The version of the workflow
        _conflicts:
          type: array
          items:
            $ref: '#/components/schemas/ConflictOutput'
          description: Any conflicts that are present in the workflow stages
        _creationDate:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the workflow was created
        _maintainerId:
          type: string
          description: >-
            The member ID of the maintainer of the workflow. Defaults to the
            workflow creator.
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        name:
          type: string
          description: The name of the workflow
        description:
          type: string
          description: A brief description of the workflow
        kind:
          type: string
          description: The kind of workflow
        stages:
          type: array
          items:
            $ref: '#/components/schemas/StageOutput'
          description: >-
            The stages that make up the workflow. Each stage contains conditions
            and actions.
        _execution:
          $ref: '#/components/schemas/ExecutionOutput'
          description: The current execution status of the workflow
        meta:
          $ref: '#/components/schemas/WorkflowTemplateMetadata'
          description: >-
            For workflows being created from a workflow template, this value
            holds any parameters that could potentially be incompatible with the
            current project, environment, or flag
        templateKey:
          type: string
          description: >-
            For workflows being created from a workflow template, this value is
            the template's key
      required:
        - _id
        - _version
        - _conflicts
        - _creationDate
        - _maintainerId
        - _links
        - name
        - _execution
      title: CustomWorkflowOutput
    CustomWorkflowsListingOutput:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/CustomWorkflowOutput'
          description: An array of workflows
        totalCount:
          type: integer
          description: Total number of workflows
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
      required:
        - items
        - totalCount
        - _links
      title: CustomWorkflowsListingOutput
    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/projects/projectKey/flags/featureFlagKey/environments/environmentKey/workflows"

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

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

print(response.json())
```

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

	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/projectKey/flags/featureFlagKey/environments/environmentKey/workflows")

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/projectKey/flags/featureFlagKey/environments/environmentKey/workflows")
  .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/projectKey/flags/featureFlagKey/environments/environmentKey/workflows', [
  'headers' => [
    'Authorization' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

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