Server side validation for authenticated write endpoints
Use this specification for every signed in write operation, including booking, assignment, daily check, service, customer, chauffeur, vehicle, settings, message draft, issue, invoice, file, and merge writes. The server is the authority. Checks in a browser form are a convenience only and never replace the checks on this page.
How to use this specification
Endpoint paths for signed in operations are not named in the site pack except for file upload, so this specification is written by operation. Map each operation to its existing route in app code and apply the rules for that operation. Do not add a new route name, a new sign in path, or a new tenant path from this page.
Principles
Reject, do not truncate, do not guess, and do not silently replace a value with a default. A missing required field, a wrong type, an over length value, a bad format, a non canonical enum, or an out of range number fails the whole write with no partial save. The same limits apply on a phone, on a desktop, and when no browser is used.
Field order for errors
Report the first failure in this order, so the message names one field to correct. Unknown or read only field, missing required field, wrong type, length, format, enum, numeric range, cross field check, same workspace existence check, then state or conflict check. Do not return a partial list of rows for a failed write.
- Limits in this specification come from the public booking form, the site form, the data fields guide, the normalized values guide, and the config guides in this pack. Where the pack states no limit, this page states verify before deploy and adds no value.
- Every existence check stays inside the signed in workspace. An id from another workspace is treated as not found and returns no detail from that workspace.
- A failed write changes no booking, no rate, no pickup time, no call time, no assignment, no check result, and no invoice amount.
Consistent request and response shape
Use one shape for every write, so a screen can show the same message in the same place.
Request
Send one JSON object for the operation, with the field names in the data fields guide. A string field must be a JSON string, a number field must be a JSON number, an integer field must be a JSON integer with no fraction, and a date or time field must be a string in the format stated below. Null is not a value for a required field. A string that is blank after trimming is missing for a required field.
Success and error
Success returns the existing success shape for that route, with the saved record or the saved id and no secret or personal note in the detail. Validation failure returns status 400 with ok false, a plain sentence in error telling the person what to correct, and field naming the first invalid field. Not found in the same workspace returns 404 in the same shape. A state or conflict failure, such as an out of sequence status, a day off assignment, a minimum gap conflict, or a vehicle not ready assignment, returns 409 in the same shape. Permission failures keep the existing server response and gain no new permission from this page.
Common field rules
These rules apply to every operation unless an operation card states a tighter rule.
Strings, length, and format
- Name fields, maximum 120 characters after trimming and collapsing repeated spaces to one space, for passenger name, booker name, chauffeur name, and sign text.
- Pickup, drop off, and meet point, maximum 200 characters after trimming. Requests and notes, maximum 1000 characters after trimming, with line breaks kept as line breaks.
- Company name and public name, maximum 120 characters. Service area, maximum 200 characters. Message and draft text, maximum 2000 characters. Other free text, maximum 500 characters.
- Email, maximum 254 characters, trimmed, lower case, no spaces, matching the pattern used in the site form, with one at sign and a domain with a dot.
- Phone, maximum 30 characters as entered, digits only for the check, 7 to 15 digits in total, and for a passenger or booker phone the country code plus the full number so the digit count is at least 10. Keep an extension separate from the main number.
- Flight number, maximum 20 characters, letters, numbers, spaces, or hyphens only, starting with a letter or number. Airline, maximum 60 characters.
Dates, times, timezone, and numbers
- Date fields are a date alone, year, month, and day in that order, in the company timezone. Date and time fields are one combined date and time in the company timezone, in ISO 8601 form. Pickup time for a new request must be in the future.
- Timezone must be a place name such as America/Chicago, not an abbreviation such as CST. No timezone value is stated in this pack, so no default timezone is added here.
- Estimated hours is a number from 0.25 to 24 in quarter hour steps. Passengers is an integer from 1 to 7.
- Gratuity percent is a number from 0 to 100. Lead hours is a number greater than 0. Minimum gap is a number of minutes from 0 up to but not including lead time in minutes.
- Rates are numbers greater than 0 in whole dollars as saved on a quote. Odometer is an integer from 0 upward and must not be lower than the last recorded odometer for that vehicle. Service cost is a number from 0 upward. A negative number fails for every numeric field.
Canonical enums, save canonical only
Booking status, in order, is Quote, Confirmed, Driver confirmed, En route, On location, Passenger on board, Complete, plus Cancelled only through the public cancel flow on a Quote or Confirmed booking. Service slugs are airport_arrival, airport_departure, hourly, point_to_point, wedding, and event. Roles are Owner or manager, Chauffeur, and Relief chauffeur. Payment status is Unpaid or Paid. Invoice state is Issued or Paid. Daily check result is Ready, Not checked, or Failed. Vehicle state is Out of service. Service flag is On track, Due soon, or Overdue. Issue types are Complaint, Lost item, Billing, Late pickup, and Compliment. Draft kinds are Confirmation, Chauffeur details, On location, and Thank you. A legacy variant in the normalized values guide is read as its canonical value, but a write saves the canonical value only and rejects a non canonical spelling with the field named.
Read only fields the client must never supply
Reject a write that supplies id, tenant_id, workspace id, created time, updated time, call_time, quote_cents, gratuity_cents, total_cents, status except through the status step for that operation, approved_by, approved_at, sent_at, recorded status times, audit fields, daily check result as a client chosen value, invoice amounts, and any card detail field. The server derives call time as pickup time minus lead hours, derives quote amounts from saved rates at booking time, and derives readiness from the check, vehicle state, dates, and service flags for the pickup date.
Validation by operation
Each card states the required fields and the operation specific checks. Common field rules apply to every field named here.
Booking create and edit
Required: service slug, pickup, pickup date and time, estimated hours where the service needs it, passengers, passenger name, and passenger phone. Drop off is required except for hourly, wedding, and event service as stated on the booking form. Flight number is required for MCI airport arrival and airline is required with it. Booker name, booker phone, and booker email are optional, but a supplied booker phone or email must pass the format rules. Meet point, sign text, and requests are optional within their limits. Edit accepts only fields the person may change for the current status, keeps the other saved fields, and rechecks pickup time, passenger count, and service against the quote rule before save.
Status advance, reschedule, and cancel
A status write accepts no free status text. It accepts only the one next step in booking order for that booking, with no skip and no step after Complete or Cancelled. Reschedule requires a new future pickup date and time, with pickup and drop off within their limits when supplied, and recalculates call time on the server. Cancel requires a reason, maximum 1000 characters, and applies only to a Quote or Confirmed booking through the cancel flow. A Quote that staff do not confirm stays in Quote and is not stored as Cancelled by a status write.
Assign, reassign, and mark day off
Required: chauffeur id and vehicle id, each must open to a real record in the same workspace. The server rechecks at write time that the chauffeur is not marked off for the pickup date, the chauffeur certificate is not expired for that date, the vehicle is Ready for that pickup date with check date equal to pickup date, not out of service, permit and inspection not expired, and no overdue service item, and that no other run for the same chauffeur or vehicle comes closer than the minimum gap, and the passenger count on the run does not exceed the vehicle's passenger capacity, failing with the field named and the flag reason in words if it does. A failed check returns 409 with the flag reason in words and saves no assignment. Day off requires a date and a reason within the note limit, and relief assignment uses only the car of a chauffeur who is off that day when that car is free.
Daily check submit and clear out of service
Required: vehicle id, check date, a pass or fail value for every cleaning and safety item in the seeded list, odometer, and fuel level. Issues and photos are optional within their limits and photo references must belong to that vehicle. The server derives the result. Ready only when every item passes. Any failed safety item derives Out of service for that vehicle and date. A clear write requires a reason and an owner or manager role, and the reason is saved with the cleared record. A check for a date that is not the pickup date never marks a vehicle Ready for that pickup date.
Log a service visit
Required: vehicle id, one of the 14 livery items, service date, odometer at service, shop name within 200 characters, and cost from 0 upward. Odometer must not move backward for that vehicle. The server resets only that item for that vehicle and recalculates next due miles and date from the saved interval. A log for a missing vehicle or a missing item fails with the field named and resets no due date.
Customer, chauffeur, and vehicle create and edit
Customer: company or hotel name, booker contact, passenger contact, and preferences are optional within their limits, but a supplied phone or email must pass format rules, and a new record first searches the same workspace list so the same person is not added twice. Chauffeur: name, phone, email, type, home vehicle id when supplied, active state, and linked sign in id when supplied are validated, with certificate number and expiry optional to save but required and not expired before assignment. Vehicle: plate, colour, home chauffeur id when supplied, permit number, permit expiry, inspection expiry, and odometer are validated, with permit, inspection, and odometer optional to save but required and valid before assignment. Plate and permit compare after trimming, upper case, and removing spaces and hyphens.
Rates, scheduling settings, and company profile
Rates: hourly rate and minimum hours, MCI flat rate, point to point minimum, event hourly rate and minimum hours, gratuity percent, lead hours, and minimum gap are each validated under the numeric rules, with a missing or zero rate failing. A changed rate applies to new quotes only and the server never rewrites a saved quote. Company profile: company name, public name, phone, service area, and timezone are required to confirm at setup, with timezone as a place name and phone and service area within their limits. Pickup points use the ten canonical names in the data fields guide.
Message draft edit, approve, and reject
Edit requires draft text, maximum 2000 characters, and saves only that draft in its current workspace. Approve requires the draft to be waiting for approval for that booking, read against the current booking, assigned chauffeur and vehicle records, and saved quote before approval, and an approved draft that follows entered text over booking facts is rejected at review. Reject sends nothing and holds the next draft for that kind. Chauffeur name, vehicle, plate, and phone are never approved before Driver confirmed. No card detail, internal note, VIP flag, spend history, rate setting, or log detail is accepted in a draft write.
Issue, invoice, and payment status
Issue requires a booking id in the same workspace, a canonical issue type, and a description within 1000 characters. Resolve requires a resolution note and keeps the issue linked to its booking. Invoice issue requires status Complete on every booking behind the invoice, a customer id, and a month, with amounts read only from the saved quote on those Complete bookings. Payment status accepts Unpaid or Paid only, with a method label as trimmed free text within 500 characters. Card number fields are read only in the sense that they are never accepted, and a deposit or cancellation fee is never accepted as fare.
File upload and merge duplicates
File upload uses the existing file route, with the file field required and an optional ref that must name a real record in the same workspace. File size and file type limits are not stated in the site pack, so verify them in locked core before deploy and add no value here. Merge requires the keeper id and the duplicate id in the same workspace, groups records only on the fixed keys in the merge guide, moves trips, files, checks, service entries, and role assignments, recounts so the keeper count after equals keeper before plus duplicate before for each category, then retires the duplicate only when the recount succeeds. A recount failure rolls back the move, keeps the duplicate, and returns 409 with field naming the reconciliation failure. A record in another workspace, a shared phone or email alone, and a name alone never merge.
Server rechecks that a screen cannot decide
A screen may hide a button, but the write must still fail when the check fails.
State and readiness at write time
Recheck status sequence, day off, certificate expiry, readiness for the pickup date, permit and inspection expiry, overdue service, and minimum gap at the moment of the write, not only when the screen opened. A pickup time that moved after the screen opened is read from the saved booking before assignment, draft approval, or invoice issue.
Source changed after drafting
If the booking, assignment, vehicle record, or saved rates change after a draft is prepared, the draft is read against the current saved fields before approval. The old draft is edited or rejected, not sent alongside a new draft. A changed rate never updates a saved quote or an earlier completed booking.
- Every create, change, and delete that succeeds is logged with actor, action, target, and time, with no secret and no personal note in the detail, as stated in the app kit.
- Every SQL statement stays scoped by the signed in workspace, as stated in the app kit, and this specification adds no new tenant path.
- Numbers that cannot be computed from the record, such as a cancellation fee, a collected amount, a utilization percent, an on time percent, and a satisfaction score, are not filled by a write and must not be estimated.
Acceptance checks before you ship
Run each check with a missing field, a wrong type, an over length value, a bad format, a non canonical enum, an out of range number, a cross field failure, a cross workspace id, a read only field, an out of sequence status, and a conflict case. Each check must fail with the field named and with no partial write.
- Booking with no passenger phone, passengers above 7, estimated hours not in quarter hour steps, and MCI arrival with no flight number each fail and save no booking.
- Assignment to a chauffeur who is off, a vehicle not Ready for the pickup date, and a run inside the minimum gap each fail with 409 and the flag reason in words.
- Daily check with a missing item, a lower odometer, and a failed safety item leaves the vehicle not Ready or Out of service as derived by the server.
- Service log with a lower odometer, a missing vehicle, and a missing item each fail and reset no due date.
- Settings with gratuity outside 0 to 100, lead hours at or below 0, minimum gap at or above lead time in minutes, and a missing or zero rate each fail.
- Draft approval before Driver confirmed with chauffeur detail, invoice issue before Complete, and payment write with a card detail field each fail and send or issue nothing.
- Merge across workspaces, merge on a shared phone alone, and a recount that does not add up each fail and retire no record.
- A valid write for each operation still succeeds, shows the same call time, quote, status, and flags on the booking, the day board, and the chauffeur phone view, and opens the saved record behind every number.
Validate on the server, save canonically, and report the field
Read the data fields and normalized values guides with this specification, then run the acceptance checks for each write operation.