Shared API validation schema patch
Use this page with the API validation by endpoint guide. It adds the missing GET rows, states the validator order for query, header and body input in one place, and states the client mirror corrections that stop a payload the server must reject from being sent.
What the audit found
The API validation guide lists every POST write endpoint and no GET endpoint. The quote preview GET, the booking status GET and the live stage GET are called by the passenger book pages and by the home estimator, yet no row states their query checks. The validator order in that guide starts with unknown field and does not state JSON parse failure, a non object body, a wrong content type for a POST, or a query parameter check. The public form client in site.js allows a free text fleet size, does not require a subject for a demo form, and allows a 7 digit phone, while the table requires digits only for fleet size, a listed subject for a demo form, and 10 to 15 digits for phone. A payload that passes those client checks fails on the server with a 400 that the person cannot see beside the field.
One consistent 400 response
Every validation failure on every endpoint below uses the same shape. Status 400, ok false, error with one plain sentence that names what to do, and field with the first invalid field in validator order. No partial save, no truncated value, no guessed default, and no list is returned with a failed write. A state or conflict failure after all 400 checks pass uses status 409 in the same shape. A wrong method on a POST route uses status 405 in the same shape with field naming the method.
Shape in words
ok is false. error is a plain sentence. field is the first invalid name. No other top level field is added. The same shape is used for a query failure, a JSON parse failure, a missing required field, a wrong JSON type, an over length value, a bad format, a non canonical enum, an out of range number, a cross field failure, and an unknown or read only field.
What this patch does not change
No sign in path, no tenancy path, no role, no CORS rule, no CSP rule, no security header, no rate limit, no firewall rule, no deploy step, no migration, no connection string and no app settings file is changed by this page. The server remains the authority and the browser check remains a convenience only.
Validator order for every endpoint
Check in this order and report only the first failure. Query parameters are checked before body fields on a GET. Body fields are checked in this order on a POST.
Method, content type and JSON parse
A POST with a body must carry content type application/json and a body that parses to one JSON object. A parse failure, a top level array, a top level string and a top level number each fail with field naming body. A GET with a body is ignored and no body field is read.
Unknown or read only field
Reject any name not listed for that endpoint, in query or in body, including id, tenant_id, token in a body, call_time, quote_cents, gratuity_cents, total_cents, status except through the status step, and any card detail name. Field names are case sensitive and must use the canonical snake case spelling.
Missing required field
A required name that is absent, null, or a string that is blank after trimming fails with that name in field. At least one field is required on the update endpoint and an empty object fails with field naming the first listed field for that endpoint.
Wrong JSON type
Text fields must be JSON strings. Estimated hours and passengers must be JSON numbers on a POST and must not be strings. Pickup time must be a JSON string. A string in place of a number, a number in place of text, a boolean in place of text and a nested object in place of text each fail with the field named and are not coerced. On a GET, a query value is text by nature and is parsed once to a number only for estimated hours.
Length, format, enum and numeric range
Apply the length, format, enum and range for that field from the API validation guide. Trim text and collapse repeated spaces in names before the length check. Lower case email and remove internal spaces before the format check. Compare phone digits only after removing punctuation. Estimated hours must be from 0.25 to 24 in quarter hour steps. Passengers must be an integer from 1 to 7. Fleet size must be digits only after trimming and from 1 to 1000.
Cross field check
Drop off is required except for hourly and event service. Airline and flight number are required for an MCI airport arrival. A subject is required for a demo form and must be one of the four listed topics. Pickup date start after pickup date end fails with field naming pickup_date_start. Total cents must equal rate cents plus gratuity cents when all three are present on a saved quote read.
Existence and state check
Check that a referenced id exists in the same workspace for a signed in write, or that a token names a booking for a public token write. An id from another workspace is treated as not found. Only after all 400 checks pass, apply the state check and return 409 for an out of sequence status, a day off assignment, a minimum gap conflict, a vehicle not ready assignment, or an update, reschedule or cancel on a booking outside Quote or Confirmed.
GET endpoints added by this patch
Read each row with the POST rows in the API validation guide. A GET never saves a record and never returns a partial list on a validation failure.
| Endpoint | Allowed query | Checks and 400 rule |
|---|---|---|
| GET /api/publicbook/public/quote | service_type and estimated_hours only | service_type is required and must be one of airport_arrival, airport_departure, hourly, point_to_point, event. estimated_hours is required and must parse as a number from 0.25 to 24 in quarter hour steps. Any other query name fails with field naming that name. A missing or out of range value fails with field naming service_type or estimated_hours. No booking is created by this GET. |
| GET /api/publicbook/public/{token} | No query name is allowed | Token is in the path and is never a body or query field. A token shorter than 8 characters, or a token that names no booking, returns 404 in the same shape with field naming token and no booking detail. Any query name fails with field naming that name. |
| GET /api/publicbook/public/{token}/live | No query name is allowed | Use the same token check as the status GET. A booking with no live stage returns the booking status with no live field, not a 400. Any query name fails with field naming that name. |
Client mirror corrections to ship with the server patch
Apply each correction in the named file so the browser stops sending a payload the server must reject. Keep the field label, the required mark and the server check in place.
public/site.js, public form
Reject fleet_size that is not digits only after trimming, with field naming fleet_size. Require subject for a demo form and require subject to be one of Cost for my fleet, Trial and evaluation terms, Cost and trial and evaluation terms, General walkthrough, with field naming subject. Require phone digits from 10 to 15 after removing punctuation, not from 7 to 15, with field naming phone. Lower case email and remove internal spaces before the format check, with field naming email.
public/request-demo.html, demo form
Use the same fleet size, subject and phone checks as site.js. Do not add a second submit path and do not change the outbox key, the timeout or the retry rule in site.js.
public/passenger-book.html and public/app/passenger-book.html, booking form
Use one validation set in both copies. Require drop off except for hourly and event service, require airline and flight number for an MCI airport arrival, require passenger phone digits from 10 to 15, and remove internal spaces from email before the format check. A payload that passes one copy must pass the other copy with the same field named on failure.
What not to change in the client
Do not add a field name, do not send a number as a JSON string, do not send a pickup time as an epoch number, and do not send a token in a body. Keep draft storage, outbox handling, quote cache and calendar generation as shipped.
Acceptance checks before you ship
Run each check with no browser as well as in a browser. Each check must fail with 400, field naming the first invalid name, and no partial save, or succeed with the same call time, quote, status and flags on the booking, the day board and the chauffeur phone view.
- GET quote with a missing service_type, a service_type outside the five listed values, estimated_hours as a word, estimated_hours at 3.1, and an unknown query name each fail with the field named
- GET status with a token shorter than 8 characters and a token that names no booking each return 404 with field naming token and no booking detail
- POST public request with a non JSON body, a top level array, a string in place of fleet_size, fleet_size as a word, a phone under 10 digits, a demo form with no subject, a subject outside the four listed topics, and an unknown field each fail with the field named
- POST booking request with estimated_hours as a string, passengers as a float, pickup time as an epoch number, a drop off missing for point to point, an MCI arrival with no flight number, and a read only field such as call_time or status each fail with the field named
- Update with no field, update with an email field, reschedule with a past pickup time, and cancel with a blank reason each fail with the field named and change nothing on the booking
- A PUT or PATCH request to a POST route returns 405 in the same shape and saves nothing
Validate in one order, save only a valid payload
Read the API validation guide with this patch, then run the acceptance checks for each endpoint.