Open Inventory / Docs
EndpointsAccess controlApiAccessRules

Create a conditional inventory access rule

The API runs on your application instance. Schemas and field names come directly from the OpenAPI specification. Session-authenticated requests require a session on that instance.

POST
/api/access/rules

Requires an authenticated browser session with the roles.manage permission. The rule grants its permissions to members of the selected role only for inventory items that match every condition.

Authorization

adminSession
cookieauthjs.session-token<token>

Authenticated Auth.js browser session cookie; each operation declares its required permission. Not restricted to administrators. HTTPS deployments use the secure-prefixed cookie variant.

Header Parameters

X-Organization-ID?string

Organization membership selected for this request. User-bound credentials may select any active membership; standalone tokens may only repeat their pinned organization ID.

Formatuuid

Request Body

application/json
  1. body

Additive item-specific access grant. Multiple enabled rules are ORed; all conditions inside this rule are ANDed.

name*string
Length1 <= length <= 160
description?string
Lengthlength <= 1000
Default""
roleKey*AccessRoleKey

Stable lowercase identifier for a built-in or custom role.

Match^[a-z][a-z0-9_-]{0,63}$
Length1 <= length <= 64
permissions*array<>
Items1 <= items <= 7
conditions*array<>

Conditions combined with logical AND.

Items1 <= items <= 12
enabled?boolean
Defaulttrue
priority?integer

Display and evaluation order; lower values come first and do not override other matching rules.

Range0 <= value <= 10000
Default100

Response Body

Inventory access rule created

application/json
  1. response
rule*

Additive permission grant for matching inventory items. Rules never deny permissions already granted by a role; any matching enabled rule may grant access.

Example Request
curl -X POST 'https://example.com/api/access/rules' \  -H 'Content-Type: application/json' \  -d '{  "name": "Update XYZ items",  "description": "Let members of the ABC role update items whose name contains xyz.",  "roleKey": "abc",  "permissions": [    "inventory.update"  ],  "conditions": [    {      "field": "name",      "operator": "contains",      "value": "xyz"    }  ],  "enabled": true,  "priority": 100}'
Example Response
{  "rule": {    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",    "name": "string",    "description": "string",    "roleKey": "editor",    "permissions": [      "inventory.update"    ],    "conditions": [      {        "field": "status",        "operator": "equals",        "value": "string"      }    ],    "enabled": true,    "priority": 0,    "createdBy": "string",    "updatedBy": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z"  }}