Batch Classification
curl --request POST \
--url https://extraction-api.nanonets.com/api/v2/classify/async \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": [
"file://a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"file://c3d4e5f6-a7b8-9012-cdef-a12345678901"
],
"classification_config": {
"categories": [
{
"name": "Invoice"
},
{
"name": "Receipt"
}
],
"mode": "document"
}
}
'import requests
url = "https://extraction-api.nanonets.com/api/v2/classify/async"
payload = {
"input": ["file://a1b2c3d4-e5f6-7890-abcd-ef1234567890", "file://c3d4e5f6-a7b8-9012-cdef-a12345678901"],
"classification_config": {
"categories": [{ "name": "Invoice" }, { "name": "Receipt" }],
"mode": "document"
}
}
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({
input: [
'file://a1b2c3d4-e5f6-7890-abcd-ef1234567890',
'file://c3d4e5f6-a7b8-9012-cdef-a12345678901'
],
classification_config: {categories: [{name: 'Invoice'}, {name: 'Receipt'}], mode: 'document'}
})
};
fetch('https://extraction-api.nanonets.com/api/v2/classify/async', 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://extraction-api.nanonets.com/api/v2/classify/async",
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([
'input' => [
'file://a1b2c3d4-e5f6-7890-abcd-ef1234567890',
'file://c3d4e5f6-a7b8-9012-cdef-a12345678901'
],
'classification_config' => [
'categories' => [
[
'name' => 'Invoice'
],
[
'name' => 'Receipt'
]
],
'mode' => 'document'
]
]),
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://extraction-api.nanonets.com/api/v2/classify/async"
payload := strings.NewReader("{\n \"input\": [\n \"file://a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"file://c3d4e5f6-a7b8-9012-cdef-a12345678901\"\n ],\n \"classification_config\": {\n \"categories\": [\n {\n \"name\": \"Invoice\"\n },\n {\n \"name\": \"Receipt\"\n }\n ],\n \"mode\": \"document\"\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://extraction-api.nanonets.com/api/v2/classify/async")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"input\": [\n \"file://a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"file://c3d4e5f6-a7b8-9012-cdef-a12345678901\"\n ],\n \"classification_config\": {\n \"categories\": [\n {\n \"name\": \"Invoice\"\n },\n {\n \"name\": \"Receipt\"\n }\n ],\n \"mode\": \"document\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://extraction-api.nanonets.com/api/v2/classify/async")
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 \"input\": [\n \"file://a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"file://c3d4e5f6-a7b8-9012-cdef-a12345678901\"\n ],\n \"classification_config\": {\n \"categories\": [\n {\n \"name\": \"Invoice\"\n },\n {\n \"name\": \"Receipt\"\n }\n ],\n \"mode\": \"document\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"total": 123,
"items": [
{
"input": "<string>",
"record_id": "<string>",
"file_id": "<string>",
"error": "<string>"
}
],
"batch_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Document Classification
Batch Classification
Classify multiple documents by providing a list of inputs (up to 50). Each document is classified using the same categories and mode.
Returns a BatchResponse with per-item completion status.
Tip: You can save and reuse classification settings (categories & mode) by creating a config via Create Config. Pass the returned
config_idinstead of repeatingclassification_configeach time.
POST
/
api
/
v2
/
classify
/
async
Batch Classification
curl --request POST \
--url https://extraction-api.nanonets.com/api/v2/classify/async \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": [
"file://a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"file://c3d4e5f6-a7b8-9012-cdef-a12345678901"
],
"classification_config": {
"categories": [
{
"name": "Invoice"
},
{
"name": "Receipt"
}
],
"mode": "document"
}
}
'import requests
url = "https://extraction-api.nanonets.com/api/v2/classify/async"
payload = {
"input": ["file://a1b2c3d4-e5f6-7890-abcd-ef1234567890", "file://c3d4e5f6-a7b8-9012-cdef-a12345678901"],
"classification_config": {
"categories": [{ "name": "Invoice" }, { "name": "Receipt" }],
"mode": "document"
}
}
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({
input: [
'file://a1b2c3d4-e5f6-7890-abcd-ef1234567890',
'file://c3d4e5f6-a7b8-9012-cdef-a12345678901'
],
classification_config: {categories: [{name: 'Invoice'}, {name: 'Receipt'}], mode: 'document'}
})
};
fetch('https://extraction-api.nanonets.com/api/v2/classify/async', 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://extraction-api.nanonets.com/api/v2/classify/async",
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([
'input' => [
'file://a1b2c3d4-e5f6-7890-abcd-ef1234567890',
'file://c3d4e5f6-a7b8-9012-cdef-a12345678901'
],
'classification_config' => [
'categories' => [
[
'name' => 'Invoice'
],
[
'name' => 'Receipt'
]
],
'mode' => 'document'
]
]),
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://extraction-api.nanonets.com/api/v2/classify/async"
payload := strings.NewReader("{\n \"input\": [\n \"file://a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"file://c3d4e5f6-a7b8-9012-cdef-a12345678901\"\n ],\n \"classification_config\": {\n \"categories\": [\n {\n \"name\": \"Invoice\"\n },\n {\n \"name\": \"Receipt\"\n }\n ],\n \"mode\": \"document\"\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://extraction-api.nanonets.com/api/v2/classify/async")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"input\": [\n \"file://a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"file://c3d4e5f6-a7b8-9012-cdef-a12345678901\"\n ],\n \"classification_config\": {\n \"categories\": [\n {\n \"name\": \"Invoice\"\n },\n {\n \"name\": \"Receipt\"\n }\n ],\n \"mode\": \"document\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://extraction-api.nanonets.com/api/v2/classify/async")
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 \"input\": [\n \"file://a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"file://c3d4e5f6-a7b8-9012-cdef-a12345678901\"\n ],\n \"classification_config\": {\n \"categories\": [\n {\n \"name\": \"Invoice\"\n },\n {\n \"name\": \"Receipt\"\n }\n ],\n \"mode\": \"document\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"total": 123,
"items": [
{
"input": "<string>",
"record_id": "<string>",
"file_id": "<string>",
"error": "<string>"
}
],
"batch_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
API key as Bearer token: Authorization: Bearer YOUR_API_KEY
Body
application/json
⌘I