Skip to main content
Install the Python SDK: pip install anyformat. See SDKs for all available SDKs.

Get Your API Key

First, you’ll need an API key to authenticate your requests:
  1. Sign up or log in to anyformat
  2. Navigate to the API Key page
  3. Generate a new API key
  4. Keep your API key secure - you’ll use it in the Authorization: Bearer header

Create Your First Workflow

A workflow defines what data to extract from your documents.
We recommend creating workflows in the anyformat platform where you can visually configure fields and test with sample documents. Once your workflow is ready, copy its ID and skip to Process a Document. The API example below is provided for reference.
Let’s create a simple invoice processing workflow:
curl -X POST 'https://api.anyformat.ai/v2/workflows/' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -d '{
    "name": "Invoice Processing",
    "description": "Extract key data from invoices",
    "fields": [
      {
        "name": "invoice_number",
        "description": "The unique invoice identifier",
        "data_type": "string"
      },
      {
        "name": "total_amount",
        "description": "Total invoice amount",
        "data_type": "float"
      },
      {
        "name": "issue_date",
        "description": "Date when the invoice was issued",
        "data_type": "date"
      }
    ]
  }'

List Your Workflows

You can retrieve your workflows in the standard paginated format:
# Get paginated response with metadata
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://api.anyformat.ai/v2/workflows/"

Process a Document

Upload a document to extract data using your workflow:
curl -X POST 'https://api.anyformat.ai/v2/workflows/YOUR_WORKFLOW_ID/run/' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -F 'file=@invoice.pdf'
The response returns a file UUID:
{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "status": "accepted",
  "workflow_id": "550e8400-e29b-41d4-a716-446655440000"
}

Get Results

Poll for results using the file id from the previous step. The endpoint returns 412 while processing and 200 when results are ready:
# Returns 412 while processing, 200 when done
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://api.anyformat.ai/v2/files/FILE_ID/extraction/"
For production integrations, use webhooks instead of polling. Webhooks deliver results immediately without consuming your rate limit.

Handle Errors Gracefully

The API provides structured error responses to help you handle different scenarios:
import anyformat
from anyformat import Anyformat

client = Anyformat()

try:
    workflows = client.workflows.list()
    print(workflows.results)
except anyformat.AuthenticationError:
    print("Check your API key")
except anyformat.NotFoundError as e:
    print(f"Resource not found: {e.message}")
except anyformat.BadRequestError as e:
    print(f"Validation error: {e.message}")
except anyformat.RateLimitError:
    print("Rate limited, back off")
except anyformat.APIStatusError as e:
    print(f"API error ({e.status_code}): {e.message}")
except anyformat.APIConnectionError:
    print("Could not reach the server")

Next Steps

Now that you’ve completed the quickstart, explore the API Reference for detailed documentation:

Response Formats

Learn about response format options for workflow results

Error Handling

Implement robust error handling with structured error codes

Field Types

Define fields with objects, enums, and more

Run Workflow

Process files and text content

Key Concepts to Remember

  • Always include trailing slashes in your API endpoints (/v2/workflows/ not /v2/workflows)
  • Use Authorization: Bearer for authentication
  • Check HTTP status codes before parsing responses
  • Handle errors using error_code for programmatic error handling
  • Poll /v2/files/{id}/extraction/ — returns 412 while processing, 200 when complete
  • Prefer webhooks over polling for production integrations
For detailed response format examples, see the Response Formats documentation.