> 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/create-workflow-api-v-1-workflows-post/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://onepin.ai/_mcp/server. # Create Workflow POST https://api.onepin.ai/api/v1/workflows Content-Type: application/json Create a new workflow in the current workspace. Validates the workflow `definition` (graph structure, node types, edge connectivity) before persisting. Returns 422 with structured details if the definition fails validation. Requires at least `editor` role in the workspace; viewers cannot create workflows. The `definition` contains a `graph` (nodes and edges) and an `execution` block (ordered step list and execution params). Omitting `definition` creates a workflow with an empty graph that can be edited later. `name` is optional. Omit it to get the server-side placeholder `"Untitled workflow"` (`name_source: "placeholder"`), which the assistant auto-names from the first message via `POST /workflows/{id}/name/generate`. An explicit `name` is stored as-is with `name_source: "user"`. Reference: https://onepin.ai/docs/reference/api-reference/workflows/create-workflow-api-v-1-workflows-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 ### Headers - `X-Workspace-Id` (string, optional, nullable) ### Body (application/json) This endpoint expects a WorkflowCreate. - `name` (string, optional, nullable) — Human-readable workflow name (1–200 characters, non-blank). Omit to create an unnamed workflow that gets a server-side placeholder and is auto-named from the first assistant message. - `description` (string, optional, nullable) — Optional description shown in the workflow list (max 5000 characters). - `definition` (WorkflowDefinition-Input, optional) — Graph and execution config. Omit to create an empty workflow. ## Response ### 201 Successful Response - `data` (WorkflowOut, required) - `meta` (Meta, required) ## Errors ### 422 Unprocessable Entity Error Validation Error - `detail` (list of ValidationError, optional) ## Types ### WorkflowDefinition-Input - `graph` (GraphDefinition-Input, optional) - `execution` (ExecutionDefinition, optional) ### 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) ### GraphDefinition-Input - `nodes` (list of GraphNode, optional) - `edges` (list of GraphEdge, optional) ### ExecutionDefinition - `steps` (list of string, optional) - `params` (map from string to any, 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 ### GraphNode - `id` (string, required) - `type` (enum, required) - Allowed values: `source_script`, `operator_translator`, `operator_normalizer`, `operator_generator`, `operator_phoneme_injector`, `sink_preview`, `validator_error_rate`, `validator_naturalness`, `validator_noise`, `validator_pronunciation`, `operator_pronunciation_corrector` - `position` (NodePosition, required) - `name` (string, optional, nullable) - `config` (map from string to any, optional) - `config_version` (integer, optional, default: 1) ### GraphEdge - `id` (string, required) - `source` (string, required) - `sourcePort` (string, required) - `target` (string, required) - `targetPort` (string, required) ### NodePosition - `x` (double, required) - `y` (double, required) ## Examples **Request** ```json {} ``` **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" payload = {} headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.onepin.ai/api/v1/workflows'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{}' }; 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" "strings" "net/http" "io" ) func main() { url := "https://api.onepin.ai/api/v1/workflows" payload := strings.NewReader("{}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") 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") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{}" 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") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{}") .asString(); ``` ```php request('POST', 'https://api.onepin.ai/api/v1/workflows', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.onepin.ai/api/v1/workflows"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.onepin.ai/api/v1/workflows")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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.