Guide - API validation

Validation by endpoint for every write request

Use this table when a write request is malformed. Each row states the method, the path, the required fields, the types, the enums, the lengths, the ranges, and the unknown field rule. The server is the authority. A browser check is a convenience only and never replaces the server check.

How to read this table

Read the validator order first, then the row for the endpoint you called. A missing required field, a wrong type, an over length value, a bad format, a non canonical enum, an out of range number, an unknown field, or a read only field fails the whole write with status 400, ok false, a plain sentence in error, and field naming the first invalid field. Do not truncate a value, do not guess a default, and do not save part of a failed write.

Validator order for every endpoint

Check in this order and report only the first failure. 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. Envelope fields are checked before lead or booking fields. Trim strings and collapse repeated spaces in names. A string that is blank after trimming is missing for a required field. Send numbers as JSON numbers on the server, not as strings, and pass through the browser values only after the same checks. A service slug, a status, a role, and a payment value must use the canonical spelling in the normalized values guide. An Idempotency-Key header, when sent, ties retries of the same payload to one saved record. A missing Idempotency-Key is not a 400 on its own. A retry with the same key and the same payload returns the first saved result. A retry with the same key and a different payload is a 409 naming the request.

EndpointRequired fields and typesEnums, lengths, ranges, and formatsUnknown field and 400 rule
POST /api/public/request, called by site.js for data-request formsEnvelope fields kind and page are always sent by site.js and are accepted as control fields only. Kind is demo, question, or pilot from the form, as a JSON string. Page is the location pathname as a JSON string, maximum 200, and carries no query string. Lead fields are name, org, email, phone, fleet_size, service_area, and message as JSON strings. Subject is a JSON string. Website is a JSON string honeypot. A legacy JSON string field company is read as org, stored as org only, and never returned as a second stored field. The server strips kind, page, company and website before storage.Kind is one of demo, question, pilot. Name is 1 to 120 after trim and collapse of repeated spaces. Org is 1 to 120 after trim. Email is 3 to 254 after trim, lower case, removal of spaces, one at sign, and a domain with a dot. The server lower cases and removes spaces before storage. Phone is maximum 30 as entered, 10 to 15 digits after removal of punctuation, country code required. A 10 digit number is stored as the country code plus those digits, consistent with customer phone normalization, so a 7 digit local number fails with field phone. Fleet_size is an integer from 1 to 1000. The client sends it as a string that contains digits only, as the hint Enter the number only states. A free text value such as a word for a number fails with field fleet_size. Service_area is 1 to 200 after trim. Message is 1 to 2000 after trim, line breaks kept. Subject is 1 to 200 for kind demo and must be one of Cost for my fleet, Trial and evaluation terms, Cost and trial and evaluation terms, General walkthrough, as listed on the request demo page. Subject is optional, 0 to 200, for question and pilot. Website is maximum 200 and is not stored. A non empty website value is treated as not a person submission and fails with field website.Accept only kind, page, company as the org alias, name, org, email, phone, fleet_size, service_area, message, subject, and website. Reject any other field name, including id, tenant_id, customer_id, reference_code, public_token, status, and any card detail field, with 400 and field naming that field. An empty or whitespace only required string fails with 400 and the field named. Do not forward kind, page, the company alias, or the honeypot value as a lead field.
POST /api/publicbook/public/request, called by passenger-book.html and app/passenger-book.htmlService_type, pickup, pickup_at, estimated_hours, passengers, passenger_name, and passenger_phone are required. Dropoff is required except for hourly and event. Airline and flight_number are required for airport_arrival. Booker name, booker phone, booker email, meet_point, sign_text, and requests are optional. All text fields are JSON strings. Estimated_hours and passengers are JSON numbers. Pickup_at is a JSON string in ISO 8601 form. No envelope field is added by this client.Service_type is one of airport_arrival, airport_departure, hourly, point_to_point, event. Pickup and dropoff are 1 to 200 after trim when required. Meet_point is maximum 200, passenger_name is maximum 120, sign_text is maximum 120, requests is maximum 1000 with line breaks kept, airline is maximum 60, flight_number is maximum 20 with letters, numbers, spaces, or hyphens and starting with a letter or number. Estimated_hours is a JSON number from 0.25 to 24 in quarter hour steps. A JSON string such as 3 fails with field estimated_hours and is not coerced. Passengers is a JSON integer from 1 to 7. A float or a string fails with field passengers. Pickup_at is a future date and time in ISO 8601 form in the company timezone. An epoch number fails with field pickup_at. Passenger phone is maximum 30 as entered, 10 to 15 digits after removal of punctuation, country code required, stored after the same normalization as the demo form. Booker phone, when supplied, uses the same rule. Booker email is maximum 254, trimmed, lower case, spaces removed, one at sign and a domain with a dot, when supplied. Requests may carry a Flight buffer line and a Stops in order block as described in the flight status buffer guide. When a Flight buffer line is present, its minutes value must be one of 30, 45, or 75. When a Stops in order block is present, each stop line must be a canonical pickup point from the data fields guide or a full address of maximum 200, with order kept. A malformed buffer or stop line fails with field requests.Accept only the fields listed above. Reject any other field, including id, tenant_id, workspace id, customer_id, chauffeur_id, vehicle_id, reference_code, public_token, company_timezone, call_time, quote_cents, gratuity_cents, total_cents, status, and any card detail field, with 400 and field naming that field. The server derives call_time and quote amounts from saved settings.
POST /api/publicbook/public/{token}/submit, update passenger detailsToken is in the path and is never a body field. At least one of passenger_name, passenger_phone, flight_number, airline, estimated_hours, or requests must be supplied. All fields are optional alone. Text fields are JSON strings. Estimated_hours is a JSON number.Use the same lengths, formats, and ranges as the request endpoint above. Estimated_hours is a JSON number from 0.25 to 24 in quarter hour steps. A supplied phone must pass the 10 to 15 digit country code rule, a supplied flight must pass the flight format, a supplied airline is maximum 60, and a supplied email is not accepted on this endpoint. Requests is maximum 1000, with the Flight buffer and Stops in order rules above when those lines are present.Accept only the six fields above. Reject any other field, including token, public_token, email, service_type, pickup, dropoff, pickup_at, passengers, meet_point, sign_text, booker fields, status, and read only fields, with 400 and field naming that field. A body with no field fails with 400. The write applies only when the booking is in Quote or Confirmed. A booking in any other status fails with 409 after the 400 checks pass, and no field is changed.
POST /api/publicbook/public/{token}/reschedulePickup_at is required as a JSON string. Pickup and dropoff are optional JSON strings.Pickup_at is a future date and time in ISO 8601 form in the company timezone. An epoch number or a past time fails with field pickup_at. Pickup and dropoff are 1 to 200 after trim when supplied. The server recalculates call_time from the saved lead hours setting. The write applies only when the booking is in Quote or Confirmed. A booking in any other status fails with 409 after the 400 checks pass.Accept only pickup_at, pickup, and dropoff. Reject any other field, including token, public_token, estimated_hours, passengers, flight fields, status, and read only fields, with 400 and field naming that field.
POST /api/publicbook/public/{token}/cancelCancel_reason is required as a JSON string.Cancel_reason is 1 to 1000 after trimming, with line breaks kept. Cancel applies only to a Quote or Confirmed booking through this flow. A booking in any other status fails with 409 after the 400 checks pass, and its status is not changed. No fee is computed from a cancelled booking and no amount is added to a quote or an invoice.Accept only cancel_reason. Reject any other field, including token, public_token, status, and read only fields, with 400 and field naming that field. A missing or blank reason fails with 400.
PUT and PATCH, any path in the site packNo PUT or PATCH handler is present in the site pack. All writes called from the site files are POST.Do not add a PUT or PATCH handler from this page. Verify in the backend slice that no PUT or PATCH route exists for bookings, customers, chauffeurs, vehicles, settings, drafts, issues, invoices, or files.A PUT or PATCH request to a POST route returns status 405 in the same error shape, ok false, a plain sentence in error naming the method to use, and field naming the method, and saves nothing. A PUT or PATCH request is never treated as an update.
POST /api/files, named in the app kit onlyFile field is required. Ref is optional and must name a real record in the same workspace when supplied.File size and file type limits are not stated in the site pack. Verify them in locked core before deploy and add no value from this page. A missing file fails with field file. A size or type failure in locked core keeps the same 400 shape where the locked code states it.Reject a missing file, a ref from another workspace, and any body field other than file and ref with 400 and field naming that field.

Gaps this table closes

The shipped client always sends kind and page on the public form, yet an earlier version of this table rejected any field not listed as a lead field, so a correct client payload would have failed. The public form also allowed a 7 digit phone and a free text fleet size, while the customer record, the passenger book form, and the duplicate merge checks all require a country code phone of 10 to 15 digits and a numeric fleet size. The table now states the envelope fields, the company alias, the integer fleet size, the 10 to 15 digit phone rule, the required pricing topic for kind demo, JSON number strictness for estimated hours and passengers, ISO only pickup times, the token and status gates on update, reschedule and cancel, and the 405 shape for PUT and PATCH, so the same malformed request fails in the same way on the phone, on a desktop, and with no browser.

Client mirror

The browser must use the same allowlist, the same lengths, the same enums, and the same ranges, show the field error beside the field, keep the other entries, and focus the first invalid field. The browser must not send a request that the table says will fail with 400. In particular, the browser sends fleet_size as digits only, phone with a country code, email in lower case, subject for kind demo, pickup_at in ISO form, and estimated_hours and passengers as numbers where the client already does so.

Server authority

The server must repeat every check at write time, inside the signed in workspace for signed in writes and from the booking record for public token writes. An id from another workspace is treated as not found. Envelope fields kind and page are validated and then stripped. The company alias is stored as org. A value sent as the wrong JSON type is rejected, not coerced. A state failure, such as 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, returns 409 in the same shape after the 400 checks pass.

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, an unknown field, and a read only field. Each check must fail with 400, the field named, and no partial save.

  • Public request with an unknown field, kind missing, page with a query string, an empty name, a whitespace only message, a bad email, a phone under 10 digits, a fleet size that is not digits only or is above 1000, and a demo submission with no subject or with a subject outside the four listed topics each fail and send nothing
  • Public request with the envelope fields, the company alias in place of org, an upper case email, and a 10 digit phone succeed, and the saved lead holds org in lower case email and the normalized phone with no kind, page, company or website value stored
  • Passenger book request with passengers above 7, estimated hours sent as a string, estimated hours not in quarter hour steps, an epoch pickup time, a past pickup time, an MCI arrival with no flight number, a drop off missing for point to point, and a Flight buffer line with minutes outside 30, 45, 75 each fail and save no booking
  • Update with no field, update with an email field, update on a booking in Driver confirmed, reschedule with a past pickup time, and cancel with a blank reason each fail and change nothing on the booking, with 409 for the state cases
  • A write that supplies id, tenant_id, call_time, quote_cents, status, token, or a card detail field each fails with the field named
  • A PUT or PATCH request to any POST route returns 405 in the error shape and saves nothing
  • A valid write for each endpoint 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 by endpoint, then save canonically

Read the data fields and normalized values guides with this table, then run the acceptance checks for each write endpoint.