# Duplicate Workflow Step

Copy a step and every step inside it, with their connections: each must be one the key's creator may use. meta.newStepIds lists all the copies; data is the copy of the step itself. Send the revision you last read in If-Match; the response's meta.revision is the new one.

`POST https://connect.mindcloud.co/v2/workflows/:workflowId/steps/:stepId/duplicate`

Permissions: `workflow:edit`.

## Parameters

### Path

- `workflowId` (string, required): The workflow's id.
- `stepId` (string, required): The step's id, from List Workflow Steps.

### Headers

- `If-Match` (string, required): Required. The revision you last read: the `revision` from its read (Get Workflow Definition for a workflow, Get Analytics Page Definition for an Analytics page, Get Analytics Data Source Table for a fixed source's table), or `meta.revision` from your last change to it. The `ETag` header of either answer is the same value, ready to send back. The change applies only if nobody changed it since: otherwise it answers 412 with the current revision in `error.details.revision`. Send it as a strong entity tag (`"r_..."`): a weak one (`W/"..."`) never matches and answers 412. Without it the request answers 428.
- `X-Company-Id` (string): Optional. The id of the organization to act in. Leave it out to act in the API key's own organization. A key can also act in its child organizations, and, with "Use this key across all of your organizations" on, in every organization its creator can open in the app. List them with GET /v2/companies. Every response's X-Company-Id header names the organization it acted in. See [Organizations](https://mindcloud.co/docs/api/rest/introduction/organizations).

### Body

- `position` (object): Where the copy goes: { parentStepId, slot, afterStepId }.
  Where the copy goes. Left out: right after the original.
  - `parentStepId` (string): The loop, folder, batch step or If/Else the step goes inside. null or left out: the top level.
  - `slot` (string): steps at the top level; body inside a loop, folder or batch step; then or else inside an If/Else. Defaults to steps at the top level.
    Allowed values:
      - `steps`: The top level of the workflow.
      - `body`: Inside a loop, a folder, or a step that pages in batches: the steps that run for each item or page.
      - `then`: The If/Else lane that runs when its conditions are true.
      - `else`: The If/Else lane that runs otherwise.
  - `afterStepId` (string): The step in that slot to follow. null puts the step first; left out puts it last.

## Example request

```bash
curl --request POST \
  --url 'https://connect.mindcloud.co/v2/workflows/Wq3kZ8pLx2Nb/steps/SyDtUxIQeocK/duplicate' \
  --header 'Authorization: Bearer $MINDCLOUD_API_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "position": {
    "afterStepId": "SyDtUxIQeocK"
  }
}'
```

## Response fields

- `id` (string): The step's id. Stable across edits; never positional.
- `number` (number): The number the editor shows for this step, in execution order. Null for a folder, which the editor does not number.
- `name` (string): The step's display name.
- `appSlug` (string): The app the step runs, or the built-in step type (iterate, ifElse, map, ...).
- `appVersion` (string): The app version the step is pinned to. For a built-in step (If, Loop, Map, ...), the version of the built-in app it was added with, "0" or "0.0.1" (some older ones hold "draft" or null); it does not change what the step does.
- `actionId` (string): The app action the step runs. Null for a built-in step type.
- `functionId` (string): The function this step calls, for a function call step.
- `parentStepId` (string): The step this one sits inside (a loop, group, folder or if/else). Null at the top level.
- `slot` (string): Where the step sits in its parent: steps (the top level), body (a loop, group or folder), then or else (an if/else lane).
  Allowed values:
    - `steps`
    - `body`
    - `then`
    - `else`
- `depth` (number): How deeply the step is nested. 0 at the top level.
- `isDisabled` (boolean): True when the step is turned off and runs skip it.
- `isConfigured` (boolean): Whether the step passed the editor's validation (required values set, connection chosen). Null when it was never validated.
