Crear un lote
Envía hasta 10.000 tareas en un lote y recibe su id.
POST
/
v1
/
batches
Create a batch
curl --request POST \
--url https://api.querying.ai/v1/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"idempotencyKey": "daily-2026-10-09",
"webhook": {
"url": "https://example.com/hooks/querying"
},
"metadata": {
"run": "daily"
},
"items": [
{
"customId": "shoes-chatgpt-us",
"taskType": "CHATGPT",
"payload": {
"prompt": "best running shoes 2026",
"country": "US"
}
},
{
"customId": "shoes-gemini-us",
"taskType": "GEMINI",
"payload": {
"prompt": "best running shoes 2026",
"country": "US"
}
}
]
}
'import requests
url = "https://api.querying.ai/v1/batches"
payload = {
"idempotencyKey": "daily-2026-10-09",
"webhook": { "url": "https://example.com/hooks/querying" },
"metadata": { "run": "daily" },
"items": [
{
"customId": "shoes-chatgpt-us",
"taskType": "CHATGPT",
"payload": {
"prompt": "best running shoes 2026",
"country": "US"
}
},
{
"customId": "shoes-gemini-us",
"taskType": "GEMINI",
"payload": {
"prompt": "best running shoes 2026",
"country": "US"
}
}
]
}
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({
idempotencyKey: 'daily-2026-10-09',
webhook: {url: 'https://example.com/hooks/querying'},
metadata: {run: 'daily'},
items: [
{
customId: 'shoes-chatgpt-us',
taskType: 'CHATGPT',
payload: {prompt: 'best running shoes 2026', country: 'US'}
},
{
customId: 'shoes-gemini-us',
taskType: 'GEMINI',
payload: {prompt: 'best running shoes 2026', country: 'US'}
}
]
})
};
fetch('https://api.querying.ai/v1/batches', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.querying.ai/v1/batches",
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([
'idempotencyKey' => 'daily-2026-10-09',
'webhook' => [
'url' => 'https://example.com/hooks/querying'
],
'metadata' => [
'run' => 'daily'
],
'items' => [
[
'customId' => 'shoes-chatgpt-us',
'taskType' => 'CHATGPT',
'payload' => [
'prompt' => 'best running shoes 2026',
'country' => 'US'
]
],
[
'customId' => 'shoes-gemini-us',
'taskType' => 'GEMINI',
'payload' => [
'prompt' => 'best running shoes 2026',
'country' => 'US'
]
]
]
]),
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 := "https://api.querying.ai/v1/batches"
payload := strings.NewReader("{\n \"idempotencyKey\": \"daily-2026-10-09\",\n \"webhook\": {\n \"url\": \"https://example.com/hooks/querying\"\n },\n \"metadata\": {\n \"run\": \"daily\"\n },\n \"items\": [\n {\n \"customId\": \"shoes-chatgpt-us\",\n \"taskType\": \"CHATGPT\",\n \"payload\": {\n \"prompt\": \"best running shoes 2026\",\n \"country\": \"US\"\n }\n },\n {\n \"customId\": \"shoes-gemini-us\",\n \"taskType\": \"GEMINI\",\n \"payload\": {\n \"prompt\": \"best running shoes 2026\",\n \"country\": \"US\"\n }\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(string(body))
}HttpResponse<String> response = Unirest.post("https://api.querying.ai/v1/batches")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"idempotencyKey\": \"daily-2026-10-09\",\n \"webhook\": {\n \"url\": \"https://example.com/hooks/querying\"\n },\n \"metadata\": {\n \"run\": \"daily\"\n },\n \"items\": [\n {\n \"customId\": \"shoes-chatgpt-us\",\n \"taskType\": \"CHATGPT\",\n \"payload\": {\n \"prompt\": \"best running shoes 2026\",\n \"country\": \"US\"\n }\n },\n {\n \"customId\": \"shoes-gemini-us\",\n \"taskType\": \"GEMINI\",\n \"payload\": {\n \"prompt\": \"best running shoes 2026\",\n \"country\": \"US\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.querying.ai/v1/batches")
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 \"idempotencyKey\": \"daily-2026-10-09\",\n \"webhook\": {\n \"url\": \"https://example.com/hooks/querying\"\n },\n \"metadata\": {\n \"run\": \"daily\"\n },\n \"items\": [\n {\n \"customId\": \"shoes-chatgpt-us\",\n \"taskType\": \"CHATGPT\",\n \"payload\": {\n \"prompt\": \"best running shoes 2026\",\n \"country\": \"US\"\n }\n },\n {\n \"customId\": \"shoes-gemini-us\",\n \"taskType\": \"GEMINI\",\n \"payload\": {\n \"prompt\": \"best running shoes 2026\",\n \"country\": \"US\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"batch": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "OPEN",
"total": 123,
"counts": {
"pending": 123,
"queued": 123,
"processing": 123,
"completed": 123,
"failed": 123,
"rejected": 123
},
"createdAt": "2023-11-07T05:31:56Z",
"completedAt": "2023-11-07T05:31:56Z",
"metadata": {},
"idempotencyKey": "<string>",
"webhook": {
"url": "<string>"
}
}
}{
"success": true,
"batch": {
"id": "3f6b2a10-0000-0000-0000-000000000000",
"status": "OPEN",
"total": 10000,
"counts": {
"pending": 9520,
"queued": 480,
"processing": 0,
"completed": 0,
"failed": 0,
"rejected": 0
},
"createdAt": "2026-10-09T09:00:00.000Z",
"completedAt": null,
"idempotencyKey": "daily-2026-10-09",
"webhook": {
"url": "https://example.com/hooks/querying"
},
"metadata": {
"run": "daily"
}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "1 of 10000 items are invalid; the batch was not stored",
"details": {
"invalidItems": 1,
"items": [
{
"index": 17,
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"details": [
{
"field": "payload.prompt",
"message": "Invalid input: expected string, received undefined"
}
]
}
]
},
"timestamp": "2026-10-09T09:00:00.000Z"
}
}{
"success": false,
"error": {
"code": "MISSING_API_KEY",
"message": "Missing or invalid API key",
"timestamp": "2026-07-09T04:12:00.000Z"
}
}{
"success": false,
"error": {
"code": "PAYLOAD_TOO_LARGE",
"message": "batch body exceeds 33554432 bytes",
"timestamp": "2026-10-09T09:00:00.000Z"
}
}Autorizaciones
Your API key, sent as Authorization: Bearer <key>.
Cuerpo
application/json
Required array length:
1 - 10000 elementsShow child attributes
Show child attributes
Each item's task posts its result here, and the batch posts one batch.completed event when it finishes.
Show child attributes
Show child attributes
Up to 8 KB of JSON, returned with the batch.
Sending the same key again returns the first batch.
Maximum string length:
256⌘I
Create a batch
curl --request POST \
--url https://api.querying.ai/v1/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"idempotencyKey": "daily-2026-10-09",
"webhook": {
"url": "https://example.com/hooks/querying"
},
"metadata": {
"run": "daily"
},
"items": [
{
"customId": "shoes-chatgpt-us",
"taskType": "CHATGPT",
"payload": {
"prompt": "best running shoes 2026",
"country": "US"
}
},
{
"customId": "shoes-gemini-us",
"taskType": "GEMINI",
"payload": {
"prompt": "best running shoes 2026",
"country": "US"
}
}
]
}
'import requests
url = "https://api.querying.ai/v1/batches"
payload = {
"idempotencyKey": "daily-2026-10-09",
"webhook": { "url": "https://example.com/hooks/querying" },
"metadata": { "run": "daily" },
"items": [
{
"customId": "shoes-chatgpt-us",
"taskType": "CHATGPT",
"payload": {
"prompt": "best running shoes 2026",
"country": "US"
}
},
{
"customId": "shoes-gemini-us",
"taskType": "GEMINI",
"payload": {
"prompt": "best running shoes 2026",
"country": "US"
}
}
]
}
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({
idempotencyKey: 'daily-2026-10-09',
webhook: {url: 'https://example.com/hooks/querying'},
metadata: {run: 'daily'},
items: [
{
customId: 'shoes-chatgpt-us',
taskType: 'CHATGPT',
payload: {prompt: 'best running shoes 2026', country: 'US'}
},
{
customId: 'shoes-gemini-us',
taskType: 'GEMINI',
payload: {prompt: 'best running shoes 2026', country: 'US'}
}
]
})
};
fetch('https://api.querying.ai/v1/batches', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.querying.ai/v1/batches",
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([
'idempotencyKey' => 'daily-2026-10-09',
'webhook' => [
'url' => 'https://example.com/hooks/querying'
],
'metadata' => [
'run' => 'daily'
],
'items' => [
[
'customId' => 'shoes-chatgpt-us',
'taskType' => 'CHATGPT',
'payload' => [
'prompt' => 'best running shoes 2026',
'country' => 'US'
]
],
[
'customId' => 'shoes-gemini-us',
'taskType' => 'GEMINI',
'payload' => [
'prompt' => 'best running shoes 2026',
'country' => 'US'
]
]
]
]),
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 := "https://api.querying.ai/v1/batches"
payload := strings.NewReader("{\n \"idempotencyKey\": \"daily-2026-10-09\",\n \"webhook\": {\n \"url\": \"https://example.com/hooks/querying\"\n },\n \"metadata\": {\n \"run\": \"daily\"\n },\n \"items\": [\n {\n \"customId\": \"shoes-chatgpt-us\",\n \"taskType\": \"CHATGPT\",\n \"payload\": {\n \"prompt\": \"best running shoes 2026\",\n \"country\": \"US\"\n }\n },\n {\n \"customId\": \"shoes-gemini-us\",\n \"taskType\": \"GEMINI\",\n \"payload\": {\n \"prompt\": \"best running shoes 2026\",\n \"country\": \"US\"\n }\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(string(body))
}HttpResponse<String> response = Unirest.post("https://api.querying.ai/v1/batches")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"idempotencyKey\": \"daily-2026-10-09\",\n \"webhook\": {\n \"url\": \"https://example.com/hooks/querying\"\n },\n \"metadata\": {\n \"run\": \"daily\"\n },\n \"items\": [\n {\n \"customId\": \"shoes-chatgpt-us\",\n \"taskType\": \"CHATGPT\",\n \"payload\": {\n \"prompt\": \"best running shoes 2026\",\n \"country\": \"US\"\n }\n },\n {\n \"customId\": \"shoes-gemini-us\",\n \"taskType\": \"GEMINI\",\n \"payload\": {\n \"prompt\": \"best running shoes 2026\",\n \"country\": \"US\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.querying.ai/v1/batches")
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 \"idempotencyKey\": \"daily-2026-10-09\",\n \"webhook\": {\n \"url\": \"https://example.com/hooks/querying\"\n },\n \"metadata\": {\n \"run\": \"daily\"\n },\n \"items\": [\n {\n \"customId\": \"shoes-chatgpt-us\",\n \"taskType\": \"CHATGPT\",\n \"payload\": {\n \"prompt\": \"best running shoes 2026\",\n \"country\": \"US\"\n }\n },\n {\n \"customId\": \"shoes-gemini-us\",\n \"taskType\": \"GEMINI\",\n \"payload\": {\n \"prompt\": \"best running shoes 2026\",\n \"country\": \"US\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"batch": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "OPEN",
"total": 123,
"counts": {
"pending": 123,
"queued": 123,
"processing": 123,
"completed": 123,
"failed": 123,
"rejected": 123
},
"createdAt": "2023-11-07T05:31:56Z",
"completedAt": "2023-11-07T05:31:56Z",
"metadata": {},
"idempotencyKey": "<string>",
"webhook": {
"url": "<string>"
}
}
}{
"success": true,
"batch": {
"id": "3f6b2a10-0000-0000-0000-000000000000",
"status": "OPEN",
"total": 10000,
"counts": {
"pending": 9520,
"queued": 480,
"processing": 0,
"completed": 0,
"failed": 0,
"rejected": 0
},
"createdAt": "2026-10-09T09:00:00.000Z",
"completedAt": null,
"idempotencyKey": "daily-2026-10-09",
"webhook": {
"url": "https://example.com/hooks/querying"
},
"metadata": {
"run": "daily"
}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "1 of 10000 items are invalid; the batch was not stored",
"details": {
"invalidItems": 1,
"items": [
{
"index": 17,
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"details": [
{
"field": "payload.prompt",
"message": "Invalid input: expected string, received undefined"
}
]
}
]
},
"timestamp": "2026-10-09T09:00:00.000Z"
}
}{
"success": false,
"error": {
"code": "MISSING_API_KEY",
"message": "Missing or invalid API key",
"timestamp": "2026-07-09T04:12:00.000Z"
}
}{
"success": false,
"error": {
"code": "PAYLOAD_TOO_LARGE",
"message": "batch body exceeds 33554432 bytes",
"timestamp": "2026-10-09T09:00:00.000Z"
}
}