For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inTry it free
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
  • REST API overview
    • Access Tokens
    • Account Members
    • Account Usage Beta
    • AI Configs
    • Announcements
    • Applications Beta
    • Approvals
    • Approvals Beta
    • Audit Log
    • Code References
    • Contexts
    • Context Settings
    • Custom Roles
    • Data Export Destinations
    • Environments
    • Experiments
    • Feature Flags
    • Feature Flags Beta
    • Flag Import Configurations Beta
    • Flag Links Beta
    • Flag Triggers
    • Follow Flags
    • Holdouts Beta
    • Insights Charts Beta
    • Insights Deployments Beta
    • Insights Flag Events Beta
    • Insights Pull Requests Beta
    • Insights Repositories Beta
    • Insights Scores Beta
    • Integration Audit Log Subscriptions
    • Integration Delivery Configurations Beta
    • Integrations Beta
    • Layers
    • Metrics
    • Metrics Beta
    • OAuth2 Clients
    • Persistent Store Integrations Beta
    • Projects
    • Relay Proxy Configurations
    • Release Pipelines Beta
    • Releases Beta
    • Scheduled Changes
    • Segments
    • Tags
    • Teams
    • Teams Beta
    • Users
    • Users Beta
    • User Settings
    • Views Beta
    • Webhooks
    • Workflows
      • POSTCreate workflow
      • DELDelete workflow
      • GETGet custom workflow
      • GETGet workflows
    • Workflow Templates
    • Other
Sign inTry it free
LogoLogo
REST API overviewWorkflows

Create workflow

POST
/api/v2/projects/:projectKey/flags/:featureFlagKey/environments/:environmentKey/workflows
POST
/api/v2/projects/:projectKey/flags/:featureFlagKey/environments/:environmentKey/workflows
$curl -X POST https://app.launchdarkly.com/api/v2/projects/projectKey/flags/featureFlagKey/environments/environmentKey/workflows \
> -H "Authorization: <apiKey>" \
> -H "Content-Type: application/json" \
> -d '{
> "name": "Progressive rollout starting in two days",
> "description": "Turn flag on for 10% of customers each day",
> "stages": [
> {
> "name": "10% rollout on day 1",
> "conditions": [
> {
> "scheduleKind": "relative",
> "waitDuration": 2,
> "waitDurationUnit": "calendarDay",
> "kind": "schedule"
> }
> ],
> "action": {
> "instructions": null
> }
> }
> ]
>}'
1{
2 "_id": "12ab3c4d5ef1a2345bcde67f",
3 "_version": 1,
4 "_conflicts": [
5 {
6 "stageId": "12ab3c4d5ef1a2345bcde67f",
7 "message": "string"
8 }
9 ],
10 "_creationDate": 1654104600000,
11 "_maintainerId": "12ab3c45de678910abc12345",
12 "_links": {},
13 "name": "Progressive rollout starting in two days",
14 "_execution": {
15 "status": "completed"
16 },
17 "description": "Turn flag on for 10% of customers each day",
18 "kind": "custom",
19 "stages": [
20 {
21 "_id": "12ab3c45de678910abc12345",
22 "conditions": [
23 {
24 "_id": "string",
25 "_execution": {
26 "status": "completed"
27 },
28 "description": "string",
29 "notifyMemberIds": [
30 "string"
31 ],
32 "allReviews": [
33 {
34 "_id": "string",
35 "kind": "string",
36 "creationDate": 1,
37 "comment": "string",
38 "memberId": "string",
39 "serviceTokenId": "string"
40 }
41 ],
42 "reviewStatus": "string",
43 "kind": "schedule",
44 "scheduleKind": "relative",
45 "waitDuration": 2,
46 "waitDurationUnit": "calendarDay",
47 "id": "12ab3c45de678910abc12345"
48 }
49 ],
50 "action": {
51 "kind": "patch",
52 "instructions": [
53 "[{\"kind\": \"turnFlagOn\"}]"
54 ]
55 },
56 "_execution": {
57 "status": "completed"
58 },
59 "name": "10% rollout on day 1"
60 }
61 ],
62 "meta": {
63 "parameters": [
64 {
65 "_id": "string",
66 "path": "string",
67 "default": {
68 "value": null,
69 "booleanVariationValue": true,
70 "ruleClause": {
71 "attribute": "string",
72 "op": "in",
73 "negate": true
74 }
75 },
76 "valid": true
77 }
78 ]
79 },
80 "templateKey": "example-workflow-template"
81}
> ### 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.
Was this page helpful?
Previous

Delete workflow

Next
Built with

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.

Click to expand example

Example request body

1{
2 "name": "Progressive rollout starting in two days",
3 "description": "Turn flag targeting on and increase feature rollout in 10% increments each day",
4 "stages": [
5 {
6 "name": "10% rollout on day 1",
7 "conditions": [
8 {
9 "kind": "schedule",
10 "scheduleKind": "relative", // or "absolute"
11 // If "scheduleKind" is "absolute", set "executionDate";
12 // "waitDuration" and "waitDurationUnit" will be ignored
13 "waitDuration": 2,
14 "waitDurationUnit": "calendarDay"
15 },
16 {
17 "kind": "ld-approval",
18 "notifyMemberIds": [ "507f1f77bcf86cd799439011" ],
19 "notifyTeamKeys": [ "team-key-123abc" ]
20 }
21 ],
22 "action": {
23 "instructions": [
24 {
25 "kind": "turnFlagOn"
26 },
27 {
28 "kind": "updateFallthroughVariationOrRollout",
29 "rolloutWeights": {
30 "452f5fb5-7320-4ba3-81a1-8f4324f79d49": 90000,
31 "fc15f6a4-05d3-4aa4-a997-446be461345d": 10000
32 }
33 }
34 ]
35 }
36 }
37 ]
38}

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.

Click to expand example

Example request body

1{
2 "name": "workflow created from my-template",
3 "description": "description of my workflow",
4 "parameters": [
5 {
6 "_id": "62cf2bc4cadbeb7697943f3b",
7 "path": "/clauses/0/values",
8 "default": {
9 "value": ["updated-segment"]
10 }
11 },
12 {
13 "_id": "62cf2bc4cadbeb7697943f3d",
14 "path": "/variationId",
15 "default": {
16 "value": "abcd1234-abcd-1234-abcd-1234abcd12"
17 }
18 }
19 ]
20}

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.

Authentication

Authorizationstring
API Key authentication via header

Path parameters

projectKeystringRequiredformat: "string"
The project key
featureFlagKeystringRequiredformat: "string"
The feature flag key
environmentKeystringRequiredformat: "string"
The environment key

Query parameters

templateKeystringOptionalformat: "string"
The template key to apply as a starting point for the new workflow
dryRunbooleanOptional

Whether to call the endpoint in dry-run mode

Request

This endpoint expects an object.
namestringRequired
The workflow name
maintainerIdstringOptional
The ID of the workflow maintainer. Defaults to the workflow creator.
descriptionstringOptional
The workflow description
stageslist of objectsOptional
A list of the workflow stages
templateKeystringOptional
The template key

Response

Workflow response
_idstring
The ID of the workflow
_versioninteger
The version of the workflow
_conflictslist of objects
Any conflicts that are present in the workflow stages
_creationDatelong
Timestamp of when the workflow was created
_maintainerIdstring
The member ID of the maintainer of the workflow. Defaults to the workflow creator.
_linksmap from strings to objects
The location and content type of related resources
namestring
The name of the workflow
_executionobject
The current execution status of the workflow
descriptionstring
A brief description of the workflow
kindstring
The kind of workflow
stageslist of objects
The stages that make up the workflow. Each stage contains conditions and actions.
metaobject
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
templateKeystring
For workflows being created from a workflow template, this value is the template's key

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
429
Too Many Requests Error