Skip to main content

Overview

All Aifano processing endpoints return structured JSON with a consistent format. The core building blocks are chunks (logical sections of content) and blocks (individual elements like text, tables, and figures).

Parse Response

{
  "job_id": "job_abc123",
  "duration": 2.34,
  "usage": {
    "num_pages": 5,
    "credits": 5
  },
  "result": {
    "type": "full",
    "chunks": [
      {
        "content": "# Introduction\n\nThis document covers...",
        "embed": "Introduction. This document covers...",
        "blocks": [
          {
            "type": "Title",
            "content": "Introduction",
            "bbox": { "left": 0.1, "top": 0.05, "width": 0.8, "height": 0.04, "page": 1 }
          },
          {
            "type": "Text",
            "content": "This document covers...",
            "bbox": { "left": 0.1, "top": 0.1, "width": 0.8, "height": 0.06, "page": 1 }
          }
        ]
      }
    ]
  }
}

Top-Level Fields

FieldTypeDescription
job_idstringUnique identifier for this processing job
durationnumberProcessing time in seconds
usageobjectCredit and page usage information
resultobjectThe processing result containing chunks

Chunks

Chunks are logical sections of the document. Each chunk contains:
FieldTypeDescription
contentstringMarkdown-formatted content of the section
embedstringEmbedding-optimized plain text (ideal for RAG)
blocksarrayIndividual elements with bounding boxes

Blocks

Blocks are the atomic elements within a chunk. Each block has:
FieldTypeDescription
typestringThe block type (see table below)
contentstringThe text or data content
bboxobjectBounding box coordinates

Block Types

TypeDescription
TitleDocument or section title
Section HeaderSub-section heading
TextBody text paragraph
TableTabular data (Markdown format)
FigureImage or chart
List ItemBulleted or numbered list item
HeaderPage header
FooterPage footer
Page NumberPage number
Key ValueKey-value pair
CommentAnnotation or comment
SignatureSignature block

Bounding Boxes

All coordinates are normalized (0.0 to 1.0) relative to the page dimensions:
{
  "left": 0.1,
  "top": 0.05,
  "width": 0.8,
  "height": 0.04,
  "page": 1
}
FieldTypeDescription
leftnumberLeft edge (0.0 = left margin, 1.0 = right margin)
topnumberTop edge (0.0 = top, 1.0 = bottom)
widthnumberWidth as fraction of page width
heightnumberHeight as fraction of page height
pageinteger1-based page number

Usage Object

{
  "num_pages": 5,
  "credits": 5
}
FieldTypeDescription
num_pagesintegerNumber of pages processed
creditsintegerCredits consumed for this operation

Extract Response

Extract responses include the parsed data plus extracted fields:
{
  "job_id": "job_ext456",
  "duration": 3.21,
  "usage": { "num_pages": 2, "credits": 4 },
  "result": {
    "invoice_number": "INV-2024-001",
    "date": "2024-01-15",
    "total_amount": 1250.00,
    "line_items": [
      { "description": "Consulting", "quantity": 10, "unit_price": 125.00 }
    ]
  }
}
The result matches the JSON schema you provided in the request.

Split Response

Split responses contain an array of categorized sections:
{
  "job_id": "job_split789",
  "duration": 5.12,
  "usage": { "num_pages": 25, "credits": 25 },
  "result": [
    {
      "category": "Cover Letter",
      "page_range": { "start": 1, "end": 2 },
      "content": "Dear Client,\n\nPlease find enclosed..."
    }
  ]
}

Edit Response

Edit responses return a download URL for the modified document:
{
  "document_url": "https://platform.aifano.com/download/edited.pdf?token=...",
  "form_schema": [...],
  "usage": { "num_pages": 2, "credits": 8 }
}