# Update an allocation rule

Updates the fields supplied and returns the rule in the same shape as reading
it. Only the fields sent are touched, so an empty body is a valid request that
changes nothing, and omitting `rules` leaves the qualifying condition alone
rather than clearing it.
Changing the threshold does not revisit anyone who already qualified - items
already handed out stay handed out, and raising the threshold does not take them
back. The new condition applies from here on.

Endpoint: PUT /api/v2/inventory/allocation/{id}
Version: 2.0.0
Security: default

## Path parameters:

  - `id` (integer, required)
    The ID of the allocation rule.

## Header parameters:

  - `Rosterfy-Platform` (string)

## Request fields (application/json):

  - `name` (string)
    A name for the allocation rule, used wherever it is listed.

  - `type` (string)
    What the people who qualify are being given. `entitlements` for something they have earned, `rewards` for something granted as a reward, and `redemption` for something exchanged for points. The value is recorded on every allocation the rule creates and is used in reporting. Send one of the three: other values are accepted here but stop the rule allocating anything when it next runs.

  - `rules` (array)
    The qualifying condition, as a list holding exactly one entry of the form `{"type": "<measure>", "value": <threshold>}`. `type` is the measure to count and `value` is the number the person has to reach. The measures are `total_number_of_shifts`, `total_number_of_events`, `total_shift_hours` (counted from scheduled times), `total_shift_hours_attended` (counted from check-in to check-out) and `shift_hours_per_day`. Required - and note that anything else, including an empty list, more than one entry, an unrecognised measure or a missing threshold, is rejected with a message saying the field is required rather than one describing what was wrong.

  - `conditions` (array)
    An optional list of further conditions narrowing who the rule applies to, on top of the measure in `rules`. The structure is not currently validated and is not part of this contract - build it in the console rather than by hand, and send back what you were given if you are updating a rule that already has one.

## Response 200 fields (application/json):

  - `object` (object)

  - `object.id` (integer)

  - `object.type` (string)

  - `object.name` (string)

  - `object.rules` (array)

  - `object.rules.type` (string)

  - `object.rules.value` (integer)

  - `object.conditions` (array)

  - `object.deleted_at` (string | null)

  - `object.created_at` (string)

  - `object.updated_at` (string)

  - `nice` (object)

  - `nice.rule_name` (string)

  - `nice.rule_value` (integer)

  - `relations` (object)

  - `relations.items` (array)

  - `relations.items.object` (object)

  - `relations.items.object.id` (integer)

  - `relations.items.object.inventory_item_id` (integer)

  - `relations.items.object.quantity` (integer)

  - `relations.items.object.valid_duration` (integer)

  - `relations.items.object.created_at` (string)

  - `relations.items.object.updated_at` (string)

  - `relations.items.nice` (array)

  - `relations.items.permissions` (object)

  - `relations.items.permissions.read` (boolean)

  - `relations.items.permissions.update` (boolean)

  - `relations.items.permissions.delete` (boolean)

  - `permissions` (object)

  - `permissions.read` (boolean)

  - `permissions.update` (boolean)

  - `permissions.delete` (boolean)

