Skip to main content

Update a Carpool Booking Rule

PATCH 

/carpool/rules/:booking_rule_id

Changes one booking rule of the account, the same setting the Carpool settings screen changes. The account's own setting is created when it does not exist yet, and the answer is the rule as it is now.

Which rules. Only the rules returned by GET /carpool/rules can be changed. Any other booking_rule_id answers 404, exactly like an id that does not exist.

Two kinds of rule. The value_type of the rule in GET /carpool/rules tells which request body applies. The body is one of two shapes, never a mix of them.

value_typeRulesSendIn the answer
BOOLThe switches: booking permissions, vehicle management, start and stop methods, active booking extension and the notificationsis_enabled onlyvalue is null
A duration unit101 advance booking and 102 maximum durationvalue, unit or bothis_enabled is true while value is at least 1

Switch a rule. Send {"is_enabled": true} or {"is_enabled": false}. Sending value or unit for a switch answers 422.

Set a duration rule. Send value, unit or both. Booking checks read only the value and the unit of these rules, so there is nothing to switch. The limit is on while the value is at least 1, and sending is_enabled answers 422. As on the Carpool settings screen, these limits cannot be switched off, so a value of 0 answers 422.

UnitLargest value
MINUTES50000
HOURS2000
DAYS365
WEEKS52
MONTHS60

The value that results from the request, the one sent or else the stored one, must be at least 1 and at most the largest value of the resulting unit. Changing only unit therefore checks the stored value against the new unit, so send value together with unit when moving to a smaller unit. Sending unit for any rule other than 101 and 102 answers 422.

Errors.

StatusWhen
401The credentials are missing or invalid
403The credentials belong to a subuser
404The booking_rule_id is not one of the rules GET /carpool/rules returns
422Field validation: the body is empty, carries an unknown field, a null or a blank text, is_enabled is not the JSON true or false, value is not a JSON whole number of at least 1 with at most nine digits, or unit is not one of the five units above in upper case
422 with reason code CARPOOL_RULE_VALUE_NOT_ALLOWEDThe body mixes the two shapes (is_enabled for a duration rule, or value for a switch), unit is sent for a rule other than 101 and 102, the value is outside the range of its unit, or the stored value does not fit the new unit

Existing bookings are not re-validated. Relaxing a rule does not approve anything that was refused, and tightening one does not invalidate a booking that was already accepted. A change applies to bookings made after it.

This operation is available to the main account only.

Request​

Responses​

The rule as it is now.