curl -X POST https://api.omnifence.ai/api/v1/moderate/text/batch \
-H "Authorization: Bearer $OMNIFENCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"items": [
{ "key": "name", "text": "Captain Mira" },
{ "key": "backstory", "text": "A pilot who left the fleet." }
],
"webhook_url": "https://your-app.com/webhooks/omnifence"
}'import requests
url = "http://localhost:3051/api/v1/moderate/text/batch"
payload = {
"items": [
{
"key": "<string>",
"text": "<string>"
}
],
"webhook_url": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({items: [{key: '<string>', text: '<string>'}], webhook_url: '<string>'})
};
fetch('http://localhost:3051/api/v1/moderate/text/batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3051",
CURLOPT_URL => "http://localhost:3051/api/v1/moderate/text/batch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'key' => '<string>',
'text' => '<string>'
]
],
'webhook_url' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:3051/api/v1/moderate/text/batch"
payload := strings.NewReader("{\n \"items\": [\n {\n \"key\": \"<string>\",\n \"text\": \"<string>\"\n }\n ],\n \"webhook_url\": \"<string>\"\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(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:3051/api/v1/moderate/text/batch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"key\": \"<string>\",\n \"text\": \"<string>\"\n }\n ],\n \"webhook_url\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3051/api/v1/moderate/text/batch")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"key\": \"<string>\",\n \"text\": \"<string>\"\n }\n ],\n \"webhook_url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"batch_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "processing",
"items": [
{
"key": "<string>",
"job_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
]
}{
"error": "<string>",
"message": "<string>",
"statusCode": 503,
"batch_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}Submit a text moderation batch
Submit 1 to 99 texts in one request. Each item is checked on its own, exactly as /moderate/text checks one text, and gets its own decision under the key you gave it. One batch request counts as one request against your rate limit; each item is billed as one text moderation. Each item is also an ordinary text job, so GET /job/{job_id} reads it. When every item has a final decision or has failed, one webhook carries all the decisions. The batch is accepted whole or refused whole: an empty batch (BATCH_EMPTY), more than 99 items (BATCH_TOO_LARGE), a repeated key (DUPLICATE_ITEM_KEY), a text over 20,000 characters (TEXT_TOO_LONG) or any other invalid item (INVALID_REQUEST) refuses the request with 400, and nothing is charged.
curl -X POST https://api.omnifence.ai/api/v1/moderate/text/batch \
-H "Authorization: Bearer $OMNIFENCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"items": [
{ "key": "name", "text": "Captain Mira" },
{ "key": "backstory", "text": "A pilot who left the fleet." }
],
"webhook_url": "https://your-app.com/webhooks/omnifence"
}'import requests
url = "http://localhost:3051/api/v1/moderate/text/batch"
payload = {
"items": [
{
"key": "<string>",
"text": "<string>"
}
],
"webhook_url": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({items: [{key: '<string>', text: '<string>'}], webhook_url: '<string>'})
};
fetch('http://localhost:3051/api/v1/moderate/text/batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3051",
CURLOPT_URL => "http://localhost:3051/api/v1/moderate/text/batch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'key' => '<string>',
'text' => '<string>'
]
],
'webhook_url' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:3051/api/v1/moderate/text/batch"
payload := strings.NewReader("{\n \"items\": [\n {\n \"key\": \"<string>\",\n \"text\": \"<string>\"\n }\n ],\n \"webhook_url\": \"<string>\"\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(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:3051/api/v1/moderate/text/batch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"key\": \"<string>\",\n \"text\": \"<string>\"\n }\n ],\n \"webhook_url\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3051/api/v1/moderate/text/batch")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"key\": \"<string>\",\n \"text\": \"<string>\"\n }\n ],\n \"webhook_url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"batch_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "processing",
"items": [
{
"key": "<string>",
"job_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
]
}{
"error": "<string>",
"message": "<string>",
"statusCode": 503,
"batch_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}moderate:text scope. Requests without this scope receive a 403 FORBIDDEN
response. See authentication.text is limited to 20,000 characters, and each key must be
unique in the batch. An invalid batch is refused with 400 before any job is created or billed.
See batch text moderation.Authorizations
API key from the Omnifence dashboard
Body
The texts to check, 1 to 99. Each item is checked on its own and gets its own decision.
1 - 99 elementsShow child attributes
Show child attributes
HTTPS URL that receives one webhook when every item has a final decision or has failed. Falls back to your registered webhook. Items send no webhook of their own.