> ## Documentation Index
> Fetch the complete documentation index at: https://docs.antei.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Extraction Workers

> Learn how Antei's Workers transform raw integration payloads into structured, mapped data for tax workflows.

<Icon icon="file-code" size={26} color="#4B5563" />

# Extraction Workers

Antei uses Cloudflare Workers to process and transform incoming data from connected integrations. These Workers extract, normalize, and prepare structured records across multiple entity types for downstream validation and reconciliation.

***

## Purpose

The Extraction Workers serve as the first point of transformation after ingestion. Their primary functions include:

* Parsing raw payloads from billing, HRIS, and communication tools
* Flattening nested objects
* Mapping extracted data to Antei’s internal schema
* Attaching metadata and sync context

Each Worker is scoped to a specific integration (e.g., Stripe, QuickBooks) but adheres to a universal extraction standard.

***

## Processing Pipeline

<Steps>
  <Step title="1. Receive Ingested Payload">
    Workers are triggered automatically via background jobs or webhook events. The ingested payload is passed to the Worker.
  </Step>

  <Step title="2. Normalize Raw Data">
    The Worker flattens and standardizes the data structure — transforming provider-specific formats into a common internal format.
  </Step>

  <Step title="3. Map to Core Entity Types">
    The normalized data is mapped to Antei’s entity model: transactions, contacts, invoices, products, etc., with correct field-level mapping.
  </Step>

  <Step title="4. Attach Metadata">
    Each extracted object is tagged with sync metadata such as source, extraction ID, version, and timestamp.
  </Step>

  <Step title="5. Queue for Validation">
    The structured data is pushed to the validation queue for further enrichment, deduplication, and processing.
  </Step>
</Steps>

***

## Supported Entity Types

Antei currently maps and processes the following core entities:

| Entity              | Description                                                                  |
| :------------------ | :--------------------------------------------------------------------------- |
| **Transactions**    | Purchases, refunds, and payments across platforms                            |
| **Products**        | Taxable goods/services with jurisdictional and taxability configurations     |
| **Contacts**        | Unified representation of customers, vendors, tax authorities, and locations |
| **Invoices**        | Billing and compliance documents mapped with product and contact references  |
| **Transaction Ops** | Operational breakdowns such as payment splits, refunds, and adjustments      |

***

## Naming Convention

Each Worker is named by function and integration. Examples:

* `extract-stripe-payment-intent`
* `extract-xero-invoices`
* `extract-outlook-emails`
* `extract-quickbooks-transactions`

All Workers follow a versioned folder-based architecture with shared utility libraries (`/shared/log.js`, `/shared/auth.js`).

***

## Reliability & Security

* **Execution Environment**: Cloudflare Workers
* **Deployment**: CI via Wrangler CLI
* **Logging**: Logs pushed to Xano for audit and error tracking
* **Authentication**: Bearer token verification on every invocation
* **Rate Limiting**: Enforced at the token level for partner-facing endpoints

***

## Error Handling

Each Worker is equipped with:

* Schema validation (during extraction)
* Try-catch wrappers for every field mapping
* Structured error logs with `payload_id`, `error_type`, and `affected_entity`
* Retry logic for transient failures

***

## Output Example

```json theme={null}
{
  "entity_type": "invoice",
  "extracted_id": "abc123",
  "payload_id": "xyz456",
  "mapped_data": {
    "invoice_id": "INV-001",
    "contact_id": "CUST-42",
    "amount": 1200,
    "currency": "USD",
    "tax_rate": 0.18
  },
  "metadata": {
    "source": "stripe_invoice",
    "sync_time": "2025-05-13T10:30:00Z",
    "version": "v1.3"
  }
}
```

***

## Next Steps

* [→ Review Validation Logic](/trust-center/Data%20Flow%20and%20Processing/validation-logic)
* [→ Learn about Field Mapping Framework](/trust-center/Data%20Flow%20and%20Processing/field-mapping-framework)
* [→ View Audit Logging Policy](/trust-center/Security/audit-logs)

***

## Questions

If you have questions about how Extraction Workers function or need support with integration-specific behavior, please contact:
[tech@antei.com](mailto:tech@antei.com)

All Worker activity is logged and traceable from the **Org Settings → Audit Trail** section.
