Create scan

Takes a receipt or invoice as RAW BYTES — a PDF, an image or plain text, uploaded under its own content type, not wrapped in JSON — extracts what the document says, resolves the vendor's expense category, and answers a DRAFT carrying a balanced voucher proposed for it.

POST /v1/books/scan

Addresshttps://api.hanzo.ai/v1/books/scan
MethodPOST
Operationpost_books_scan
AuthAuthorization: Bearer $HANZO_API_KEY

Takes a receipt or invoice as RAW BYTES — a PDF, an image or plain text, uploaded under its own content type, not wrapped in JSON — extracts what the document says, resolves the vendor's expense category, and answers a DRAFT carrying a balanced voucher proposed for it.

NOTHING IS POSTED. That split is the whole design: the model only ever produces a structured reading of the document, the voucher is assembled deterministically in Go from that reading, and the ledger is written only by the separate book call a human confirms. So a misread scan can propose a wrong draft; it cannot move money. Amounts are exact integer cents end to end — the extraction returns cents, never a decimal — so no rounding enters the ledger.

The draft's id is the FILE HASH, and that is what makes booking idempotent: re-scanning the same bytes addresses the same draft rather than queuing a second one. A row is written to the org's document inbox as a side effect, moving it from unsorted to draft. Scoped to the caller's own org from the validated principal and refused without one; sandbox=true targets the sandbox ledger, and filename is recorded for the inbox. An empty or oversized upload is a 400, and a deployment with no scanner model answers 501.

Request

1 field, body application/octet-stream.

FieldInTypeRequiredDescription
(body)bodystring (binary)yes

Response

StatusBodyMeaning
2XXScanDraftSuccess

2XX body — 32 fields.

FieldInTypeAlwaysDescription
balancedbodyboolean—
categorybodystring—
confidencebodystring—
extractedbodyExtracted—
extracted.categorybodystring—
extracted.currencybodystring—
extracted.issuedAtbodystring—
extracted.lineItemsbodyLineItem[]—
extracted.lineItems[].amountCentsbodyinteger—
extracted.lineItems[].descriptionbodystring—
extracted.merchantbodystring—
extracted.notebodystring—
extracted.taxCentsbodyinteger—
extracted.totalCentsbodyinteger—
questionsbodyQuestion[]—
questions[].accountbodystring—
questions[].amountbodystring—
questions[].idbodystring—
questions[].kindbodystring—
questions[].postedAtbodystring—
questions[].textbodystring—
scanIdbodystring—
vendorbodystring—
voucherbodyVoucher—
voucher.descriptionbodystring—
voucher.legsbodyLeg[]—
voucher.legs[].accountbodystring—
voucher.legs[].creditbodyinteger—
voucher.legs[].debitbodyinteger—
voucher.postingAtbodystring—
voucher.sourceIdbodystring—
voucher.sourceKindbodystring—

Failure carries the platform error shape — see Errors.

Examples

hanzo books scan create
import { Configuration, BooksApi } from 'hanzoai';

const api = new BooksApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postBooksScan();
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import BooksApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = BooksApi(client).post_books_scan()
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.BooksAPI.PostBooksScan(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, books_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = books_api::post_books_scan(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.BooksApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new BooksApi(client).postBooksScan();
curl -X POST https://api.hanzo.ai/v1/books/scan \
  -H "Authorization: Bearer $HANZO_API_KEY"

MCP reaches books through the books tool, which names its 20 operations with its own verbs — this one among them, under a name only MCP declares. describe explains any of them:

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_book_accounts"
         }
       }
     }'

Books API · All Hanzo APIs · Interactive reference

Was this page useful?