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

# buyStorage

Buy storage

> **Group:** Storage APIs

Use this when you need: **Buy storage**.

## Usage

```ts theme={"system"}
import { NeynarAPIClient, Configuration } from "@neynar/nodejs-sdk";

const client = new NeynarAPIClient(
  new Configuration({ apiKey: "YOUR_NEYNAR_API_KEY" })
);

const res = await client.buyStorage({
  xWalletId: "example", // Wallet ID to use for transactions
  buyStorageReqBody: { /* request body */ }, // required
});
console.log(res);
```

## Parameters

| Parameter           | Type                | Required | Description                       |
| ------------------- | ------------------- | :------: | --------------------------------- |
| `xWalletId`         | `string`            |     ✅    | Wallet ID to use for transactions |
| `buyStorageReqBody` | `BuyStorageReqBody` |     ✅    | -                                 |

## Response

Returns a `RequestArgs` object.

## Error Handling

```ts theme={"system"}
try {
  const res = await client.buyStorage({
    xWalletId: "example",
    buyStorageReqBody: { /* request body */ }
  });
  // use res
} catch (err) {
  // Axios/HTTP errors, invalid params, auth issues, etc.
  console.error(err);
}
```

## Related API Reference

📖 **API Reference:** [buyStorage](/reference/buy-storage)

For detailed information about the HTTP endpoint, request/response schemas, and additional examples, see the complete API documentation.

## Tips

* Provide a **viewerFid** when supported to respect mutes/blocks and include `viewer_context`.
* Keep requests scoped (e.g., use `limit`) to improve latency.
* Cache results where sensible.


## Related topics

- [SDK v1 to v2 migration guide](/reference/neynar-nodejs-sdk-v1-to-v2-migration-guide.md)
- [Buy storage](/reference/buy-storage.md)
- [Storage Units Allocation](/docs/getting-storage-units-allocation-of-farcaster-user.md)
- [Managing Onchain Wallets](/docs/managing-onchain-wallets.md)
- [Whitepaper](/snapchain/whitepaper.md)
