Skip to main content

Response Formats

The Anyformat API supports multiple response formats to accommodate different use cases and integration patterns.

Standard Paginated Format

By default, endpoints that return multiple items (like workflows or jobs) use paginated responses with metadata:
{
  "count": 25,
  "total_pages": 3,
  "next": "https://api.anyformat.ai/workflows/?page=2",
  "previous": null,
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Invoice Data Extraction",
      "description": "Extracts invoice number, date, total amount, vendor details, and line items from PDF invoices",
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-20T14:22:00Z"
    },
    {
      "id": "550e8400-e29b-41d4-a716-446655440001", 
      "name": "Receipt Processing",
      "description": "Captures merchant name, transaction date, total amount, payment method, and itemized purchases from receipts",
      "created_at": "2024-01-12T09:15:00Z",
      "updated_at": "2024-01-18T16:45:00Z"
    }
  ]
}
This format includes:
  • count: Total number of items across all pages
  • total_pages: Number of pages available
  • next: URL for the next page (null if last page)
  • previous: URL for the previous page (null if first page)
  • results: Array of actual data items

Consistent Data Formatting with as_lists=true

The as_lists=true parameter provides consistent data formatting for extracted fields, making client automation easier. This parameter:
  • Only affects extraction results that contain extracted data fields
  • Transforms extracted data fields to consistent list format
  • Only affects JSON responses (ignores CSV/JSONL)
  • Makes client processing predictable and easier to automate

For Job Results

Similar transformation applies to job endpoint results: Standard Response:
{
  "id": "362963",
  "status": "processed",
  "workflow_id": "550e8400-e29b-41d4-a716-446655440000",
  "processed_at": "2024-01-15T10:30:00Z",
  "created_at": "2024-01-15T09:45:00Z",
  "updated_at": "2024-01-15T10:30:00Z",
  "results": {
    "invoice_id": {
      "value": "13152556",
      "evidence": [{"text": "Invoice #13152556", "page_number": 1}],
      "confidence": 95
    },
    "vendor_name": {
      "value": "Association for Computing Machinery",
      "evidence": [{"text": "ACM Digital Library", "page_number": 1}],
      "confidence": 92
    },
    "client": [
      {
        "name": {
          "value": "Bryan Java",
          "evidence": [{"text": "Bill To: Bryan Java", "page_number": 1}],
          "confidence": 98
        },
        "id": {
          "value": "ID-001",
          "evidence": [{"text": "Customer ID: ID-001", "page_number": 1}],
          "confidence": 87
        }
      }
    ],
    "total_amount": {
      "value": 124.0,
      "value_unit": "USD",
      "evidence": [{"text": "Total: $124.00", "page_number": 1}],
      "confidence": 99
    }
  }
}
With as_lists=true formatting:
{
  "id": "362963",
  "status": "processed",
  "workflow_id": "550e8400-e29b-41d4-a716-446655440000",
  "processed_at": "2024-01-15T10:30:00Z",
  "created_at": "2024-01-15T09:45:00Z",
  "updated_at": "2024-01-15T10:30:00Z",
  "results": {
    "invoice_id": [
      {
        "value": "13152556",
        "evidence": [{"text": "Invoice #13152556", "page_number": 1}],
        "confidence": 95
      }
    ],
    "vendor_name": [
      {
        "value": "Association for Computing Machinery",
        "evidence": [{"text": "ACM Digital Library", "page_number": 1}],
        "confidence": 92
      }
    ],
    "client": [
      {
        "name": {
          "value": "Bakary Camara",
          "evidence": [{"text": "Bill To: Bakary Camara", "page_number": 1}],
          "confidence": 98
        },
        "id": {
          "value": "BCM-001",
          "evidence": [{"text": "Customer ID: BCM-001", "page_number": 1}],
          "confidence": 87
        }
      }
    ],
    "total_amount": [
      {
        "value": 124.0,
        "value_unit": "USD",
        "evidence": [{"text": "Total: $124.00", "page_number": 1}],
        "confidence": 99
      }
    ]
  }
}
Notice how:
  • Metadata fields (id, status, workflow_id) are preserved unchanged
  • Existing arrays like client remain unchanged
  • Single objects like invoice_id, vendor_name, and total_amount are wrapped in arrays for consistency

When to Use Each Format

Standard Format is recommended for most use cases. It provides the most natural and compact response structure. List Format (as_lists=true) is useful when you need all extracted data fields to have consistent array formatting, regardless of whether they naturally contain single values or multiple values. This is useful when building automated data processing pipelines, especially if you need consistent field formatting across all extractions.

Supported Endpoints

The as_lists=true parameter only affects these endpoints that return extraction results:

Extraction Results Endpoints

  • GET /workflows/{id}/results/?output_format=json&as_lists=true - Transform workflow extraction results
  • GET /jobs/{id}/?as_lists=true - Transform job results that contain extracted data

Endpoints Where as_lists=true Has No Effect

  • GET /workflows/ - Workflow lists (no extracted data)
  • GET /workflows/{id}/ - Single workflow details (no extracted data)
  • GET /jobs/ - Job lists (no extracted data)
  • Any endpoint returning only metadata without extracted data fields