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

# Create Documents

> Create new documents with the store method

## store

Store documents in a collection with payment.

```typescript TypeScript theme={null}
const result = await client.store(
  {
    collection: 'users',
    data: [{ email: 'alice@example.com', name: 'Alice', active: true }]
  },
  async (quote) => {
    // quote contains: totalCost, brokerAddress, tokenSymbol, network, chainType
    const txHash = await processPayment(quote);
    return { txHash, network: quote.network, sender: walletAddress, chainType: quote.chainType, paymentMethod: 'native' };
  },
  true // waitForConfirmation
);

console.log('Stored at block:', result.block_height);
```

## Parameters

| Parameter             | Type           | Description                                               |
| --------------------- | -------------- | --------------------------------------------------------- |
| `request`             | `StoreRequest` | Collection name and data array                            |
| `paymentCallback`     | `function`     | Callback that receives a quote and returns payment result |
| `waitForConfirmation` | `boolean`      | Whether to wait for confirmation                          |

## Bulk Creation

Store multiple documents at once:

```typescript TypeScript theme={null}
const result = await client.store(
  {
    collection: 'users',
    data: [
      { email: 'alice@example.com', name: 'Alice' },
      { email: 'bob@example.com', name: 'Bob' },
      { email: 'charlie@example.com', name: 'Charlie' }
    ]
  },
  async (quote) => {
    const txHash = await processPayment(quote);
    return { txHash, network: quote.network, sender: walletAddress, chainType: quote.chainType, paymentMethod: 'native' };
  },
  true
);

console.log('Stored at block:', result.block_height);
```

## Error Handling

```typescript TypeScript theme={null}
import { ValidationError, OnDBError } from '@ondb/sdk';

try {
  await client.store(
    { collection: 'users', data: [{ email: 'alice@example.com' }] },
    paymentCallback,
    true
  );
} catch (error) {
  if (error instanceof ValidationError) {
    console.log('Validation failed:', error.message);
  } else if (error instanceof OnDBError) {
    console.log('OnDB error:', error.code);
  }
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Read" icon="book-open" href="/crud/read">
    Find and query documents
  </Card>

  <Card title="Update" icon="pen" href="/crud/update">
    Update existing documents
  </Card>
</CardGroup>
