> 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/templates/update-template-api-v-1-templates-template-id-patch/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://onepin.ai/_mcp/server. # Update Template PATCH https://api.onepin.ai/api/v1/templates/{template_id} Content-Type: application/json Update a template owned by the caller's workspace. All fields are optional (omit to keep the stored value). When `definition` is supplied it is a full replace — send the complete graph, not a partial diff. Structural validation runs on write, same as `POST /templates`. Restrictions: - Only the owning workspace may update its templates (403 otherwise). - Platform starter templates (`is_starter=true`) are read-only via this endpoint regardless of workspace ownership (403). - Updates apply only to the draft/live definition; the published gallery snapshot is not updated until an admin republishes. Requires workspace `editor` role or higher. Reference: https://onepin.ai/docs/reference/api-reference/templates/update-template-api-v-1-templates-template-id-patch ## Authentication - `Authorization` header (bearer token, required) — Clerk JWT token ## Servers - `https://api.onepin.ai` (prod, default) - `https://dev-api.onepin.ai` (dev) ## Request ### Path parameters - `template_id` (string, required) — Case-sensitive 8-character base62 template identifier. ### Headers - `X-Workspace-Id` (string, optional, nullable) ### Body (application/json) This endpoint expects a TemplateUpdate. - `name` (string, optional, nullable) - `description` (string, optional, nullable) - `category` (enum, optional, nullable) - Allowed values: `media`, `creative`, `business`, `education`, `wellness` - `definition` (WorkflowDefinition-Input, optional, nullable) — Full-replace on PATCH. Omit to keep the stored value. Explicit `null` is rejected — there is no 'empty graph' use-case worth the ambiguity. The union with `null` here only makes omission easy for FE clients; see `reject_null_definition` for the runtime guard. ## Response ### 200 Successful Response - `data` (TemplateOut, required) — Response shape. `workspace_id` is intentionally omitted so the gallery endpoint (which returns rows from any workspace) does not leak tenant ownership IDs across tenants. `created_by` is retained as author provenance for public/starter rows. `definition` is the serialized `WorkflowDefinition` JSONB (same shape as `Workflow.definition`) — a template is a reusable workflow snapshot. - `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) ### TemplateOut Response shape. `workspace_id` is intentionally omitted so the gallery endpoint (which returns rows from any workspace) does not leak tenant ownership IDs across tenants. `created_by` is retained as author provenance for public/starter rows. `definition` is the serialized `WorkflowDefinition` JSONB (same shape as `Workflow.definition`) — a template is a reusable workflow snapshot. - `id` (string, required) — Case-sensitive 8-character base62 template identifier. - `name` (string, required) — Display name of the template. - `definition` (WorkflowDefinition-Output, required) — Full workflow definition (graph + execution config). Use this directly as the `definition` body when creating a workflow from scratch, or clone via `POST /templates/{id}/clone`. - `is_starter` (boolean, required) — `true` for platform-curated starter templates. Starter templates cannot be updated or deleted. - `is_public` (boolean, required) — `true` when this template has an active published snapshot visible in the gallery. - `uses_count` (integer, required) — Number of times this template has been cloned into a workflow. - `created_at` (datetime, required) - `updated_at` (datetime, required) — Last-modified timestamp. For gallery rows this reflects the most recent publish; for own-workspace rows it reflects the most recent draft save. - `description` (string, optional, nullable) — Optional human-readable description. - `category` (enum, optional, nullable) — Gallery category tag, if set. - Allowed values: `media`, `creative`, `business`, `education`, `wellness` - `is_favorite` (boolean, optional, default: false) — `true` when the authenticated caller has favorited this template. - `created_by` (string, optional, nullable) — User ID of the template author. ### 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) ### WorkflowDefinition-Output - `graph` (GraphDefinition-Output, optional) - `execution` (ExecutionDefinition, optional) ### 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) ### GraphDefinition-Output - `nodes` (list of GraphNode, optional) - `edges` (list of GraphEdge, optional) ### NodePosition - `x` (double, required) - `y` (double, required) ## Examples **Request** ```json {} ``` **Response** ```json { "data": { "id": "string", "name": "string", "definition": { "graph": { "nodes": [ { "id": "string", "type": "source_script", "position": { "x": 1.1, "y": 1.1 }, "name": "string", "config": {}, "config_version": 1 } ], "edges": [ { "id": "string", "source": "string", "sourcePort": "string", "target": "string", "targetPort": "string" } ] }, "execution": { "steps": [ "string" ], "params": {} } }, "is_starter": true, "is_public": true, "uses_count": 1, "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z", "description": "string", "category": "media", "is_favorite": false, "created_by": "string" }, "meta": { "request_id": "string", "timestamp": "2024-01-15T09:30:00Z" } } ``` **SDK Code** ```python import requests url = "https://api.onepin.ai/api/v1/templates/template_id" payload = {} headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.patch(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.onepin.ai/api/v1/templates/template_id'; const options = { method: 'PATCH', 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/templates/template_id" payload := strings.NewReader("{}") req, _ := http.NewRequest("PATCH", 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/templates/template_id") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Patch.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.patch("https://api.onepin.ai/api/v1/templates/template_id") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{}") .asString(); ``` ```php request('PATCH', 'https://api.onepin.ai/api/v1/templates/template_id', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.onepin.ai/api/v1/templates/template_id"); var request = new RestRequest(Method.PATCH); 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/templates/template_id")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PATCH" 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.