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

# Item

> Reference for Item and ServerItem types for managing quantifiable resources.

Items represent quantifiable resources in your application, such as credits, API calls, storage quotas, or subscription allowances. They can be associated with users, teams, or custom customers and are managed through Hexclave's payment system.On this page:- [Item](#item)
- [ServerItem](#serveritem)***# `Item`The `Item` type represents a quantifiable resource that can be consumed or managed within your application. Items are typically obtained through purchases, subscriptions, or manual allocation.Items can be retrieved through:- [`user.getItem()`](https://docs.hexclave.com/sdk/types/user#currentusergetitem)
- [`user.useItem()`](https://docs.hexclave.com/sdk/types/user#currentuseruseitem) (React hook)
- [`team.getItem()`](https://docs.hexclave.com/sdk/types/team#teamgetitem)
- [`team.useItem()`](https://docs.hexclave.com/sdk/types/team#teamuseitem) (React hook)## Table of ContentsItem Table of Contents<pre />## Properties

\<details>

\<summary>`item.displayName`
          
            
            item</summary>

      

The human-readable name of the item as configured in your Hexclave project settings.

Type Definition

\`typescript declare const displayName: string; `

\</details>



\<details>

\<summary>`item.quantity`
          
            
            item</summary>

      

The current quantity. This value can be negative, which is useful for tracking overdrafts or pending charges.

Type Definition

\`typescript declare const quantity: number; `

\</details>



\<details>

\<summary>`item.nonNegativeQuantity`
          
            
            item</summary>

      

The quantity clamped to a minimum of 0. Equivalent to `Math.max(0, quantity)`. Useful for display purposes when you don't want to show negative values to users.

Type Definition

\`typescript declare const nonNegativeQuantity: number; `

\</details>

***# `ServerItem`The `ServerItem` type extends `Item` with additional server-side methods for modifying quantities. This type is only available in server-side contexts and provides race-condition-safe operations for managing item quantities.Server items can be retrieved through:- [`serverUser.getItem()`](https://docs.hexclave.com/sdk/types/user#serverusergetitem)
- [`serverUser.useItem()`](https://docs.hexclave.com/sdk/types/user#serveruseruseitem) (React hook)
- [`serverTeam.getItem()`](https://docs.hexclave.com/sdk/types/team#serverteamgetitem)
- [`serverTeam.useItem()`](https://docs.hexclave.com/sdk/types/team#serverteamuseitem) (React hook)## Table of ContentsServerItem Table of Contents<pre />## Methods

\<details>

\<summary>`serverItem.increaseQuantity(amount)`
          
            
            serverItem</summary>

      

Increases the item quantity by the specified amount. This operation is atomic and safe for concurrent use.

Parameters

\**amount** `number`

The amount to increase the quantity by. Must be a positive number.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function increaseQuantity(amount: number): Promise<void>;
\```

Examples

\```typescript theme={null}
const user = await hexclaveServerApp.getUser({ userId: "user_123" });
const credits = await user.getItem("credits");

await credits.increaseQuantity(100);
\```

\</details>



\<details>

\<summary>`serverItem.decreaseQuantity(amount)`
          
            
            serverItem</summary>

      

Decreases the item quantity by the specified amount. This operation allows the quantity to go negative.

If you want to prevent the quantity from going below zero, use [`tryDecreaseQuantity()`](#serveritemtrydecreasequantity) instead.

Parameters

\**amount** `number`

The amount to decrease the quantity by. Must be a positive number.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function decreaseQuantity(amount: number): Promise<void>;
\```

Examples

\```typescript theme={null}
const user = await hexclaveServerApp.getUser({ userId: "user_123" });
const credits = await user.getItem("credits");

await credits.decreaseQuantity(50);
\```

\</details>



\<details>

\<summary>`serverItem.tryDecreaseQuantity(amount)`
          
            
            serverItem</summary>

      

Attempts to decrease the item quantity by the specified amount, but only if the result would be non-negative. Returns `true` if the operation succeeded, `false` if it would result in a negative quantity.

This method is race-condition-safe and is ideal for implementing prepaid credit systems where you need to ensure sufficient balance before allowing an operation.

Parameters

\**amount** `number`

The amount to decrease the quantity by. Must be a positive number.

Returns

\`Promise<boolean>`

\`true` if the quantity was successfully decreased, `false` if the operation would result in a negative quantity.

Signature

\```typescript theme={null}
declare function tryDecreaseQuantity(amount: number): Promise<boolean>;
\```

Examples

\```typescript theme={null}
const user = await hexclaveServerApp.getUser({ userId: "user_123" });
const credits = await user.getItem("credits");

const success = await credits.tryDecreaseQuantity(50);

if (success) {
  console.log("Credits consumed successfully");
} else {
  console.log("Insufficient credits");
  throw new Error("Not enough credits available");
}
\```

\</details>

> [!TIP]
>
> The `tryDecreaseQuantity()` method is particularly valuable for prepaid credit
> systems where operations require sufficient balance verification before
> proceeding.
