> ## 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.

# Register stash

> Dynamically registers a new stash and creates its server inventory during runtime.

Dynamically registers a new stash and creates its server inventory during runtime.

<CodeGroup>
  ```lua Export theme={null}
  exports['jaksam_inventory']:registerStash(options)
  ```

  ```lua Example theme={null}
  -- Create a public stash with interaction point (runtimeOnly = false)
  local stashId = exports['jaksam_inventory']:registerStash({
      label = "Public Storage",
      coords = vector3(100.0, 200.0, 30.0),
      maxWeight = 500,
      maxSlots = 50,
      radius = 5.0,
      runtimeOnly = false -- Enable interaction points
  })

  -- Create a job-restricted stash with interaction point
  local policeStashId = exports['jaksam_inventory']:registerStash({
      id = "police_evidence",
      label = "Police Evidence Locker",
      coords = vector3(450.0, -990.0, 30.0),
      maxWeight = 1000,
      maxSlots = 100,
      radius = 3.0,
      allowedJobs = {police = true, sheriff = true},
      runtimeOnly = false -- Enable interaction points
  })

  -- Create a programmatic-only stash (default behavior, runtimeOnly = true)
  -- Players can't access it via world interaction, only through code
  local hiddenStashId = exports['jaksam_inventory']:registerStash({
      id = "secret_stash",
      label = "Secret Storage",
      maxWeight = 200,
      maxSlots = 30
      -- No coords provided, accessed only programmatically
  })

  -- Create a private stash (each player gets their own inventory when accessing the stash)
  local privateStashId = exports['jaksam_inventory']:registerStash({
      id = "luxury_apartment_stash",
      label = "Personal Safe",
      coords = vector3(300.0, 400.0, 50.0),
      maxWeight = 200,
      maxSlots = 30,
      isPrivate = true
  })

  -- Create a temporary stash with starting items (won't save to database)
  local tempStashId = exports['jaksam_inventory']:registerStash({
      label = "Event Loot Box",
      coords = vector3(500.0, 600.0, 20.0),
      maxWeight = 100,
      maxSlots = 20,
      temporary = true,
      startingItems = {
          {"bread", 5, nil},
          {"water", 3, nil},
          {"money", 1000, nil}
      }
  })

  -- Create a menu-based stash (runtimeOnly = true by default)
  -- Useful for custom UI/menu systems
  local virtualStashId = exports['jaksam_inventory']:registerStash({
      id = "player_bank_vault",
      label = "Bank Vault",
      maxWeight = 500,
      maxSlots = 50,
      isPrivate = true
      -- runtimeOnly = true by default, accessed only programmatically
  })

  -- Open stash programmatically from server (e.g., from a menu or command)
  RegisterCommand('openvault', function(source)
      local charId = Framework.getPlayerCharIdentifier(source)
      local stashId = "player_bank_vault_" .. charId
      exports['jaksam_inventory']:forceOpenInventory(source, stashId)
  end)

  -- Alternative: Open from client-side script
  -- exports['jaksam_inventory']:openInventory('stashId')
  ```
</CodeGroup>

### Parameters

| Name      | Data Type | Description                                         |
| --------- | --------- | --------------------------------------------------- |
| `options` | table     | Configuration table for the stash (see Notes below) |

### Return value

| Name      | Data Type     | Description                                         |
| --------- | ------------- | --------------------------------------------------- |
| `stashId` | string \| nil | The ID of the created stash, nil if creation failed |

### Notes

`options` fields:

* `id` (string, optional): Unique ID for the stash. If not provided, one will be autogenerated
* `label` (string, required): Display name for the stash
* `coords` (vector3 | table, optional): Location where the stash can be accessed via interaction point
* `maxWeight` (number, optional): Maximum weight capacity. Default: 100
* `maxSlots` (number, optional): Maximum number of slots. Default: 100
* `radius` (number, optional): Distance from which players can access the stash. Default: 3.0
* `isPrivate` (boolean, optional): If true, creates a separate inventory for each player. Default: false
* `allowedJobs` (table, optional): Table of job names that can access the stash. If nil, stash is public
* `temporary` (boolean, optional): If true, stash won't be saved to database and lost on script restart. Default: false
* `startingItems` (table, optional): Items to add when the stash is first created. Format: `{{itemName, amount, metadata}, ...}`
* `runtimeOnly` (boolean, optional): If true (default), stash can only be opened programmatically. If false and coords are provided, creates client-side interaction points. Default: true


## Related topics

- [Server](/jaksam-inventory/functions/server/index.md)
- [Action Buttons](/jaksam-inventory/guides/action-buttons.md)
- [Item added](/jaksam-inventory/hooks/on-item-added.md)
- [Modules](/drugs-creator/modules.md)
- [Replace Stash/Safe/Armory](/jobs-creator/client/replace-stash-safe-armory.md)
