> 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/uploads/confirm/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://onepin.ai/_mcp/server. # Confirm Upload POST https://api.onepin.ai/api/v1/uploads/{upload_id} Content-Type: application/json Confirm a completed upload and bind it to a resource (step 2 of 2). Call this after successfully PUTting your file to the presigned URL returned by `POST /uploads`. Provide `context_type` and `context_id` to associate the file with an existing `workflow` or `assistant_session` resource, or with the selected workspace for `playground`. The file is moved to its final location and `status` transitions from `pending` to `uploaded`. This endpoint is idempotent: if the upload was already confirmed, the current state is returned without re-processing. Storage quota is checked against the workspace at confirm time. If confirming would exceed the workspace storage limit, a 402 is returned and the file remains in its staging location (the upload record stays `pending` so you can delete the staging file and try a smaller file). Binding to a workspace-scoped resource requires the caller to hold at least the `editor` role in that workspace (viewers get 403); the workspace is inferred from the resource when `X-Workspace-Id` is omitted. Workspace membership is always required (non-members get 404). The internal `playground` context replaces the `editor` requirement with current platform-admin identity. API-key callers are workspace-scoped already and bypass the role check for non-playground contexts. Dual-auth: Bearer JWT or API key (scope `uploads:write`). Reference: https://onepin.ai/docs/reference/api-reference/uploads/confirm ## 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 - `upload_id` (string, required) ### Headers - `X-Workspace-Id` (string, optional, nullable) ### Body (application/json) This endpoint expects an UploadConfirmRequest. - `context_type` (enum, required) — Type of resource this upload is being attached to: `workflow`, `playground`, or `assistant_session`. - Allowed values: `workflow`, `playground`, `assistant_session` - `context_id` (string, required) — ID of the resource to attach this upload to. Must be an existing resource of the given `context_type` that the caller has access to. ## Response ### 200 Successful Response - `data` (UploadOut, required) - `meta` (Meta, required) ## Errors ### 422 Unprocessable Entity Error Validation Error - `detail` (list of ValidationError, optional) ## Types ### UploadOut - `id` (string, required) — Unique upload identifier. Use this as `upload_id` in confirm and delete calls. - `user_id` (string, required) — ID of the user who created the upload. - `filename` (string, required) — Sanitized display filename (Unicode-safe, extension preserved). - `category` (string, required) — Upload category: `script` or `dictionary`. - `content_type` (string, required) — MIME type inferred from the file extension at create time. - `status` (string, required) — `pending` until confirmed; `uploaded` after a successful confirm call. - `created_at` (datetime, required) - `updated_at` (datetime, required) - `workspace_id` (string, optional, nullable) — Workspace this upload is scoped to, if any. Set at create time via `X-Workspace-Id` or derived from the bound resource at confirm time. - `format` (string, optional, nullable) — Normalized format identifier (e.g. `mp3`, `txt`), if applicable. - `size_bytes` (integer, optional, nullable) — File size in bytes. Populated after a successful confirm. - `char_count` (integer, optional, nullable) — Decoded character count of the uploaded script: the sum of Unicode code-point lengths of each stripped, non-empty line (leading/trailing whitespace, blank lines, and newlines excluded). This is always code points; it equals the billed `unit_chars` for character-billed models but not for byte-billed models (e.g. Fish Audio), which bill UTF-8 bytes. Populated after a successful confirm for `script` uploads in `.txt` or `.pdf` format (a PDF is parsed with the same text extractor the run uses). `null` while pending, for a PDF whose text cannot be extracted (encrypted, scanned/image-only, or corrupt), and for `dictionary` (audio) uploads. - `line_count` (integer, optional, nullable) — Number of non-empty lines in the uploaded script. Populated alongside `char_count` (same scope: confirmed `script` `.txt`/`.pdf` uploads); `null` otherwise. - `detected_language` (string, optional, nullable) — Server-detected dominant source language as a bare BCP-47 code (e.g. `en`, `ko`). Populated after a successful confirm for `script` `.txt`/`.pdf` uploads. The client maps it to a supported regional locale (e.g. `en` → `en-us`). `null` when detection is not confident, when the detected language is not a supported locale, and for non-script uploads — in which case the source language is picked manually. - `download_url` (string, optional, nullable) — Short-lived presigned URL for downloading the confirmed file. `null` for pending uploads. - `context_type` (string, optional, nullable) — Resource type this upload is attached to (e.g. `workflow` or `playground`). Set at confirm time. - `context_id` (string, optional, nullable) — ID of the attached resource. Set at confirm time. ### 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) ### ValidationErrorLocItems ### ValidationErrorCtx ## Examples **Request** ```json { "context_type": "workflow", "context_id": "string" } ``` **Response** ```json { "data": { "id": "string", "user_id": "string", "filename": "string", "category": "string", "content_type": "string", "status": "string", "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z", "workspace_id": "string", "format": "string", "size_bytes": 1, "char_count": 1, "line_count": 1, "detected_language": "string", "download_url": "string", "context_type": "string", "context_id": "string" }, "meta": { "request_id": "string", "timestamp": "2024-01-15T09:30:00Z" } } ``` **SDK Code** ```python import requests url = "https://api.onepin.ai/api/v1/uploads/upload_id" payload = { "context_type": "workflow", "context_id": "string" } 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/uploads/upload_id'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"context_type":"workflow","context_id":"string"}' }; 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/uploads/upload_id" payload := strings.NewReader("{\n \"context_type\": \"workflow\",\n \"context_id\": \"string\"\n}") 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/uploads/upload_id") 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 = "{\n \"context_type\": \"workflow\",\n \"context_id\": \"string\"\n}" 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/uploads/upload_id") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"context_type\": \"workflow\",\n \"context_id\": \"string\"\n}") .asString(); ``` ```php request('POST', 'https://api.onepin.ai/api/v1/uploads/upload_id', [ 'body' => '{ "context_type": "workflow", "context_id": "string" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.onepin.ai/api/v1/uploads/upload_id"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"context_type\": \"workflow\",\n \"context_id\": \"string\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "context_type": "workflow", "context_id": "string" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.onepin.ai/api/v1/uploads/upload_id")! 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.