> For the complete documentation index, see [llms.txt](https://docs.northscripts.dev/site/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.northscripts.dev/site/documentation/resources/ox-inventory-rework/developer-api.md).

# Developer API

Every upstream ox\_inventory export still works. See the [official docs](https://overextended.dev/ox_inventory). These are the ones added by the rework.

#### Server

```lua
-- Create a clothing item for a player
local ok, response = exports.ox_inventory:CreateClothingItem(playerId, 'torso', 15, 0, { label = 'Leather jacket' })
-- returns false, 'clothing_disabled' when Config.Clothing.Enabled = false

-- Move the whole player inventory into a drop at their feet
local dropId = exports.ox_inventory:CreateDropFromPlayer(playerId)

-- Get the ground inventory near the player, or create one
local inv = exports.ox_inventory:GetOrCreateGroundInventory(source, GetPlayerPed(source), coords?)

-- The equipped backpack, or the box being carried
local backpack = exports.ox_inventory:GetEquippedBackpack(source)

-- Clear items but keep worn clothing and the backpack
exports.ox_inventory:ClearInventoryItems(inv)
```

#### Client

```lua
exports.ox_inventory:placeItem(itemName, slot)
exports.ox_inventory:throwItem(itemName, slot)

-- Placement tool for your own scripts
exports.ox_inventory:startFreePlacement(itemName, slot, modelOverride, {
    requireFlat = true,
    onConfirm = function(coords, rotation) end,
    onCancel = function() end,
})

exports.ox_inventory:suppressItemNotifications(true) -- hide the add/remove popups
local injuries = exports.ox_inventory:getInjuries()
exports.ox_inventory:clearInjuries()                -- e.g. from your ambulance job
```

#### Hooks

The 7 upstream hooks are unchanged (`openInventory`, `usingItem`, `swapItems`, `craftItem`, `createItem`, `openShop`, `buyItem`). `swapItems` adds two cases:

* `action = 'give'` when an item is handed to another player;
* `toInventory = 'newdrop'` (with `dropId`) when an item is dropped on the ground.

#### State bags

| Key                         | Content                                    |
| --------------------------- | ------------------------------------------ |
| `Player(id).state.injuries` | Current injuries                           |
| `Player(id).state.instance` | Routing bucket used to show and hide drops |

***

### 9. Discord logs

Every inventory log is also sent to Discord. It is set in `Config.Logs`:

```lua
Config.Logs = {
    Enabled = true,
    Events = {
        giveItem   = '',    -- player → player
        swapSlots  = '',    -- moved between inventories
        addItem    = '',    -- added by a script
        removeItem = '',    -- removed by a script
        buyItem    = '',    -- shop purchase
        craftItem  = '',    -- crafted
        createDrop = '',    -- ground drop
        placeItem  = '',    -- placed in the world
        placeSafe  = '',    -- safe placed
        throwItem  = '',    -- thrown
        admin      = '',    -- admin commands
        exploit    = '',    -- blocked cheat attempts
    },
    Webhook = '',           -- fallback channel for events left empty
    Default = false,        -- send unknown events to the fallback?
    Username = 'Inventory',
    Avatar = 'https://...',
    Colors = { default = 3447003, admin = 15844367, exploit = 15158332 },
    FlushInterval = 1500,   -- ms, messages are batched (10 per request)
}
```

* A URL sends that event to that channel.
* `''` sends it to the fallback `Webhook`. If that is empty too, the event is not logged.
* `false` turns the event off.
* `set inventory:loglevel 0` turns **all** logs off, Discord included. `2` also logs every add/remove and every purchase.
* A failed Discord request never breaks the action it was logging.

***
