Open Inventory / Docs
EndpunkteAccess controlApiAccessRules

Create a conditional inventory access rule

Die API läuft auf deiner Anwendungsinstanz. Schemas und Feldnamen stammen unverändert aus der OpenAPI-Spezifikation. Browsergebundene Aufrufe benötigen eine Sitzung auf der Instanz.

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.

Authentifizierung

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-Parameter

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

Anfrageinhalt

application/json
  1. body

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

name*string
Länge1 <= length <= 160
description?string
Längelength <= 1000
Standard""
roleKey*AccessRoleKey

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

Muster^[a-z][a-z0-9_-]{0,63}$
Länge1 <= length <= 64
permissions*array<>
Einträge1 <= items <= 7
conditions*array<>

Conditions combined with logical AND.

Einträge1 <= items <= 12
enabled?boolean
Standardtrue
priority?integer

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

Bereich0 <= value <= 10000
Standard100

Antwortinhalt

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.

Beispielanfrage
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}'
Beispielantwort
{  "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"  }}