> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.markup.ai/developer-reference/api-reference/style-agent/run-style-agent-file/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.markup.ai/_mcp/server. # Run Style Agent File POST https://api.markup.ai/style-agent/run-file Content-Type: multipart/form-data Run a Style Agent check on an uploaded document. Accepts PDF, Word (.docx), HTML, DITA, Markdown, and plain-text files. The file is uploaded unchanged and its text extracted for you, so the check runs against the document as submitted. Behaves like `POST /style-agent/run` otherwise: `wait=true` blocks for the result (201 Created), the default returns 202 Accepted with a workflow id to poll via `GET /style-agent/workflows/{workflow_id}`. A large file can take longer than the synchronous request window, so prefer polling for those. Issue positions index the extracted text, not the bytes you uploaded; use each issue's `context_surface` to locate it in the original document. Reference: https://docs.markup.ai/developer-reference/api-reference/style-agent/run-style-agent-file ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Query parameters - `wait` (boolean, optional, default: false) ### Body (multipart/form-data) This endpoint expects a multipart form containing a file. - `style_guide_id` (string, optional) — Style guide ID to check the document against. ``target_id`` is a deprecated alias for this field; send exactly one of the two names. - `content_profile_id` (string, optional) — Language-service content profile ID for style checking. - `domain_ids` (list of string, optional) — Terminology domain IDs. - `document_ref` (string, optional) — Caller-provided document identifier for tracking across scans. - `url` (string, optional) — Document URL. - `document_name` (string, optional) — Document name or title. - `webhook_url` (string, optional) — Optional webhook URL for async result delivery. - `file_upload` (file, required) — The document to analyze. Text (.txt), Markdown (.md), HTML (.html .htm), DITA (.dita, .xml), Word (.docx), and PDF (.pdf) files are accepted. The max file size is 7 MB. ## Response ### 200 Successful Response - `workflow_id` (string, required) — Workflow ID for tracking - `status` (enum, required) — Workflow status - Allowed values: `running`, `completed`, `failed`, `timed_out`, `cancelled` - `started_at` (datetime, required) — Workflow start time - `request_id` (string, optional, nullable) — Request tracking ID - `document_ref` (string, optional, nullable) — Caller-provided document identifier. - `check_type` (enum, optional) — How this check is counted: 'batch' for a document checked as part of a batch, 'interactive' for a direct /run check. - Allowed values: `interactive`, `automated`, `batch`, `baseline` - `assigned` (boolean, optional, default: true) — Whether the check counts as authoring activity for an author. - `batch_id` (string, optional, nullable) — Owning batch id (agbw\_\); null unless this is a batch check. - `result` (StyleAgentResult, optional, nullable) — Execution result (if completed) - `completed_at` (datetime, optional, nullable) — Workflow completion time - `duration_seconds` (double, optional, nullable) — Execution duration ### 201 Completed (wait=true) - `workflow_id` (string, required) — Workflow ID for tracking - `status` (enum, required) — Workflow status - Allowed values: `running`, `completed`, `failed`, `timed_out`, `cancelled` - `started_at` (datetime, required) — Workflow start time - `request_id` (string, optional, nullable) — Request tracking ID - `document_ref` (string, optional, nullable) — Caller-provided document identifier. - `check_type` (enum, optional) — How this check is counted: 'batch' for a document checked as part of a batch, 'interactive' for a direct /run check. - Allowed values: `interactive`, `automated`, `batch`, `baseline` - `assigned` (boolean, optional, default: true) — Whether the check counts as authoring activity for an author. - `batch_id` (string, optional, nullable) — Owning batch id (agbw\_\); null unless this is a batch check. - `result` (StyleAgentResult, optional, nullable) — Execution result (if completed) - `completed_at` (datetime, optional, nullable) — Workflow completion time - `duration_seconds` (double, optional, nullable) — Execution duration ### 202 Accepted (wait=false) - `workflow_id` (string, required) — Workflow ID for tracking - `status` (enum, required) — Workflow status - Allowed values: `running`, `completed`, `failed`, `timed_out`, `cancelled` - `started_at` (datetime, required) — Workflow start time - `request_id` (string, optional, nullable) — Request tracking ID - `document_ref` (string, optional, nullable) — Caller-provided document identifier. - `check_type` (enum, optional) — How this check is counted: 'batch' for a document checked as part of a batch, 'interactive' for a direct /run check. - Allowed values: `interactive`, `automated`, `batch`, `baseline` - `assigned` (boolean, optional, default: true) — Whether the check counts as authoring activity for an author. - `batch_id` (string, optional, nullable) — Owning batch id (agbw\_\); null unless this is a batch check. - `result` (StyleAgentResult, optional, nullable) — Execution result (if completed) - `completed_at` (datetime, optional, nullable) — Workflow completion time - `duration_seconds` (double, optional, nullable) — Execution duration ## Errors ### 401 Unauthorized Error Authentication failed or no valid API key provided. - `detail` (string, required) — A description of the error that occurred. - `status` (integer, required) — The HTTP status code generated by the server for this issue - `request_id` (string, required) — A unique ID associated with the HTTP request. ### 403 Forbidden Error Forbidden - `detail` (string, required) — A description of the error that occurred. - `status` (integer, required) — The HTTP status code generated by the server for this issue - `request_id` (string, required) — A unique ID associated with the HTTP request. ### 413 Content Too Large Error File exceeds the maximum allowed size - `any` ### 422 Unprocessable Entity Error Invalid input for agent - `any` ### 500 Internal Server Error Workflow execution failed (wait=true) - `any` ## Types ### StyleAgentResult Result of a Style Agent content check. Only the ``analysis`` block is typed here — issues, quality scores, and any agent-specific keys flow through unchanged (``extra="allow"``). Validating ``analysis`` at this edge also mirrors the legacy ``targetId`` naming onto the canonical ``styleGuideId`` keys for results persisted before the rename. - `analysis` (StyleAgentAnalysis, optional, nullable) — Style guide, content profile, and readability metadata for the checked document. Omitted while the run is in progress and for organizations without numeric scoring. ### StyleAgentAnalysis Style guide, content profile, and readability metadata forwarded from SLS. Cortex populates this from the language-service ``data.analysis`` block (legacy ``targetId`` naming) and helios_one republishes it on the style-agent API surface. ``styleGuideId`` / ``styleGuideDisplayName`` are the canonical public keys; the legacy ``targetId`` / ``targetDisplayName`` keys carry the same values (and are marked deprecated in the schema) until removed in a future API version. The mirror runs on validation, so results persisted before the rename gain the canonical keys when re-validated. - `styleGuideId` (string, optional, nullable) - `styleGuideDisplayName` (string, optional, nullable) - `contentProfileId` (string, optional, nullable) - `contentProfileDisplayName` (string, optional, nullable) - `words` (integer, optional, nullable) - `sentences` (integer, optional, nullable) - `clarityIndex` (double, optional, nullable) - `informalityIndex` (double, optional, nullable) - `livelinessIndex` (double, optional, nullable) - `fleschReadingEase` (double, optional, nullable) - `targetId` (string, optional, nullable, deprecated) - `targetDisplayName` (string, optional, nullable, deprecated) ## Examples ### Example 1 **Request** ```json { "content_profile_id": { "type": "json" }, "document_name": { "type": "json" }, "document_ref": { "type": "json" }, "domain_ids": { "type": "json" }, "file_upload": "", "style_guide_id": { "type": "json" }, "url": { "type": "json" }, "webhook_url": { "type": "json" } } ``` **Response** ```json { "workflow_id": "string", "status": "running", "started_at": "2024-01-15T09:30:00Z", "request_id": "string", "document_ref": "string", "check_type": "interactive", "assigned": true, "batch_id": "string", "result": { "analysis": { "styleGuideId": "string", "styleGuideDisplayName": "string", "contentProfileId": "string", "contentProfileDisplayName": "string", "words": 1, "sentences": 1, "clarityIndex": 1.1, "informalityIndex": 1.1, "livelinessIndex": 1.1, "fleschReadingEase": 1.1, "targetId": "string", "targetDisplayName": "string" } }, "completed_at": "2024-01-15T09:30:00Z", "duration_seconds": 1.1 } ``` **SDK Code** ```python Python import requests with open("/path/to/your/file.pdf", "rb") as file: response = requests.post( "https://api.markup.ai/style-agent/run-file", headers={"Authorization": "Bearer YOUR_TOKEN"}, params={"wait": "true"}, files={"file_upload": file}, data={ "style_guide_id": "YOUR_STYLE_GUIDE_ID", "content_profile_id": "YOUR_CONTENT_PROFILE_ID", "document_ref": "handbook/chapter-3", "document_name": "Employee Handbook", "domain_ids": ["YOUR_DOMAIN_ID"], }, ) print(response.json()) ``` ```python Python import time import requests BASE = "https://api.markup.ai" HEADERS = {"Authorization": "Bearer YOUR_TOKEN"} with open("/path/to/your/file.pdf", "rb") as file: workflow_id = requests.post( f"{BASE}/style-agent/run-file", headers=HEADERS, files={"file_upload": file}, ).json()["workflow_id"] while True: status = requests.get( f"{BASE}/style-agent/workflows/{workflow_id}", headers=HEADERS ).json() # Terminal states: completed, failed, timed_out, cancelled. if status["status"] != "running": break time.sleep(5) print(status["status"], status.get("result")) ``` ```typescript TypeScript import { readFileSync } from "fs"; const form = new FormData(); form.append( "file_upload", new Blob([readFileSync("/path/to/your/file.pdf")]), "file.pdf", ); form.append("style_guide_id", "YOUR_STYLE_GUIDE_ID"); form.append("content_profile_id", "YOUR_CONTENT_PROFILE_ID"); form.append("document_ref", "handbook/chapter-3"); form.append("document_name", "Employee Handbook"); form.append("domain_ids", "YOUR_DOMAIN_ID"); const response = await fetch( "https://api.markup.ai/style-agent/run-file?wait=true", { method: "POST", headers: { Authorization: "Bearer YOUR_TOKEN" }, body: form, }, ); console.log(await response.json()); ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.markup.ai/style-agent/run-file" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_profile_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_name\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_ref\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain_ids\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_upload\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"style_guide_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001") 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.markup.ai/style-agent/run-file") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001' request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_profile_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_name\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_ref\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain_ids\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_upload\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"style_guide_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\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.markup.ai/style-agent/run-file") .header("Authorization", "Bearer ") .header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_profile_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_name\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_ref\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain_ids\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_upload\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"style_guide_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n") .asString(); ``` ```php request('POST', 'https://api.markup.ai/style-agent/run-file', [ 'multipart' => [ [ 'name' => 'content_profile_id', 'contents' => '{ "type": "json" }' ], [ 'name' => 'document_name', 'contents' => '{ "type": "json" }' ], [ 'name' => 'document_ref', 'contents' => '{ "type": "json" }' ], [ 'name' => 'domain_ids', 'contents' => '{ "type": "json" }' ], [ 'name' => 'file_upload', 'filename' => '[object Object]', 'contents' => null ], [ 'name' => 'style_guide_id', 'contents' => '{ "type": "json" }' ], [ 'name' => 'url', 'contents' => '{ "type": "json" }' ], [ 'name' => 'webhook_url', 'contents' => '{ "type": "json" }' ] ] 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.markup.ai/style-agent/run-file"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_profile_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_name\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_ref\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain_ids\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_upload\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"style_guide_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "multipart/form-data; boundary=---011000010111000001101001" ] let parameters = [ [ "name": "content_profile_id", "value": "{ \"type\": \"json\" }" ], [ "name": "document_name", "value": "{ \"type\": \"json\" }" ], [ "name": "document_ref", "value": "{ \"type\": \"json\" }" ], [ "name": "domain_ids", "value": "{ \"type\": \"json\" }" ], [ "name": "file_upload", "fileName": "[object Object]" ], [ "name": "style_guide_id", "value": "{ \"type\": \"json\" }" ], [ "name": "url", "value": "{ \"type\": \"json\" }" ], [ "name": "webhook_url", "value": "{ \"type\": \"json\" }" ] ] let boundary = "---011000010111000001101001" var body = "" var error: NSError? = nil for param in parameters { let paramName = param["name"]! body += "--\(boundary)\r\n" body += "Content-Disposition:form-data; name=\"\(paramName)\"" if let filename = param["fileName"] { let contentType = param["content-type"]! let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) if (error != nil) { print(error as Any) } body += "; filename=\"\(filename)\"\r\n" body += "Content-Type: \(contentType)\r\n\r\n" body += fileContent } else if let paramValue = param["value"] { body += "\r\n\r\n\(paramValue)" } } let request = NSMutableURLRequest(url: NSURL(string: "https://api.markup.ai/style-agent/run-file")! 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() ``` ### Example 2 **Request** ```json { "content_profile_id": { "type": "json" }, "document_name": { "type": "json" }, "document_ref": { "type": "json" }, "domain_ids": { "type": "json" }, "file_upload": "", "style_guide_id": { "type": "json" }, "url": { "type": "json" }, "webhook_url": { "type": "json" } } ``` **Response** ```json { "workflow_id": "string", "status": "running", "started_at": "2024-01-15T09:30:00Z", "request_id": "string", "document_ref": "string", "check_type": "interactive", "assigned": true, "batch_id": "string", "result": { "analysis": { "styleGuideId": "string", "styleGuideDisplayName": "string", "contentProfileId": "string", "contentProfileDisplayName": "string", "words": 1, "sentences": 1, "clarityIndex": 1.1, "informalityIndex": 1.1, "livelinessIndex": 1.1, "fleschReadingEase": 1.1, "targetId": "string", "targetDisplayName": "string" } }, "completed_at": "2024-01-15T09:30:00Z", "duration_seconds": 1.1 } ``` **SDK Code** ```python Python import requests with open("/path/to/your/file.pdf", "rb") as file: response = requests.post( "https://api.markup.ai/style-agent/run-file", headers={"Authorization": "Bearer YOUR_TOKEN"}, params={"wait": "true"}, files={"file_upload": file}, data={ "style_guide_id": "YOUR_STYLE_GUIDE_ID", "content_profile_id": "YOUR_CONTENT_PROFILE_ID", "document_ref": "handbook/chapter-3", "document_name": "Employee Handbook", "domain_ids": ["YOUR_DOMAIN_ID"], }, ) print(response.json()) ``` ```python Python import time import requests BASE = "https://api.markup.ai" HEADERS = {"Authorization": "Bearer YOUR_TOKEN"} with open("/path/to/your/file.pdf", "rb") as file: workflow_id = requests.post( f"{BASE}/style-agent/run-file", headers=HEADERS, files={"file_upload": file}, ).json()["workflow_id"] while True: status = requests.get( f"{BASE}/style-agent/workflows/{workflow_id}", headers=HEADERS ).json() # Terminal states: completed, failed, timed_out, cancelled. if status["status"] != "running": break time.sleep(5) print(status["status"], status.get("result")) ``` ```typescript TypeScript import { readFileSync } from "fs"; const form = new FormData(); form.append( "file_upload", new Blob([readFileSync("/path/to/your/file.pdf")]), "file.pdf", ); form.append("style_guide_id", "YOUR_STYLE_GUIDE_ID"); form.append("content_profile_id", "YOUR_CONTENT_PROFILE_ID"); form.append("document_ref", "handbook/chapter-3"); form.append("document_name", "Employee Handbook"); form.append("domain_ids", "YOUR_DOMAIN_ID"); const response = await fetch( "https://api.markup.ai/style-agent/run-file?wait=true", { method: "POST", headers: { Authorization: "Bearer YOUR_TOKEN" }, body: form, }, ); console.log(await response.json()); ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.markup.ai/style-agent/run-file" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_profile_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_name\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_ref\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain_ids\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_upload\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"style_guide_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001") 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.markup.ai/style-agent/run-file") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001' request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_profile_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_name\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_ref\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain_ids\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_upload\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"style_guide_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\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.markup.ai/style-agent/run-file") .header("Authorization", "Bearer ") .header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_profile_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_name\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_ref\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain_ids\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_upload\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"style_guide_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n") .asString(); ``` ```php request('POST', 'https://api.markup.ai/style-agent/run-file', [ 'multipart' => [ [ 'name' => 'content_profile_id', 'contents' => '{ "type": "json" }' ], [ 'name' => 'document_name', 'contents' => '{ "type": "json" }' ], [ 'name' => 'document_ref', 'contents' => '{ "type": "json" }' ], [ 'name' => 'domain_ids', 'contents' => '{ "type": "json" }' ], [ 'name' => 'file_upload', 'filename' => '[object Object]', 'contents' => null ], [ 'name' => 'style_guide_id', 'contents' => '{ "type": "json" }' ], [ 'name' => 'url', 'contents' => '{ "type": "json" }' ], [ 'name' => 'webhook_url', 'contents' => '{ "type": "json" }' ] ] 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.markup.ai/style-agent/run-file"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_profile_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_name\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_ref\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain_ids\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_upload\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"style_guide_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "multipart/form-data; boundary=---011000010111000001101001" ] let parameters = [ [ "name": "content_profile_id", "value": "{ \"type\": \"json\" }" ], [ "name": "document_name", "value": "{ \"type\": \"json\" }" ], [ "name": "document_ref", "value": "{ \"type\": \"json\" }" ], [ "name": "domain_ids", "value": "{ \"type\": \"json\" }" ], [ "name": "file_upload", "fileName": "[object Object]" ], [ "name": "style_guide_id", "value": "{ \"type\": \"json\" }" ], [ "name": "url", "value": "{ \"type\": \"json\" }" ], [ "name": "webhook_url", "value": "{ \"type\": \"json\" }" ] ] let boundary = "---011000010111000001101001" var body = "" var error: NSError? = nil for param in parameters { let paramName = param["name"]! body += "--\(boundary)\r\n" body += "Content-Disposition:form-data; name=\"\(paramName)\"" if let filename = param["fileName"] { let contentType = param["content-type"]! let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) if (error != nil) { print(error as Any) } body += "; filename=\"\(filename)\"\r\n" body += "Content-Type: \(contentType)\r\n\r\n" body += fileContent } else if let paramValue = param["value"] { body += "\r\n\r\n\(paramValue)" } } let request = NSMutableURLRequest(url: NSURL(string: "https://api.markup.ai/style-agent/run-file")! 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() ``` ### Example 3 **Request** ```json { "content_profile_id": { "type": "json" }, "document_name": { "type": "json" }, "document_ref": { "type": "json" }, "domain_ids": { "type": "json" }, "file_upload": "", "style_guide_id": { "type": "json" }, "url": { "type": "json" }, "webhook_url": { "type": "json" } } ``` **Response** ```json { "workflow_id": "string", "status": "running", "started_at": "2024-01-15T09:30:00Z", "request_id": "string", "document_ref": "string", "check_type": "interactive", "assigned": true, "batch_id": "string", "result": { "analysis": { "styleGuideId": "string", "styleGuideDisplayName": "string", "contentProfileId": "string", "contentProfileDisplayName": "string", "words": 1, "sentences": 1, "clarityIndex": 1.1, "informalityIndex": 1.1, "livelinessIndex": 1.1, "fleschReadingEase": 1.1, "targetId": "string", "targetDisplayName": "string" } }, "completed_at": "2024-01-15T09:30:00Z", "duration_seconds": 1.1 } ``` **SDK Code** ```python Python import requests with open("/path/to/your/file.pdf", "rb") as file: response = requests.post( "https://api.markup.ai/style-agent/run-file", headers={"Authorization": "Bearer YOUR_TOKEN"}, params={"wait": "true"}, files={"file_upload": file}, data={ "style_guide_id": "YOUR_STYLE_GUIDE_ID", "content_profile_id": "YOUR_CONTENT_PROFILE_ID", "document_ref": "handbook/chapter-3", "document_name": "Employee Handbook", "domain_ids": ["YOUR_DOMAIN_ID"], }, ) print(response.json()) ``` ```python Python import time import requests BASE = "https://api.markup.ai" HEADERS = {"Authorization": "Bearer YOUR_TOKEN"} with open("/path/to/your/file.pdf", "rb") as file: workflow_id = requests.post( f"{BASE}/style-agent/run-file", headers=HEADERS, files={"file_upload": file}, ).json()["workflow_id"] while True: status = requests.get( f"{BASE}/style-agent/workflows/{workflow_id}", headers=HEADERS ).json() # Terminal states: completed, failed, timed_out, cancelled. if status["status"] != "running": break time.sleep(5) print(status["status"], status.get("result")) ``` ```typescript TypeScript import { readFileSync } from "fs"; const form = new FormData(); form.append( "file_upload", new Blob([readFileSync("/path/to/your/file.pdf")]), "file.pdf", ); form.append("style_guide_id", "YOUR_STYLE_GUIDE_ID"); form.append("content_profile_id", "YOUR_CONTENT_PROFILE_ID"); form.append("document_ref", "handbook/chapter-3"); form.append("document_name", "Employee Handbook"); form.append("domain_ids", "YOUR_DOMAIN_ID"); const response = await fetch( "https://api.markup.ai/style-agent/run-file?wait=true", { method: "POST", headers: { Authorization: "Bearer YOUR_TOKEN" }, body: form, }, ); console.log(await response.json()); ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.markup.ai/style-agent/run-file" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_profile_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_name\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_ref\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain_ids\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_upload\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"style_guide_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001") 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.markup.ai/style-agent/run-file") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001' request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_profile_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_name\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_ref\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain_ids\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_upload\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"style_guide_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\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.markup.ai/style-agent/run-file") .header("Authorization", "Bearer ") .header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_profile_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_name\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_ref\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain_ids\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_upload\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"style_guide_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n") .asString(); ``` ```php request('POST', 'https://api.markup.ai/style-agent/run-file', [ 'multipart' => [ [ 'name' => 'content_profile_id', 'contents' => '{ "type": "json" }' ], [ 'name' => 'document_name', 'contents' => '{ "type": "json" }' ], [ 'name' => 'document_ref', 'contents' => '{ "type": "json" }' ], [ 'name' => 'domain_ids', 'contents' => '{ "type": "json" }' ], [ 'name' => 'file_upload', 'filename' => '[object Object]', 'contents' => null ], [ 'name' => 'style_guide_id', 'contents' => '{ "type": "json" }' ], [ 'name' => 'url', 'contents' => '{ "type": "json" }' ], [ 'name' => 'webhook_url', 'contents' => '{ "type": "json" }' ] ] 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.markup.ai/style-agent/run-file"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_profile_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_name\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_ref\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain_ids\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_upload\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"style_guide_id\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "multipart/form-data; boundary=---011000010111000001101001" ] let parameters = [ [ "name": "content_profile_id", "value": "{ \"type\": \"json\" }" ], [ "name": "document_name", "value": "{ \"type\": \"json\" }" ], [ "name": "document_ref", "value": "{ \"type\": \"json\" }" ], [ "name": "domain_ids", "value": "{ \"type\": \"json\" }" ], [ "name": "file_upload", "fileName": "[object Object]" ], [ "name": "style_guide_id", "value": "{ \"type\": \"json\" }" ], [ "name": "url", "value": "{ \"type\": \"json\" }" ], [ "name": "webhook_url", "value": "{ \"type\": \"json\" }" ] ] let boundary = "---011000010111000001101001" var body = "" var error: NSError? = nil for param in parameters { let paramName = param["name"]! body += "--\(boundary)\r\n" body += "Content-Disposition:form-data; name=\"\(paramName)\"" if let filename = param["fileName"] { let contentType = param["content-type"]! let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) if (error != nil) { print(error as Any) } body += "; filename=\"\(filename)\"\r\n" body += "Content-Type: \(contentType)\r\n\r\n" body += fileContent } else if let paramValue = param["value"] { body += "\r\n\r\n\(paramValue)" } } let request = NSMutableURLRequest(url: NSURL(string: "https://api.markup.ai/style-agent/run-file")! 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() ```