Skip to main content

Process a file

To extract data from a file, you can either:
  1. Upload a file directly
  2. Or send text content for processing

File Upload

Send a POST request to /workflows/:id/run/ with the file or text content as multipart/form-data:
curl -X POST 'https://api.anyformat.ai/workflows/123/run/' \
-H 'x-api-key: YOUR_API_KEY' \
-F 'file=@/path/to/your/document.pdf'
As data extraction is not an instantaneous process, the response will include an ID that you can use to check the extraction status.
{
  "status": "success",     // File upload successful
  "extraction_id": "222",  // Use this ID to check results    
  "workflow_id": "123"     // The workflow used for extraction
}
The API returns a 202 Accepted response code, indicating that the processing request has been accepted but the extraction is not yet complete.

Text processing

To process text directly, send a POST request with the text as multipart/form-data:
curl -X POST 'https://api.anyformat.ai/workflows/123/run/' \
-H 'x-api-key: YOUR_API_KEY' \
-F 'text=the customer is called John McCain and is 27 years old. He bought a motorcycle from Kawazaki.'

Requirements for file / text upload

  • The file must be sent as multipart/form-data.
  • The file field name must be file.
  • Only one file can be processed per request. If both file and text are provided, only the file will be processed.
  • The file must be a binary file. URLs and base64 encoded strings are not supported.
Refer to Obtaining Data Extraction Results to learn how to retrieve the extracted data.