Skip to content

Define material

POST
/v1/actions/hospitality.action.define_material/apply
curl --request POST \
--url https://api.aerandil.com/v1/actions/hospitality.action.define_material/apply \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "branch": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "params": { "brand_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "code": "example", "description": "example", "family": "spare_part", "name": "example", "property_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "sale_price": { "amount": "example", "currency": "example" }, "unit": "each" }, "return_modified": false }'

Put a part or a product in a catalogue under its code — a brand’s (brand_id, shared by its houses) or one house’s (property_id); exactly one. Defining a code the catalogue already holds re-states it in place (details replaced, an unstated description cleared), so the call is replay-safe and is also how a material is corrected; an identical re-statement changes nothing. The price is kept when a re-statement leaves sale_price out, and cleared by an explicit null (2026-10-17). A retired code refuses. The unit is fixed once any store holds the material. A minibar product needs a sale_price for a minibar task to charge it. The catalogue is kept by family (2026-10-17): an engineer’s session defines and re-states spare parts and consumables only, a housekeeping supervisor’s every other family — held to the family the code had and the one it is given (403); the desk and agents are held to none.

Effects: create hospitality.material; modify hospitality.material; link hospitality.link.material_at_brand; link hospitality.link.material_at_property.

Media typeapplication/json
object
branch

Apply against an open branch’s overlay view instead of the canonical (main) plane. The action’s writes land in the branch’s copy-on-first-write overlay, its events in the branch’s own stream, and the invocation is journaled for merge-by-replay. Branch writes are action-only, so this is the write-side entry point to a branch (POST /v1/branches forks one).

string format: uuid
params
required
object
brand_id
The brand's catalogue (exactly one of brand_id / property_id)
string format: uuid
code
required
The catalogue's code for it
string
description
Notes on it
string
family
required
What kind of thing it is
string
Allowed values: spare_part consumable amenity linen minibar_product laundry_item cleaning_product other
name
required
What it is, in words
string
property_id
One house's catalogue (exactly one of brand_id / property_id)
string format: uuid
sale_price
What one unit sells for (a minibar product's charge per unit)
object
amount
required
string format: decimal
currency
required
string format: iso-4217
unit
required
The unit it is counted in
string
Allowed values: each pack pair roll kg l m
return_modified

When true, the response carries modified_objects and modified_links projections — the engine reads the event log inside the same transaction so the projection observes the handler’s own writes.

boolean

Action applied. modified_objects and modified_links populated when return_modified: true was supplied.

Media typeapplication/json
ApplyActionResponse

Envelope returned by the Aerandil action engine. correlation_id ties every event emitted by this invocation; modified_objects and modified_links project the events the handler emitted (per the action’s declared effects); warnings carries any non-blocking soft-validator observations.

object
correlation_id
required

Per-invocation correlation id; matches events.correlation_id for every event this action appended.

string format: uuid
modified_links
required

Links established or removed by this invocation. Empty when the caller did not request return_modified.

Array<object>
object
from_id
required
string format: uuid
from_type
required
string
kind
required
Allowed values: linked
link_type
required
Allowed values: hospitality.link.material_at_brand hospitality.link.material_at_property
to_id
required
string format: uuid
to_type
required
string
modified_objects
required

Objects created, modified, or soft-deleted by this invocation. Empty when the caller did not request return_modified.

Array<object>
object
id
required
string format: uuid
kind
required
Allowed values: created modified
object_type
required
Allowed values: hospitality.material
warnings

Non-blocking soft-validator observations emitted during this invocation (e.g. comp-authority over-limit, recipe pour-cost over sell-price). Absent when no warnings were emitted.

Array<object>
object
message
required

Human-readable summary, suitable for logging or operator-UI surfacing.

string
object_type
required

Object type the warning was raised against.

string
property

Property the warning anchors to, when a single field is the locus. Absent for multi-field rules.

string
rule
required

Stable kebab-case rule identifier (e.g. comp-authority-over-limit).

string
Example
{
"modified_links": [
{
"kind": "linked",
"link_type": "hospitality.link.material_at_brand"
}
],
"modified_objects": [
{
"kind": "created",
"object_type": "hospitality.material"
}
]
}

Conflict — concurrent modification or unique constraint violation.

Validation error — parameter validation or business-rule violation.