> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://onepin.ai/docs/reference/api-reference/workflows/duplicate-workflow-api-v-1-workflows-workflow-id-duplicate-post/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://onepin.ai/_mcp/server. # Duplicate Workflow POST https://api.onepin.ai/api/v1/workflows/{workflow_id}/duplicate Create a copy of an existing workflow in the same workspace. The new workflow inherits the source's `name` (suffixed with " (Copy)"), `description`, and `definition`. Runs from the original workflow are not copied — the duplicate starts with zero runs. Requires at least `editor` role. Returns 201 with the new workflow on success. Reference: https://onepin.ai/docs/reference/api-reference/workflows/duplicate-workflow-api-v-1-workflows-workflow-id-duplicate-post ## Authentication - `Authorization` header (bearer token, required) — Clerk JWT token - `Authorization` header (bearer token, required) — Onepin live API key (`op_live_...`). Test and public keys are reserved in Phase 1. ## Servers - `https://api.onepin.ai` (prod, default) - `https://dev-api.onepin.ai` (dev) ## Request ### Path parameters - `workflow_id` (string, required) ### Headers - `X-Workspace-Id` (string, optional, nullable) ## Response ### 201 Successful Response - `data` (WorkflowOut, required) - `meta` (Meta, required) ## Errors ### 422 Unprocessable Entity Error Validation Error - `detail` (list of ValidationError, optional) ## Types ### WorkflowOut - `id` (string, required) — Unique workflow identifier. - `user_id` (string, required) — ID of the user who created the workflow. - `name` (string, required) — Human-readable workflow name. - `name_source` (string, required) — How `name` was set: 'placeholder' | 'generated' | 'user'. - `definition` (map from string to any, required) — Full workflow graph and execution config as stored (config-migrated on read). - `created_at` (datetime, required) — When the workflow was created (UTC). - `updated_at` (datetime, required) — When the workflow was last modified (UTC). - `description` (string, optional, nullable) — Optional workflow description. - `runs_count` (integer, optional, default: 0) — Total number of runs ever started for this workflow. - `last_run_at` (datetime, optional, nullable) — When the most recent run was created. Null if never run. - `last_run_status` (string, optional, nullable) — Raw RunStatus of the most recent run. One of: `pending`, `running`, `completed`, `failed`, `cancelled`, `paused`. Null if never run. - `run_status_counts` (RunStatusCounts, optional) — Number of runs per raw RunStatus, computed over ALL runs of this workflow (same population as `runs_count`; NOT affected by the list-level `status` filter). The sum of all values equals `runs_count`; statuses with no runs are 0. ### Meta - `request_id` (string, required) - `timestamp` (datetime, required) ### ValidationError - `loc` (list of ValidationErrorLocItems, required) - `msg` (string, required) - `type` (string, required) - `input` (any, optional) - `ctx` (ValidationErrorCtx, optional) ### RunStatusCounts Per-raw-`RunStatus` run counts for a workflow. Computed over ALL runs of the workflow — the same population as `runs_count` — so it is NOT affected by the list-level `status` filter. Every raw status is always present; a status with no runs is `0`. The sum of all fields equals `runs_count`, and each field matches the `pagination.total` of `GET /workflows/{id}/runs?status=`. These are RAW status counts (not the UI-derived `WorkflowListStatus` buckets), so the caller can group them per tab. - `pending` (integer, optional, default: 0) — Runs queued but not yet started. - `running` (integer, optional, default: 0) — Runs currently executing. - `completed` (integer, optional, default: 0) — Runs that finished successfully. - `failed` (integer, optional, default: 0) — Runs that ended in a failure state. - `cancelled` (integer, optional, default: 0) — Runs explicitly cancelled by a user. - `paused` (integer, optional, default: 0) — Runs currently paused/parked. ### ValidationErrorLocItems ### ValidationErrorCtx ## Examples **Response** ```json { "data": { "id": "string", "user_id": "string", "name": "string", "name_source": "string", "definition": {}, "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z", "description": "string", "runs_count": 0, "last_run_at": "2024-01-15T09:30:00Z", "last_run_status": "string", "run_status_counts": { "pending": 0, "running": 0, "completed": 0, "failed": 0, "cancelled": 0, "paused": 0 } }, "meta": { "request_id": "string", "timestamp": "2024-01-15T09:30:00Z" } } ``` **SDK Code** ```python import requests url = "https://api.onepin.ai/api/v1/workflows/workflow_id/duplicate" headers = {"Authorization": "Bearer "} response = requests.post(url, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.onepin.ai/api/v1/workflows/workflow_id/duplicate'; const options = {method: 'POST', headers: {Authorization: 'Bearer '}}; 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://api.onepin.ai/api/v1/workflows/workflow_id/duplicate" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Authorization", "Bearer ") 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://api.onepin.ai/api/v1/workflows/workflow_id/duplicate") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.onepin.ai/api/v1/workflows/workflow_id/duplicate") .header("Authorization", "Bearer ") .asString(); ``` ```php request('POST', 'https://api.onepin.ai/api/v1/workflows/workflow_id/duplicate', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.onepin.ai/api/v1/workflows/workflow_id/duplicate"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.onepin.ai/api/v1/workflows/workflow_id/duplicate")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" 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() ``` > Onepin is a voice workflow platform that orchestrates, validates, and ships production-ready audio across 33 TTS models.