> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.markup.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.markup.ai/_mcp/server.

# Append Style Agent Batch Items

POST https://api.markup.ai/style-agent/batch/{batch_id}/items
Content-Type: application/json

Append up to 20 more documents to a batch that is still processing.

Rejected with 409 once the batch is sealed (1000 documents reached, or every
document has finished) — create a new batch instead. Send an
``Idempotency-Key`` header to make retries safe: the same key + payload
replays the original 202 instead of appending the documents again.

Reference: https://docs.markup.ai/developer-reference/api-reference/style-agent/append-style-agent-batch-items

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `batch_id` (string, required)

### 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 an AppendItemsRequest.

- `items` (list of BatchItemRequest, required)
- `defaults` (BatchDefaults, optional, nullable) — Optional per-batch defaults applied to any item that omits the field.

## Response

### 202

Documents appended

- `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.

### 404 Not Found Error

Batch not found

- `any`

### 409 Conflict Error

Batch sealed or over the 1000-document limit, or 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/batch_id/items"

payload = { "items": [{ "text": "string" }] }
headers = {
    "Authorization": "Bearer <token>",
    "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/batch_id/items';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', '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/batch_id/items"

	payload := strings.NewReader("{\n  \"items\": [\n    {\n      \"text\": \"string\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	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/batch_id/items")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
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<String> response = Unirest.post("https://api.markup.ai/style-agent/batch/batch_id/items")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"items\": [\n    {\n      \"text\": \"string\"\n    }\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.markup.ai/style-agent/batch/batch_id/items', [
  'body' => '{
  "items": [
    {
      "text": "string"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.markup.ai/style-agent/batch/batch_id/items");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
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 <token>",
  "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/batch_id/items")! 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()
```