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

# Schemas

> The optional schema registry provides convenience defaults for common extraction tasks. You can bypass it entirely by supplying your own schema at request time.

# Schemas

> The only document-specific layer in Docex is the optional built-in schema registry (`apps/worker/src/registry.js`). Users can bypass it entirely by supplying their own `schema` at request time.

## Built-in schemas

The registry includes convenience defaults for common tasks:

| Schema ID                         | Use case                                          |
| --------------------------------- | ------------------------------------------------- |
| `invoice/global-accounts-payable` | Extract vendor, total, line items, due date       |
| `trade-license/uae`               | Extract company name, license number, expiry      |
| `identity/passport`               | Extract full name, document number, date of birth |
| `receipt/retail`                  | Extract merchant, items, total, date              |

## Custom schemas

The biggest unlock of the task-agnostic architecture is user-defined schemas. Pass any schema at request time without touching the registry:

```js theme={null}
const result = await docex.run({
  file: "suspicious-email.png",
  prompt: "Analyze this email attachment for phishing indicators",
  schema: {
    label: "Phishing scan",
    expectedFields: [
      "is_phishing",
      "confidence_score",
      "suspicious_elements",
      "recommended_action"
    ],
    promptScaffold: "Analyze this image for security threats and phishing indicators."
  }
});
```

This makes Docex genuinely task-agnostic. The built-in schemas are just convenience defaults.

## Schema ID vs. custom schema

* Use `schemaId` to reference a built-in registry schema
* Use `schema` to provide an inline custom schema
* If neither is provided, the prompt alone drives the analysis (generic vision summary)

## Backward compatibility

The old `docTypeHint` parameter is mapped to `schemaId` internally. Existing code using `docTypeHint` will continue to work.
