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

# Built-in Schemas

> Pre-defined schemas for common document types

The `@doclo/schemas` package includes pre-built schemas for common document types that you can use directly or extend.

## Installation

```bash theme={null}
pnpm add @doclo/schemas
```

## Available Schemas

### Bunker Delivery Note (BDN)

The BDN schema extracts comprehensive data from maritime fuel delivery notes.

```typescript theme={null}
import { bdnSchema, BDNData } from '@doclo/schemas';
import { createFlow, extract } from '@doclo/flows';

const flow = createFlow()
  .step('extract', extract<BDNData>({
    provider: vlmProvider,
    schema: bdnSchema
  }))
  .build();

const result = await flow.run({ base64: bdnDocument });
// result.output is typed as BDNData
```

#### BDN Schema Fields

| Section   | Fields                                                                                                                    |
| --------- | ------------------------------------------------------------------------------------------------------------------------- |
| Reference | `refNumber`                                                                                                               |
| Supplier  | `supplierName`, `supplierLegalName`, `supplierLicenseNumber`, `supplierAddress`, `supplierPhoneNumber1`, `supplierEmail1` |
| Vessels   | `receivingVessel.vesselName`, `receivingVessel.imoNumber`, `deliveringBarge.bargeName`                                    |
| Bunkering | `deliveredQuantityMT`, `deliveryDate`, `port`, `anchorage`                                                                |
| Product   | `productName`, `productGrade`, `sulphurContent`                                                                           |

#### Using BDN Schema from Registry

```typescript theme={null}
import { getSchemaByRef } from '@doclo/schemas';

const schema = getSchemaByRef('bdn@1.0.0');

const flow = createFlow()
  .step('extract', extract({
    provider: vlmProvider,
    schema: { ref: 'bdn@1.0.0' }  // Reference by ID
  }))
  .build();
```

## Schema Registry

Built-in schemas are automatically registered when you import `@doclo/schemas`. Access them using the registry functions:

```typescript theme={null}
import {
  getSchema,
  getSchemaByRef,
  getLatestSchema,
  SCHEMA_REGISTRY
} from '@doclo/schemas';

// Get specific version
const v1 = getSchemaByRef('bdn@1.0.0');

// Get latest version of a schema
const latest = getLatestSchema('bdn');

// Check available schemas
console.log(SCHEMA_REGISTRY.listSchemas());
```

## Extending Built-in Schemas

Add custom fields to built-in schemas:

```typescript theme={null}
import { bdnSchema } from '@doclo/schemas';

const extendedBdnSchema = {
  ...bdnSchema,
  properties: {
    ...bdnSchema.properties,
    customField: {
      type: 'string',
      description: 'My custom field'
    }
  }
};
```

## Creating Custom Schemas

See [Defining Schemas](/sdk/schemas/defining-schemas) for how to create your own schemas for document types like invoices, receipts, contracts, and more.

## Next Steps

<CardGroup cols={2}>
  <Card title="Defining Schemas" icon="code" href="/sdk/schemas/defining-schemas">
    Create custom schemas
  </Card>

  <Card title="Extract Node" icon="database" href="/sdk/nodes/extract">
    Use schemas with extraction
  </Card>
</CardGroup>
