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_type | Rules | Send | In the answer |
|---|---|---|---|
BOOL | The switches: booking permissions, vehicle management, start and stop methods, active booking extension and the notifications | is_enabled only | value is null |
| A duration unit | 101 advance booking and 102 maximum duration | value, unit or both | is_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.
| Unit | Largest value |
|---|---|
MINUTES | 50000 |
HOURS | 2000 |
DAYS | 365 |
WEEKS | 52 |
MONTHS | 60 |
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.
| Status | When |
|---|---|
401 | The credentials are missing or invalid |
403 | The credentials belong to a subuser |
404 | The booking_rule_id is not one of the rules GET /carpool/rules returns |
422 | Field 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_ALLOWED | The 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
- 200
- 400
- 401
- 403
- 404
- 422
- 429
- 500
- 503
The rule as it is now.
The request body is declared as JSON but cannot be parsed, or is not a JSON object or array. Nothing was processed.
Unauthorized access. Authentication is required.
The operation requires main account credentials. Valid subusers receive this response.
The requested resource was not found.
Request field validation or Carpool business validation failed.
Too Many Requests - the endpoint's rate limit has been exceeded. Retry after the number of seconds in the Retry-After header.
Response Headers
Seconds to wait before retrying. The same value as X-RateLimit-Retry-After-Seconds when that wait is non-negative. If the computed wait is negative, Retry-After is floored at 0.
Unix timestamp of the next earliest successful request.
Seconds until the next earliest successful request.
Internal server error.
Service temporarily unavailable. The request did not complete and can be retried after the number of seconds in the Retry-After header, when one is sent.
Response Headers
Seconds to wait before retrying. Sent with db_busy and db_pool_timeout.