> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create workflow

> > For the complete documentation index, see [llms.txt](https://launchdarkly-preview.mintlify.app/llms.txt). For the full documentation snapshot, see [llms-full.txt](https://launchdarkly-preview.mintlify.app/llms-full.txt).

> ### Workflows are in maintenance mode
>
> The workflows feature is in maintenance mode, and is planned for future deprecation at a date not yet specified. We will work with existing customers using workflows to migrate to a replacement solution when deprecation occurs.

Create a workflow for a feature flag. You can create a workflow directly, or you can apply a template to create a new workflow.

### Creating a workflow

You can use the create workflow endpoint to create a workflow directly by adding a `stages` array to the request body.

For each stage, define the `name`, `conditions` when the stage should be executed, and `action` that describes the stage. For approval stages, only standard LaunchDarkly approvals are permitted. Workflows of `kind` `integration-approval` cannot be used for custom workflows. 

<details>
<summary>Click to expand example</summary>

_Example request body_
```json
{
  "name": "Progressive rollout starting in two days",
  "description": "Turn flag targeting on and increase feature rollout in 10% increments each day",
  "stages": [
    {
      "name": "10% rollout on day 1",
      "conditions": [
        {
          "kind": "schedule",
          "scheduleKind": "relative", // or "absolute"
              //  If "scheduleKind" is "absolute", set "executionDate";
              // "waitDuration" and "waitDurationUnit" will be ignored
          "waitDuration": 2,
          "waitDurationUnit": "calendarDay"
        },
        {
          "kind": "ld-approval",
          "notifyMemberIds": [ "507f1f77bcf86cd799439011" ],
          "notifyTeamKeys": [ "team-key-123abc" ]
        }
      ],
      "action": {
        "instructions": [
          {
            "kind": "turnFlagOn"
          },
          {
            "kind": "updateFallthroughVariationOrRollout",
            "rolloutWeights": {
              "452f5fb5-7320-4ba3-81a1-8f4324f79d49": 90000,
              "fc15f6a4-05d3-4aa4-a997-446be461345d": 10000
            }
          }
        ]
      }
    }
  ]
}
```
</details>

### Creating a workflow by applying a workflow template

You can also create a workflow by applying a workflow template. If you pass a valid workflow template key as the `templateKey` query parameter with the request, the API will attempt to create a new workflow with the stages defined in the workflow template with the corresponding key.

#### Applicability of stages
Templates are created in the context of a particular flag in a particular environment in a particular project. However, because workflows created from a template can be applied to any project, environment, and flag, some steps of the workflow may need to be updated in order to be applicable for the target resource.

You can pass a `dryRun` query parameter to tell the API to return a report of which steps of the workflow template are applicable in the target project/environment/flag, and which will need to be updated. When the `dryRun` query parameter is present the response body includes a `meta` property that holds a list of parameters that could potentially be inapplicable for the target resource. Each of these parameters will include a `valid` field. You will need to update any invalid parameters in order to create the new workflow. You can do this using the `parameters` property, which overrides the workflow template parameters.

#### Overriding template parameters
You can use the `parameters` property in the request body to tell the API to override the specified workflow template parameters with new values that are specific to your target project/environment/flag.

<details>
<summary>Click to expand example</summary>

_Example request body_
```json
{
	"name": "workflow created from my-template",
	"description": "description of my workflow",
	"parameters": [
		{
			"_id": "62cf2bc4cadbeb7697943f3b",
			"path": "/clauses/0/values",
			"default": {
				"value": ["updated-segment"]
			}
		},
		{
			"_id": "62cf2bc4cadbeb7697943f3d",
			"path": "/variationId",
			"default": {
				"value": "abcd1234-abcd-1234-abcd-1234abcd12"
			}
		}
	]
}
```
</details>

If there are any steps in the template that are not applicable to the target resource, the workflow will not be created, and the `meta` property will be included in the response body detailing which parameters need to be updated.




## OpenAPI

````yaml /openapi/launchdarkly-api.json post /api/v2/projects/{projectKey}/flags/{featureFlagKey}/environments/{environmentKey}/workflows
openapi: 3.0.3
info:
  title: LaunchDarkly REST API
  description: >
    > For the complete documentation index, see
    https://launchdarkly-preview.mintlify.app/llms.txt.

    > For the full documentation snapshot, see
    https://launchdarkly-preview.mintlify.app/llms-full.txt.


    This is the LaunchDarkly REST API. It lets you build custom integrations,
    automate your workflow, and manage feature flags and other LaunchDarkly
    resources programmatically.


    For authentication, rate limits, pagination, versioning, JSON Patch and
    semantic patches, beta resources, and the full SDK End-of-Life table, read
    the [REST API overview](https://launchdarkly-preview.mintlify.app/api).


    To fetch the complete OpenAPI spec, use [Get OpenAPI
    spec](https://launchdarkly.com/docs/api/other/get-openapi-spec).
  contact:
    name: LaunchDarkly Technical Support Team
    url: https://support.launchdarkly.com
    email: support@launchdarkly.com
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: '2.0'
servers:
  - url: https://app.launchdarkly.com
    description: ' Default'
  - url: https://app.launchdarkly.us
    description: ' Federal'
security:
  - ApiKey:
      - read
      - write
tags:
  - name: Access tokens
    description: >-
      The access tokens API allows you to list, create, modify, and delete
      access tokens programmatically.
  - name: Account members
    description: >-
      The account members API allows you to invite new members to an account by
      making a `POST` request to `/api/v2/members`. When you invite a new member
      to an account, an invitation is sent to the email you provided.
  - name: Account usage (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: AI Configs
    description: >-
      The AI Configs API allows you to create, retrieve, and edit AI Configs, AI
      Config variations, and AI model configurations.
  - name: Announcements
    description: >-
      The announcements API lets you create and update a custom announcement
      banner that appears in the LaunchDarkly user interface for everyone in
      your organization.
  - name: Applications (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Approvals
    description: >-
      An account member can request approval on changes to a flag or AI Config's
      targeting or variations, or to a segment's targeting. Members may be
      required to request approval depending on the settings in their
      LaunchDarkly project.
  - name: Approvals (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Audit log
    description: >-
      LaunchDarkly maintains a record of all the changes made to any resource in
      the system. You can access this history using the audit log API, including
      filtering by timestamps, or using a custom policy to select which entries
      to receive.
  - name: Code references
    description: >-
      > ### Code references is an Enterprise feature > > Code references is
      available to customers on an Enterprise plan. To learn more, [read about
      our pricing](https://launchdarkly.com/pricing/).
  - name: Context settings
    description: >-
      You can use the context settings API to assign a context to a specific
      variation for any feature flag. To learn more, read [View and manage
      contexts](https://launchdarkly.com/docs/home/observability/context-attributes#view-and-manage-contexts).
  - name: Contexts
    description: >-
      Contexts are people, services, machines, or other resources that encounter
      feature flags in your product. Contexts are identified by their `kind`,
      which describes the type of resources encountering flags, and by their
      `key`.
  - name: Custom roles
    description: >-
      > ### Custom roles is an Enterprise feature > > Custom roles is available
      to customers on an Enterprise plan. To learn more, [read about our
      pricing](https://launchdarkly.com/pricing/).
  - name: Data Export destinations
    description: >-
      > ### Data Export is an add-on feature > > Data Export is available as an
      add-on for customers on a Foundation or Enterprise plan. To learn more,
      [read about our pricing](https://launchdarkly.com/pricing/).
  - name: Environments
    description: >-
      Environments allow you to maintain separate rollout rules in different
      contexts, from local development to QA, staging, and production. With the
      LaunchDarkly Environments API, you can programmatically list, create, and
      manage environments.
  - name: Experiments
    description: >-
      > ### Available for subscription customers > > Experimentation is
      available to all customers on a Developer, Foundation, or Enterprise
      subscription. If you're on an older Pro or Enterprise plan,
      Experimentation is available as an add-on.
  - name: Feature flags
    description: >-
      The feature flags API allows you to list, create, and modify feature flags
      and their targeting. For example, you can control percentage rollouts,
      target specific contexts, or even toggle off a feature flag
      programmatically.
  - name: Feature flags (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Flag import configurations (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Flag links (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Flag triggers
    description: >-
      > ### Flag triggers is an Enterprise feature > > Flag triggers is
      available to customers on an Enterprise plan. To learn more, [read about
      our pricing](https://launchdarkly.com/pricing/).
  - name: Follow flags
    description: >-
      Follow flags to receive email updates about targeting changes to a flag in
      a project and environment.
  - name: Holdouts (beta)
    description: >-
      > ### Available for customers using Experimentation > > Holdouts are
      available to customers using
      [Experimentation](https://launchdarkly.com/docs/api/experiments).
  - name: Insights charts (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Insights deployments (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Insights flag events (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Insights pull requests (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Insights repositories (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Insights scores (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Integration audit log subscriptions
    description: >-
      Audit log integration subscriptions allow you to send audit log events
      hooks to one of dozens of external tools. For example, you can send flag
      change event webhooks to external third party software.
  - name: Integration delivery configurations (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Integrations (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Layers
    description: >-
      > ### Available for customers using Experimentation > > Layers are
      available to customers using
      [Experimentation](https://launchdarkly.com/docs/api/experiments).
  - name: Metrics
    description: >-
      Metrics track flag behavior over time when an experiment is running. The
      data generated from experiments gives you more insight into the impact of
      a particular flag.
  - name: Metrics (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: OAuth2 Clients
    description: >-
      The OAuth2 client API allows you to register a LaunchDarkly OAuth client
      for use in your own custom integrations.
  - name: Persistent store integrations (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Projects
    description: >-
      Projects allow you to manage multiple different software projects under
      one LaunchDarkly account. Each project has its own unique set of
      environments and feature flags.
  - name: Relay Proxy configurations
    description: >-
      > ### Relay Proxy automatic configuration is an Enterprise feature > >
      Relay Proxy automatic configuration is available to customers on an
      Enterprise plan. To learn more, [read about our
      pricing](https://launchdarkly.com/pricing/).
  - name: Release pipelines (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Release policies (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Releases (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Scheduled changes
    description: >-
      > ### Scheduled flag changes is an Enterprise feature > > Scheduled flag
      changes is available to customers on an Enterprise plan. To learn more,
      [read about our pricing](https://launchdarkly.com/pricing/).
  - name: Segments
    description: >-
      > ### Synced segments and larger list-based segments are an Enterprise
      feature > > This section documents endpoints for rule-based, list-based,
      and synced segments.
  - name: Tags
    description: >-
      Tags are simple strings that you can attach to most resources in
      LaunchDarkly. Tags are useful for grouping resources into a set that you
      can name in a resource specifier.
  - name: Teams
    description: >-
      > ### Teams is an Enterprise feature > > Teams is available to customers
      on an Enterprise plan. To learn more, [read about our
      pricing](https://launchdarkly.com/pricing/).
  - name: Teams (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: User settings
    description: >-
      > ### Contexts are now available > > After you have upgraded your
      LaunchDarkly SDK to use contexts instead of users, you should use
      [Contexts](https://launchdarkly.com/docs/api/contexts) instead of the user
      settings API.
  - name: Users
    description: >-
      > ### Contexts are now available > > After you have upgraded your
      LaunchDarkly SDK to use contexts instead of users, you should use
      [Contexts](https://launchdarkly.com/docs/api/contexts) instead of these
      endpoints.
  - name: Users (beta)
    description: >-
      > ### Contexts are now available > > After you have upgraded your
      LaunchDarkly SDK to use contexts instead of users, you should use
      [Contexts](https://launchdarkly.com/docs/api/contexts) instead of these
      endpoints.
  - name: Views (beta)
    description: >-
      > ### This feature is in beta > > To use this feature, pass in a header
      including the `LD-API-Version` key with value set to `beta`. Use this
      header with each call.
  - name: Webhooks
    description: >-
      The webhooks API lets you build your own integrations that subscribe to
      activities in LaunchDarkly. When you generate an activity in LaunchDarkly,
      such as when you change a flag or you create a project, LaunchDarkly sends
      an HTTP POST payload to the...
  - name: Workflow templates
    description: >-
      > ### Workflows are in maintenance mode > > The workflows feature is in
      maintenance mode, and is planned for future deprecation at a date not yet
      specified.
  - name: Workflows
    description: >-
      > ### Workflows are in maintenance mode > > The workflows feature is in
      maintenance mode, and is planned for future deprecation at a date not yet
      specified.
  - name: Other
    description: Other requests available in the LaunchDarkly API.
paths:
  /api/v2/projects/{projectKey}/flags/{featureFlagKey}/environments/{environmentKey}/workflows:
    post:
      tags:
        - Workflows
      summary: Create workflow
      description: "> For the complete documentation index, see [llms.txt](https://launchdarkly-preview.mintlify.app/llms.txt). For the full documentation snapshot, see [llms-full.txt](https://launchdarkly-preview.mintlify.app/llms-full.txt).\n\n> ### Workflows are in maintenance mode\n>\n> The workflows feature is in maintenance mode, and is planned for future deprecation at a date not yet specified. We will work with existing customers using workflows to migrate to a replacement solution when deprecation occurs.\n\nCreate a workflow for a feature flag. You can create a workflow directly, or you can apply a template to create a new workflow.\n\n### Creating a workflow\n\nYou can use the create workflow endpoint to create a workflow directly by adding a `stages` array to the request body.\n\nFor each stage, define the `name`, `conditions` when the stage should be executed, and `action` that describes the stage. For approval stages, only standard LaunchDarkly approvals are permitted. Workflows of `kind` `integration-approval` cannot be used for custom workflows. \n\n<details>\n<summary>Click to expand example</summary>\n\n_Example request body_\n```json\n{\n  \"name\": \"Progressive rollout starting in two days\",\n  \"description\": \"Turn flag targeting on and increase feature rollout in 10% increments each day\",\n  \"stages\": [\n    {\n      \"name\": \"10% rollout on day 1\",\n      \"conditions\": [\n        {\n          \"kind\": \"schedule\",\n          \"scheduleKind\": \"relative\", // or \"absolute\"\n              //  If \"scheduleKind\" is \"absolute\", set \"executionDate\";\n              // \"waitDuration\" and \"waitDurationUnit\" will be ignored\n          \"waitDuration\": 2,\n          \"waitDurationUnit\": \"calendarDay\"\n        },\n        {\n          \"kind\": \"ld-approval\",\n          \"notifyMemberIds\": [ \"507f1f77bcf86cd799439011\" ],\n          \"notifyTeamKeys\": [ \"team-key-123abc\" ]\n        }\n      ],\n      \"action\": {\n        \"instructions\": [\n          {\n            \"kind\": \"turnFlagOn\"\n          },\n          {\n            \"kind\": \"updateFallthroughVariationOrRollout\",\n            \"rolloutWeights\": {\n              \"452f5fb5-7320-4ba3-81a1-8f4324f79d49\": 90000,\n              \"fc15f6a4-05d3-4aa4-a997-446be461345d\": 10000\n            }\n          }\n        ]\n      }\n    }\n  ]\n}\n```\n</details>\n\n### Creating a workflow by applying a workflow template\n\nYou can also create a workflow by applying a workflow template. If you pass a valid workflow template key as the `templateKey` query parameter with the request, the API will attempt to create a new workflow with the stages defined in the workflow template with the corresponding key.\n\n#### Applicability of stages\nTemplates are created in the context of a particular flag in a particular environment in a particular project. However, because workflows created from a template can be applied to any project, environment, and flag, some steps of the workflow may need to be updated in order to be applicable for the target resource.\n\nYou can pass a `dryRun` query parameter to tell the API to return a report of which steps of the workflow template are applicable in the target project/environment/flag, and which will need to be updated. When the `dryRun` query parameter is present the response body includes a `meta` property that holds a list of parameters that could potentially be inapplicable for the target resource. Each of these parameters will include a `valid` field. You will need to update any invalid parameters in order to create the new workflow. You can do this using the `parameters` property, which overrides the workflow template parameters.\n\n#### Overriding template parameters\nYou can use the `parameters` property in the request body to tell the API to override the specified workflow template parameters with new values that are specific to your target project/environment/flag.\n\n<details>\n<summary>Click to expand example</summary>\n\n_Example request body_\n```json\n{\n\t\"name\": \"workflow created from my-template\",\n\t\"description\": \"description of my workflow\",\n\t\"parameters\": [\n\t\t{\n\t\t\t\"_id\": \"62cf2bc4cadbeb7697943f3b\",\n\t\t\t\"path\": \"/clauses/0/values\",\n\t\t\t\"default\": {\n\t\t\t\t\"value\": [\"updated-segment\"]\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"_id\": \"62cf2bc4cadbeb7697943f3d\",\n\t\t\t\"path\": \"/variationId\",\n\t\t\t\"default\": {\n\t\t\t\t\"value\": \"abcd1234-abcd-1234-abcd-1234abcd12\"\n\t\t\t}\n\t\t}\n\t]\n}\n```\n</details>\n\nIf there are any steps in the template that are not applicable to the target resource, the workflow will not be created, and the `meta` property will be included in the response body detailing which parameters need to be updated.\n"
      operationId: postWorkflow
      parameters:
        - name: templateKey
          in: query
          description: The template key to apply as a starting point for the new workflow
          schema:
            type: string
            format: string
            description: The template key to apply as a starting point for the new workflow
        - name: dryRun
          in: query
          description: Whether to call the endpoint in dry-run mode
          schema:
            type: boolean
            description: Whether to call the endpoint in dry-run mode
        - name: projectKey
          in: path
          description: The project key
          required: true
          schema:
            type: string
            format: string
            description: The project key
        - name: featureFlagKey
          in: path
          description: The feature flag key
          required: true
          schema:
            type: string
            format: string
            description: The feature flag key
        - name: environmentKey
          in: path
          description: The environment key
          required: true
          schema:
            type: string
            format: string
            description: The environment key
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomWorkflowInput'
            example:
              description: Turn flag on for 10% of customers each day
              name: Progressive rollout starting in two days
              stages:
                - action:
                    instructions:
                      - kind: turnFlagOn
                      - kind: updateFallthroughVariationOrRollout
                        rolloutWeights:
                          452f5fb5-7320-4ba3-81a1-8f4324f79d49: 90000
                          fc15f6a4-05d3-4aa4-a997-446be461345d: 10000
                  conditions:
                    - kind: schedule
                      scheduleKind: relative
                      waitDuration: 2
                      waitDurationUnit: calendarDay
                  name: 10% rollout on day 1
        required: true
      responses:
        '201':
          description: Workflow response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomWorkflowOutput'
        '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'
        '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'
components:
  schemas:
    CustomWorkflowInput:
      type: object
      required:
        - name
      properties:
        maintainerId:
          $ref: '#/components/schemas/ObjectId'
          description: The ID of the workflow maintainer. Defaults to the workflow creator.
          example: 12ab3c45de678910abc12345
        name:
          type: string
          description: The workflow name
          example: Progressive rollout starting in two days
        description:
          type: string
          description: The workflow description
          example: Turn flag on for 10% of users each day
        stages:
          type: array
          description: A list of the workflow stages
          items:
            $ref: '#/components/schemas/StageInput'
        templateKey:
          type: string
          description: The template key
    CustomWorkflowOutput:
      type: object
      required:
        - _id
        - _version
        - _conflicts
        - _creationDate
        - _maintainerId
        - _links
        - name
        - _execution
      properties:
        _id:
          type: string
          description: The ID of the workflow
          example: 12ab3c4d5ef1a2345bcde67f
        _version:
          type: integer
          description: The version of the workflow
          example: 1
        _conflicts:
          type: array
          description: Any conflicts that are present in the workflow stages
          items:
            $ref: '#/components/schemas/ConflictOutput'
        _creationDate:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the workflow was created
          example: '1654104600000'
        _maintainerId:
          type: string
          description: >-
            The member ID of the maintainer of the workflow. Defaults to the
            workflow creator.
          example: 12ab3c45de678910abc12345
        _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
          example: Progressive rollout starting in two days
        description:
          type: string
          description: A brief description of the workflow
          example: Turn flag on for 10% of customers each day
        kind:
          type: string
          description: The kind of workflow
          example: custom
        stages:
          type: array
          description: >-
            The stages that make up the workflow. Each stage contains conditions
            and actions.
          items:
            $ref: '#/components/schemas/StageOutput'
        _execution:
          $ref: '#/components/schemas/ExecutionOutput'
          description: The current execution status of the workflow
          example: '{"status": "completed"}'
        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
          example: example-workflow-template
    InvalidRequestErrorRep:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Specific error code encountered
          example: invalid_request
        message:
          type: string
          description: Description of the error
          example: Invalid request body
    UnauthorizedErrorRep:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Specific error code encountered
          example: unauthorized
        message:
          type: string
          description: Description of the error
          example: Invalid access token
    ForbiddenErrorRep:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Specific error code encountered
          example: forbidden
        message:
          type: string
          description: Description of the error
          example: Forbidden. Access to the requested resource was denied.
    NotFoundErrorRep:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Specific error code encountered
          example: not_found
        message:
          type: string
          description: Description of the error
          example: Invalid resource identifier
    RateLimitedErrorRep:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Specific error code encountered
          example: rate_limited
        message:
          type: string
          description: Description of the error
          example: You've exceeded the API rate limit. Try again later.
    ObjectId:
      type: string
    StageInput:
      type: object
      properties:
        name:
          type: string
          description: The stage name
          example: 10% rollout on day 1
        executeConditionsInSequence:
          type: boolean
          description: Whether to execute the conditions in sequence for the given stage
          example: true
        conditions:
          type: array
          description: An array of conditions for the stage
          items:
            $ref: '#/components/schemas/ConditionInput'
          example:
            - kind: schedule
              scheduleKind: relative
              waitDuration: 2
              waitDurationUnit: calendarDay
        action:
          $ref: '#/components/schemas/ActionInput'
          description: >-
            An <code>instructions</code> field containing an array of
            instructions for the stage. Each object in the array uses the
            semantic patch format for updating a feature flag.
          example: '{"instructions": [{ "kind": "turnFlagOn"}]}'
    ConflictOutput:
      type: object
      required:
        - stageId
        - message
      properties:
        stageId:
          type: string
          description: The stage ID
          example: 12ab3c4d5ef1a2345bcde67f
        message:
          type: string
          description: Message about the conflict
    UnixMillis:
      type: integer
      format: int64
    Link:
      type: object
      properties:
        href:
          type: string
        type:
          type: string
    StageOutput:
      type: object
      required:
        - _id
        - conditions
        - action
        - _execution
      properties:
        _id:
          type: string
          description: The ID of this stage
          example: 12ab3c45de678910abc12345
        name:
          type: string
          description: The stage name
          example: 10% rollout on day 1
        conditions:
          type: array
          description: An array of conditions for the stage
          items:
            $ref: '#/components/schemas/ConditionOutput'
          example:
            - _execution:
                status: completed
              id: 12ab3c45de678910abc12345
              kind: schedule
              scheduleKind: relative
              waitDuration: 2
              waitDurationUnit: calendarDay
        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.
          example: '{ "kind": "patch", "instructions": [{ "kind": "turnFlagOn"}] }'
        _execution:
          $ref: '#/components/schemas/ExecutionOutput'
          description: Details on the execution of this stage
          example: '{ "status": "completed" }'
    ExecutionOutput:
      type: object
      required:
        - status
      properties:
        status:
          type: string
          description: The status of the execution of this workflow stage
          example: completed
        stopDate:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the workflow was completed.
          example: '1718467200000'
    WorkflowTemplateMetadata:
      type: object
      properties:
        parameters:
          type: array
          items:
            $ref: '#/components/schemas/WorkflowTemplateParameter'
    ConditionInput:
      type: object
      properties:
        scheduleKind:
          $ref: '#/components/schemas/ScheduleKind'
          description: >-
            Whether the scheduled execution of the workflow stage is relative or
            absolute. If relative, the <code>waitDuration</code> and
            <code>waitDurationUnit</code> specify when the execution occurs. If
            absolute, the <code>executionDate</code> specifies when the
            execution occurs.
          example: relative
          enum:
            - absolute
            - relative
        executionDate:
          $ref: '#/components/schemas/UnixMillis'
          description: >-
            For workflow stages whose scheduled execution is absolute, the time,
            in Unix milliseconds, when the stage should start.
          example: '1706810400000'
        waitDuration:
          type: integer
          description: >-
            For workflow stages whose scheduled execution is relative, how far
            in the future the stage should start.
          example: 2
        waitDurationUnit:
          $ref: '#/components/schemas/DurationUnit'
          description: >-
            For workflow stages whose scheduled execution is relative, the unit
            of measure for the <code>waitDuration</code>.
          example: calendarDay
          enum:
            - minute
            - hour
            - calendarDay
            - calendarWeek
        executeNow:
          type: boolean
          description: Whether the workflow stage should be executed immediately
          example: false
        description:
          type: string
          description: A description of the approval required for this stage
          example: Require example-team approval for final stage
        notifyMemberIds:
          type: array
          description: >-
            A list of member IDs for the members to request approval from for
            this stage
          items:
            type: string
          example:
            - 507f1f77bcf86cd799439011
        notifyTeamKeys:
          type: array
          description: >-
            A list of team keys for the teams to request approval from for this
            stage
          items:
            type: string
          example:
            - example-team
        integrationConfig:
          $ref: '#/components/schemas/FormVariableConfig'
          description: >-
            Additional approval request fields for third-party integration
            approval systems. If you are using a third-party integration to
            manage approval requests, these additional fields will be described
            in the <code>manifest.json</code> for that integration, at
            https://github.com/launchdarkly/integration-framework.
        kind:
          $ref: '#/components/schemas/ConditionKind'
          description: >-
            The type of condition to meet before executing this stage of the
            workflow. Use <code>schedule</code> to schedule a workflow stage.
            Use <code>ld-approval</code> to add an approval request to a
            workflow stage.
          example: schedule
    ActionInput:
      type: object
      properties:
        instructions:
          description: >-
            An array of instructions for the stage. Each object in the array
            uses the semantic patch format for updating a feature flag.
          example: '{"instructions": [{ "kind": "turnFlagOn"}]}'
    ConditionOutput:
      type: object
      required:
        - _id
        - _execution
        - description
        - notifyMemberIds
        - allReviews
        - reviewStatus
      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'
    ActionOutput:
      type: object
      required:
        - kind
        - instructions
      properties:
        kind:
          type: string
          description: The type of action for this stage
          example: patch
        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.
          example: '[{"kind": "turnFlagOn"}]'
    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
    ScheduleKind:
      type: string
    DurationUnit:
      type: string
    FormVariableConfig:
      type: object
      additionalProperties: {}
    ConditionKind:
      type: string
    ReviewOutput:
      type: object
      required:
        - _id
        - kind
      properties:
        _id:
          type: string
        kind:
          type: string
        creationDate:
          $ref: '#/components/schemas/UnixMillis'
        comment:
          type: string
        memberId:
          type: string
        serviceTokenId:
          type: string
    Instructions:
      type: array
      items:
        $ref: '#/components/schemas/Instruction'
    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
    Instruction:
      type: object
      additionalProperties: {}
    RuleClause:
      type: object
      properties:
        attribute:
          type: string
          description: >-
            The attribute the rule applies to, for example, last name or email
            address
        op:
          type: string
          description: The operator to apply to the given attribute
          enum:
            - in
            - endsWith
            - startsWith
            - matches
            - contains
            - lessThan
            - lessThanOrEqual
            - greaterThan
            - greaterThanOrEqual
            - before
            - after
            - segmentMatch
            - semVerEqual
            - semVerLessThan
            - semVerGreaterThan
        negate:
          type: boolean
          description: Whether the operator should be negated
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

````