> 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/create-style-agent-batch/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.markup.ai/_mcp/server. # Create Style Agent Batch POST https://api.markup.ai/style-agent/batch Content-Type: application/json Create a style-agent batch of up to 20 documents and start checking them. Returns 202 with a `batch_id` to poll at `GET /style-agent/batch/{id}`. Append more documents (up to 1000 total) while the batch is still processing via `POST /style-agent/batch/{id}/items`. Send an `Idempotency-Key` header to make retries safe: the same key + payload replays the original 202 instead of creating a second batch. Polling that report is the authoritative way to learn a batch finished. An optional `webhook_url` is a bounded best-effort notification on top of it — it can fire zero times or more than once, so receivers must deduplicate on `batch_id`. Reference: https://docs.markup.ai/developer-reference/api-reference/style-agent/create-style-agent-batch ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Headers - `Idempotency-Key` (string, optional, nullable) — Optional client-generated key making this submission idempotent: a retry with the same key and payload returns the original accepted response instead of submitting the documents again. Reusing a key with a different payload returns 409. ### Body (application/json) This endpoint expects a CreateBatchRequest. - `items` (list of BatchItemRequest, required) - `defaults` (BatchDefaults, optional, nullable) — Optional per-batch defaults applied to any item that omits the field. - `webhook_url` (string, optional, nullable) — Notified when the batch reaches a terminal state (D5). Delivery is bounded best-effort, not guaranteed: a failed POST is retried with backoff for roughly two hours and then abandoned, so this endpoint may be called zero times or more than once. GET /style-agent/batch/\{batch\_id} is authoritative — poll it if the notification has not arrived. Deduplicate on the payload's batch\_id: a batch has exactly one completion event, so batch\_id is its stable event id. ## Response ### 202 Batch accepted - `batch_id` (string, required) - `segment_workflow_id` (string, required) - `status` (enum, required) — Lifecycle of a style-agent batch (see design-docs/style-agent-batch-checking.md). A batch is ``running`` while any item is non-terminal; it becomes ``completed`` (and ``sealed``) once every item reaches a terminal state. - Allowed values: `running`, `completed` - `item_count` (integer, required) - `created_at` (datetime, required) - `items` (list of BatchItemResponse, required) ## 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. ### 409 Conflict Error Idempotency-Key reused with a different payload - `any` ### 413 Content Too Large Error Request payload exceeds the per-request size limit - `any` ### 422 Unprocessable Entity Error Invalid input for one or more items - `any` ### 500 Internal Server Error Internal Server Error - `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. ## Types ### BatchItemRequest One document to check. Style-agent fields only (D4/D13). - `text` (string, required) - `document_ref` (string, optional, nullable) — Caller-provided document identifier. - `style_guide_id` (string, optional, nullable) — Style guide to check against (overrides defaults). - `content_profile_id` (string, optional, nullable) - `domain_ids` (list of string, optional, nullable) - `url` (string, optional, nullable) - `document_name` (string, optional, nullable) - `author` (string, optional, nullable) — Who this document's check is credited to (D16). A batch check counts as authoring activity for its content's author; supply that identity here. When omitted, the check is credited to the batch's runner. ### BatchDefaults Optional per-batch defaults applied to any item that omits the field. - `style_guide_id` (string, optional, nullable) - `content_profile_id` (string, optional, nullable) - `domain_ids` (list of string, optional, nullable) ### BatchItemResponse Per-item entry in a batch response (no full result — fetch by workflow_id, D5). - `item_id` (string, required) - `workflow_id` (string, required) - `status` (enum, required) — Per-document status within a batch, cached from the child workflow. - Allowed values: `pending`, `running`, `completed`, `failed` - `document_ref` (string, optional, nullable) - `error_category` (enum, optional, nullable) — Why a batch item failed (D7): a bad request vs. a processing/system fault. - Allowed values: `input`, `processing` ## Examples **Request** ```json { "items": [ { "text": "string" } ] } ``` **Response** ```json { "batch_id": "string", "segment_workflow_id": "string", "status": "running", "item_count": 1, "created_at": "2024-01-15T09:30:00Z", "items": [ { "item_id": "string", "workflow_id": "string", "status": "pending", "document_ref": "string", "error_category": "input" } ] } ``` **SDK Code** ```python import requests url = "https://api.markup.ai/style-agent/batch" payload = { "items": [{ "text": "string" }] } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.markup.ai/style-agent/batch'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"items":[{"text":"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.markup.ai/style-agent/batch" payload := strings.NewReader("{\n \"items\": [\n {\n \"text\": \"string\"\n }\n ]\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.markup.ai/style-agent/batch") 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 \"items\": [\n {\n \"text\": \"string\"\n }\n ]\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/batch") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"items\": [\n {\n \"text\": \"string\"\n }\n ]\n}") .asString(); ``` ```php request('POST', 'https://api.markup.ai/style-agent/batch', [ 'body' => '{ "items": [ { "text": "string" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.markup.ai/style-agent/batch"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"items\": [\n {\n \"text\": \"string\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["items": [["text": "string"]]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.markup.ai/style-agent/batch")! 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() ```