API Reference
Create a Batch
Submit a Moderation Batch backed by a valid purpose=batch File.
Submit a Moderation Batch backed by a valid purpose=batch File.
Endpoint
- Base URL
https://runapi.ai- API version
v1- Authentication
Authorization: Bearer YOUR_API_KEY
02
JSON bodyRequest
Send values only in the listed request location.
application/json4 fields
completion_windowstring
Required
Completion window for this Batch capability.
endpointstring
Required
Moderation endpoint processed by this Batch capability.
input_file_idstring
Required
RunAPI File ID for a purpose=batch input File.
metadataobject
Optional
Optional caller metadata returned with the Batch object.
03
HTTP 200Success response
POST /v1/batches
JSON
{
"completion_window": "24h",
"created_at": 1785196800,
"endpoint": "/v1/moderations",
"id": "batch_abc123",
"input_file_id": "file_batch123",
"metadata": {
"customer_tag": "demo"
},
"object": "batch",
"request_counts": {
"completed": 0,
"failed": 0,
"total": 3
},
"status": "validating"
}
04
HTTP 401Error response (401)
Response schema
JSON
{
"additionalProperties": true,
"properties": {
"error": {
"additionalProperties": true,
"properties": {
"code": {
"type": [
"string",
"null"
]
},
"message": {
"type": "string"
},
"param": {
"type": [
"string",
"null"
]
},
"type": {
"type": "string"
}
},
"required": [
"message",
"type"
],
"type": "object"
}
},
"required": [
"error"
],
"type": "object"
}
Response example
JSON
{
"error": {
"code": "authentication_error",
"message": "Missing API key",
"param": null,
"type": "authentication_error"
}
}
05
HTTP 400Error response (400)
Response schema
JSON
{
"additionalProperties": true,
"properties": {
"error": {
"additionalProperties": true,
"properties": {
"code": {
"type": [
"string",
"null"
]
},
"message": {
"type": "string"
},
"param": {
"type": [
"string",
"null"
]
},
"type": {
"type": "string"
}
},
"required": [
"message",
"type"
],
"type": "object"
}
},
"required": [
"error"
],
"type": "object"
}
Response example
JSON
{
"error": {
"code": "invalid_request_error",
"message": "Malformed request",
"param": null,
"type": "invalid_request_error"
}
}
06
HTTP 404Error response (404)
Response schema
JSON
{
"additionalProperties": true,
"properties": {
"error": {
"additionalProperties": true,
"properties": {
"code": {
"type": [
"string",
"null"
]
},
"message": {
"type": "string"
},
"param": {
"type": [
"string",
"null"
]
},
"type": {
"type": "string"
}
},
"required": [
"message",
"type"
],
"type": "object"
}
},
"required": [
"error"
],
"type": "object"
}
Response example
JSON
{
"error": {
"code": "not_found",
"message": "File not found",
"param": null,
"type": "invalid_request_error"
}
}
07
HTTP 409Error response (409)
Response schema
JSON
{
"additionalProperties": true,
"properties": {
"error": {
"additionalProperties": true,
"properties": {
"code": {
"type": [
"string",
"null"
]
},
"message": {
"type": "string"
},
"param": {
"type": [
"string",
"null"
]
},
"type": {
"type": "string"
}
},
"required": [
"message",
"type"
],
"type": "object"
}
},
"required": [
"error"
],
"type": "object"
}
Response example
JSON
{
"error": {
"code": "upload_state_conflict",
"message": "Upload state conflict",
"param": null,
"type": "invalid_request_error"
}
}
08
HTTP 402Error response (402)
Response schema
JSON
{
"additionalProperties": true,
"properties": {
"error": {
"additionalProperties": true,
"properties": {
"code": {
"type": [
"string",
"null"
]
},
"message": {
"type": "string"
},
"param": {
"type": [
"string",
"null"
]
},
"type": {
"type": "string"
}
},
"required": [
"message",
"type"
],
"type": "object"
}
},
"required": [
"error"
],
"type": "object"
}
Response example
JSON
{
"error": {
"code": "payment_required",
"message": "Insufficient balance",
"param": null,
"type": "insufficient_balance"
}
}
09
HTTP 422Error response (422)
Response schema
JSON
{
"additionalProperties": true,
"properties": {
"error": {
"additionalProperties": true,
"properties": {
"code": {
"type": [
"string",
"null"
]
},
"message": {
"type": "string"
},
"param": {
"type": [
"string",
"null"
]
},
"type": {
"type": "string"
}
},
"required": [
"message",
"type"
],
"type": "object"
}
},
"required": [
"error"
],
"type": "object"
}
Response example
JSON
{
"error": {
"code": "invalid_upload",
"message": "Upload request rejected",
"param": null,
"type": "invalid_request_error"
}
}
10
HTTP 502Error response (502)
Response schema
JSON
{
"additionalProperties": true,
"properties": {
"error": {
"additionalProperties": true,
"properties": {
"code": {
"type": [
"string",
"null"
]
},
"message": {
"type": "string"
},
"param": {
"type": [
"string",
"null"
]
},
"type": {
"type": "string"
}
},
"required": [
"message",
"type"
],
"type": "object"
}
},
"required": [
"error"
],
"type": "object"
}
Response example
JSON
{
"error": {
"code": "storage_write_failed",
"message": "File storage failed",
"param": null,
"type": "server_error"
}
}
11
cURL example
CURL
curl -X POST https://runapi.ai/v1/batches \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"input_file_id":"file_batch123","endpoint":"/v1/moderations","completion_window":"24h","metadata":{"customer_tag":"demo"}}'