Skip to main content

Retrieving extraction results

Once a workflow has processed your file, you can retrieve the extraction results using the jobs/:id/ endpoint:
Remember that all API endpoints require a trailing slash (/) and your API key in the x-api-key header.
curl -X GET "https://api.anyformat.ai/jobs/123/" \
     -H "x-api-key: YOUR_API_KEY"

Response format

{
  "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_number": {
      "value": "INV-001",
      "confidence": 95,
      "evidence": [{"text": "Invoice #INV-001", "page_number": 1}]
    },
    "total_amount": {
      "value": "1250.00", 
      "confidence": 88,
      "evidence": [{"text": "Total: $1,250.00", "page_number": 1}]
    },
    "line_items": [
      {
        "description": {
          "value": "Consulting Services",
          "confidence": 92,
          "evidence": [{"text": "Consulting Services", "page_number": 1}]
        },
        "amount": {
          "value": "1250.00",
          "confidence": 90,
          "evidence": [{"text": "$1,250.00", "page_number": 1}]
        }
      }
    ]
  }
}
For additional response formatting options including as_lists=true for consistent field formatting, see the Response Formats Guide.

Job status values

The status field in the response can be one of:
  • pending: Job is queued for processing.
  • in_progress: Job is being processed.
  • processed: Processing finished successfully.
  • error: Processing encountered an error.
The results of the job will only be available when the job status is processed. In any other case, the results object will be empty.

Retrieving extractions results for a given workflow

Workflow Results Endpoint

To retrieve the results of all the extractions for a specific workflow, you can use the workflows/:id/results/ endpoint. This endpoint will return the extractions results for all the jobs of a given workflow.
curl -X GET "https://api.anyformat.ai/workflows/8/results/?output_format=csv&file__last_processed_at__gte=2024-12-20" \
     -H "x-api-key: YOUR_API_KEY"

Workflow results query parameters

Notice in the examples above that the output_format parameter is used to specify the format of the response. The default format is CSV, but you can also request JSON or JSON lines format.

Response formatting examples

# CSV (default)
curl -X GET "https://api.anyformat.ai/workflows/8/results/" \
     -H "x-api-key: YOUR_API_KEY"

# JSON format
curl -X GET "https://api.anyformat.ai/workflows/8/results/?output_format=json" \
     -H "x-api-key: YOUR_API_KEY"

# JSON format with consistent field formatting
curl -X GET "https://api.anyformat.ai/workflows/8/results/?output_format=json&as_lists=true" \
     -H "x-api-key: YOUR_API_KEY"

# JSON Lines format
curl -X GET "https://api.anyformat.ai/workflows/8/results/?output_format=jsonl" \
     -H "x-api-key: YOUR_API_KEY"

Response Format Options

ParameterDescriptionNotes
output_format=csvCSV format (default)Tabular data, good for spreadsheet import
output_format=jsonJSON formatStructured data with full metadata
output_format=jsonlJSON Lines formatOne JSON object per line
as_lists=trueConsistent field formattingOnly works with output_format=json, transforms extracted data fields to consistent list format
Note: The as_lists parameter only affects JSON format responses. It’s ignored for CSV and JSONL formats. JSON with as_lists=true example:
curl -X GET "https://api.anyformat.ai/workflows/8/results/?output_format=json&as_lists=true" \
     -H "x-api-key: YOUR_API_KEY"
This transforms extracted data fields to consistent list format:
{
  "file_name.pdf": {
    "file_name": "file_name.pdf",
    "status": "processed",
    "results": {
      "field_name": [{
        "id": 123,
        "value": "extracted_value",
        "confidence": 95,
        "evidence": [{"page_number": 1}],
        "verification_status": "not_verified",
        "value_unit": null
      }],
      "another_field": [
        {
          "id": 124,
          "value": "item1: 100",
          "confidence": 92,
          "evidence": [{"page_number": 1}],
          "verification_status": "not_verified",
          "value_unit": null
        },
        {
          "id": 125,
          "value": "item2: 200",
          "confidence": 90,
          "evidence": [{"page_number": 1}],
          "verification_status": "not_verified",
          "value_unit": null
        }
      ],
      "empty_field": []
    }
  }
}
For more details about response formats, see the Response Formats Guide.

Query Parameters

Similarly to the output_format parameter, this endpoint supports a number of filters that you can use to retrieve the results you are interested in. These can all be combined using the & operator, so you can retrieve more specific results:

File name filters

ParameterDescription
file__name__iexactExact file name match (case-insensitive)
file__name__icontainsFile name contains (case-insensitive)
file__name__not_icontainsFile name does not contain (case-insensitive)
file__name__not_iexactFile name does not match exactly (case-insensitive)
file__name__istartswithFile name starts with (case-insensitive)
file__name__iendswithFile name ends with (case-insensitive)
# Get results for files containing "invoice"
curl -X GET "https://api.anyformat.ai/workflows/8/results/?file__name__icontains=invoice" \
     -H "x-api-key: YOUR_API_KEY"

# Get results for exact file name
curl -X GET "https://api.anyformat.ai/workflows/8/results/?file__name__iexact=invoice-2024-03.pdf" \
     -H "x-api-key: YOUR_API_KEY"

File upload date filters

ParameterDescription
file__created_atExact file creation date match
file__created_at__gtFile created after this date
file__created_at__ltFile created before this date
file__created_at__gteFile created on or after this date
file__created_at__lteFile created on or before this date

Processing time filters

ParameterDescriptionFormat
file__last_processed_atLast processing dateISO 8601 datetime
file__last_processed_at__gtLast processed after dateISO 8601 datetime
file__last_processed_at__ltLast processed before dateISO 8601 datetime
file__last_processed_at__gteLast processed on or after dateISO 8601 datetime
file__last_processed_at__lteLast processed on or before dateISO 8601 datetime
# Get results from files processed after December 20, 2024
curl -X GET "https://api.anyformat.ai/workflows/8/results/?file__last_processed_at__gte=2024-12-20" \
     -H "x-api-key: YOUR_API_KEY"

# Get results from files processed in a specific time window
curl -X GET "https://api.anyformat.ai/workflows/8/results/?file__last_processed_at__gte=2024-03-01&file__last_processed_at__lt=2024-04-01" \
     -H "x-api-key: YOUR_API_KEY"

Error Handling

The API uses structured error responses to help you handle different types of errors. All error responses include:
  • error: Human-readable error description
  • detail: Detailed explanation of what went wrong
  • error_code: Machine-readable error code for programmatic handling
For complete error handling information, see the Error Handling Guide.