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

# Item added

> Hook triggered when an item is added to an inventory.

Triggered when an item is added to an inventory. Register with [`registerHook`](/jaksam-inventory/hooks#register-a-hook) using the event name `onItemAdded`.

### Payload

| Field         | Data Type    | Description                |
| ------------- | ------------ | -------------------------- |
| `inventoryId` | string       | e.g. `"player:1"`          |
| `itemName`    | string       | e.g. `"bread"`             |
| `amount`      | number       | Amount added               |
| `metadata`    | table \| nil | Item metadata, can be nil  |
| `slotId`      | number       | Slot the item was added to |

### Examples

<AccordionGroup>
  <Accordion title="One backpack per player">
    ```lua theme={null}
    exports['jaksam_inventory']:registerHook("onItemAdded", function(payload)
        local backpackCount = exports["jaksam_inventory"]:getTotalItemAmount(payload.inventoryId, "backpack")
        if backpackCount >= 1 then
            return false, "You can only have one backpack"
        end
    end, {
        itemNameFilter = {backpack = true},
        inventoryTypeFilter = {player = true}
    })
    ```
  </Accordion>

  <Accordion title="Filter by specific inventory name">
    ```lua theme={null}
    -- Only trigger when items are added to police stash
    exports['jaksam_inventory']:registerHook("onItemAdded", function(payload)
        print("Item added to police stash:", payload.itemName)
    end, {
        inventoryFilter = {"stash_police"}
    })
    ```
  </Accordion>
</AccordionGroup>

See [Hooks overview](/jaksam-inventory/hooks) for the `registerHook` API, available filters, and return-value behavior.


## Related topics

- [Inventory item added](/jaksam-inventory/events/server/on-inventory-item-added.md)
- [Server](/jaksam-inventory/events/server/index.md)
- [Hooks](/jaksam-inventory/hooks/index.md)
- [Installation](/doors-creator/installation.md)
- [Item processed](/jobs-creator/server/process/item-processed.md)
