ROOL API docs

API guide

Rules for clients, errors, and the owner flow call by call: authentication, catalog, localization, garage, odometer, maintenance with every reason code, service events and errors. Section 10 records a run against staging and names the commit each statement was checked on; where versions behave differently, the text says which one does what.

Rendered from docs/public-api-contract.md at commit 8565409 (main). The schema of record is the API reference; production, staging and main differ where Versions says so.

5. Rules for clients

  1. Ignore unknown fields. Responses gain fields without notice. A client that fails on an unknown field breaks on a normal release.
  2. Expect new enum values. Every enum may grow: section states, attention levels, manufacturerResponse, identification, and so on. Map an unknown value to a safe fallback. For example, show an unknown section state as "not available", never as "all clear".
  3. Reason codes are extensible. See §8.
  4. Ids are opaque UUID-format strings. Do not parse them, derive meaning from them, or sort by them. Store them as strings.
  5. Branch on code, never on text. title, detail, displayName and the regulator texts are for display only.
  6. NOT_YET_AVAILABLE is not "nothing wrong". Never present it as all clear. See §7.
  7. Mock ids are not production ids. Fixture ids use the synthetic range 00000000-0000-7000-8000-…. Never persist them beyond a mock build, and clear local caches when switching from mock to a real backend.
  8. Send Idempotency-Key (a fresh UUID per user action) on the create operations that declare it. Reuse it only for a retry of the same action.

How to build a mock adapter (an HTTP interceptor, a local mock server or generated stubs) is each client's decision and lives in that client's repository.

6. Envelopes and errors

Lists always use one page envelope, even when there is only one page:

{ "data": [], "page": { "nextCursor": null, "hasMore": false } }

Request the next page with ?cursor=<page.nextCursor> (and optionally &limit=, 1–100). Cursors are opaque.

Errors are RFC 9457 application/problem+json, the ProblemDetailsResponse schema:

{ "type": "about:blank", "title": "Conflict", "status": 409, "code": "email_taken",
  "detail": "An account with this email already exists.", "instance": "/api/v1/auth/register",
  "requestId": "…", "errors": [{ "field": "email", "message": "…" }] }

Codes defined today:

CodeStatusWhere
validation_failed400any operation with input; errors lists each field
unauthenticated401any signed-in operation: token missing, expired or invalid (refresh and retry once)
invalid_credentials401login
refresh_token_invalid, session_revoked401refreshSession: sign in again
invalid_provider_token401signInWithGoogle
forbidden403a route the caller may not use
not_found404unknown id, or another user's resource
catalog_entry_not_found404createVehicle with an unknown generation or profile
email_taken409register
account_link_required409signInWithGoogle (provisional)
idempotency_in_progress409a retry while the first request is still running
model_year_not_covered, profile_not_in_generation, market_contradicts_profile, engine_not_in_generation, in_service_date_without_baseline, in_service_date_in_future422createVehicle, updateVehicle
odometer_decreased, recorded_on_in_future422createOdometerReading
unknown_item_code, performed_on_in_future422createServiceEvent
rate_limited429register, login, refreshSession (Retry-After header, in seconds)
service_unavailable503register, login while Redis is down (the rate limiter fails closed)
internal_error500anything unexpected

10. Owner flow reference, as observed on staging

Everything in this section was run against https://api.staging.rool.am on 2026-10-06, deployed commit 205d1e99, by the suite in test/staging/ (runbook staging-e2e.md; evidence in docs/readiness/staging-e2e-2026-10-06/), not read from code. These are historical results of that run: they describe that staging release, not main as it is now and not production (0697919). A rerun needs a reason. Where a row says observed, it is behaviour the contract does not promise and a client must not depend on. openapi.json stays the schema of record; this section adds what a schema cannot say.

Headers on every call: Accept: application/json, Content-Type: application/json on a body. Signed-in calls add Authorization: Bearer <accessToken>. Staging also needs X-Rool-Staging-Key (mobile-api-connection.md §4a). Production needs neither staging header nor any other gate.

10.1 Authentication

CallRequestSuccessErrors
POST /api/v1/auth/register{ email, password (10 to 128 chars), locale? }; unknown fields are 400201 AuthSession400 validation_failed (errors[].field), 409 email_taken, 429 rate_limited
POST /api/v1/auth/login{ email, password }200 AuthSession400, 401 invalid_credentials (the same answer for a wrong password and an unknown address), 429
POST /api/v1/auth/refresh{ refreshToken }200 AuthSession, a new refresh token400, 401 refresh_token_invalid (unknown or expired), 401 session_revoked, 429
POST /api/v1/auth/logoutbearer, { refreshToken }204, no body400, 401 unauthenticated
GET /api/v1/mebearer200 Me401 unauthenticated
PATCH /api/v1/mebearer, { displayName?, locale? } (en, hy, ru)200 Me400, 401

Refresh rotation.

SituationResult
Refresh with the latest refresh token200, new access and refresh token. The old refresh token is now spent. The old access token keeps working until it expires.
Refresh with a spent token (a retry, or two devices sharing a token)401 session_revoked, and every token of that sign-in dies, including the newest one and its access token (verified: GET /me is then 401). Other sign-ins of the same account are untouched.
Two refreshes of the same token at the same timeExactly one answers 200; the other is 401 session_revoked, and the winner's new tokens are revoked at once. The user has to sign in again.
Refresh with a made-up token401 refresh_token_invalid, nothing is revoked

Safe client recovery. There is no grace window (a deliberate gap in authentication.md). The client therefore:

  1. allows one refresh in flight at a time, per account, in the whole app (a mutex, not a queue of retries);
  2. writes the new refresh token to secure storage before it uses the new access token;
  3. after a refresh whose result it did not see (timeout, connection lost after sending), must assume the old token may already be spent. Retrying it will answer session_revoked and end the sign-in. There is no safe retry; the client shows sign-in. Do not loop;
  4. treats 401 session_revoked and 401 refresh_token_invalid as "signed out": clear tokens, keep nothing but the email, show sign-in;
  5. treats a 401 unauthenticated on an ordinary call as "refresh once, then retry the call once".

Logout. The first logout is 204 and takes effect at once: the access token is 401 unauthenticated immediately, not after 15 minutes, and the refresh token is session_revoked. A second logout with the same (now revoked) access token is 401 unauthenticated, not a second 204: treat 401 on logout as "already signed out". It ends only this sign-in; other devices stay signed in. No logout-everywhere endpoint exists.

Rate limits (per authentication.md): 10 registrations per hour per client address, 5 wrong passwords per account per address per 15 minutes (the 6th attempt is 429, and while limited even the correct password is 429). A 429 always carries Retry-After in seconds. A client behind a shared mobile-carrier address shares the per-address bucket with everyone on it.

10.2 Catalog

All public: no bearer token. Cache-Control: public, max-age=300, stale-while-revalidate=60 and an ETag on lists. A compressing proxy may append -gzip to the ETag it sends: send back exactly the value you received in If-None-Match; an unchanged list is then 304. Your HTTP client must not add Cache-Control: no-cache to that revalidation.

CallQueryReturns
GET /api/v1/makeslimit (1 to 100), cursorpage of { id, name }
GET /api/v1/modelsmakeId (UUID), pagingpage of { id, makeId, name }
GET /api/v1/generationsmodelId, pagingpage of { id, modelId, code, name, modelYearFrom, modelYearTo } (modelYearTo null while in production)
GET /api/v1/vehicle-profilesgenerationId, pagingpage of { id, generationId, displayName, engine, transmission, drivetrain, market, modelYearFrom, modelYearTo }
GET /api/v1/generations/{id}/variant-optionsnone{ generationId, engines: [{ id, label }], transmissions, drivetrains, conditions, markets, scheduleOptions }

makeId, modelId and generationId are required on their lists (400 validation_failed without). A malformed id is 400 validation_failed; a well-formed id that does not exist is 404 not_found, not an empty page. The chain is make, model, generation, then optionally a profile. A vehicle references a generation (required) and may reference a profile and an engine variant (engines[].id).

10.3 Localization

GET /api/v1/localization/{locale}, public, locale exactly en, hy or ru: 200 { version, strings } with an ETag and Cache-Control: public, max-age=300, stale-while-revalidate=60; 304 on a matching If-None-Match; any other value (de, EN, hy-AM) is 404 locale_not_supported. In main since 13a853e (ROOL-189, PR #20) and on staging 205d1e9; not on production (0697919), where it answers a plain 404 until the next production release. Details: localization.md. A client that cannot get a catalog (404, error, offline) needs a bundled fallback; whether a given client has one is for that client's team to state, this document does not.

10.4 Garage

CallNotes
POST /api/v1/me/vehiclesIdempotency-Key header is required (400 validation_failed without it). Body: generationId, modelYear required; vehicleProfileId, engineVariantId, nickname (40), transmission, drivetrain, severeUse, conditions, market, scheduleOptions, serviceBaseline, inServiceOn, odometerKm optional. 201 Vehicle.
GET /api/v1/me/vehiclespage of the caller's vehicles
GET /api/v1/me/vehicles/{id}200, or 404 not_found for an unknown id and for another user's id (the two are indistinguishable by design)
PATCH /api/v1/me/vehicles/{id}any create field except generationId; 200 Vehicle; 422 model_year_not_covered when the year is outside the generation
DELETE /api/v1/me/vehicles/{id}204; afterwards the vehicle, its maintenance, odometer readings and service events are 404

10.5 Odometer

POST /api/v1/me/vehicles/{id}/odometer-readings, Idempotency-Key required, body { odometerKm (integer, km), recordedOn (YYYY-MM-DD) } → 201 { id, odometerKm, recordedOn, createdAt }.

10.6 Maintenance

GET /api/v1/me/vehicles/{id}/maintenance → 200 VehicleMaintenance:

{ "vehicleId": "…", "asOf": "2026-10-06", "odometerKm": 52000, "state": "AVAILABLE",
  "fixtureData": true, "questions": [{ "dimension": "TRANSMISSION", "options": [], "itemsWaiting": 1 }],
  "unavailableItemCodes": [], "items": [ { "itemCode": "ENGINE_OIL", "action": "REPLACE",
  "applicability": "APPLIES", "due": { "state": "NOT_DUE", "distanceRemainingKm": 11570,
  "monthsRemaining": 5, "dueAtOdometerKm": 63570, "dueOn": "2027-04-01", "reasons": [] },
  "interval": { "basis": "WHICHEVER_FIRST", "distanceKm": 12070, "months": 6 },
  "lastService": { "serviceEventId": "…", "performedOn": "2026-10-01", "odometerKm": 51500, "action": "REPLACE" },
  "sources": [{ "title": "…", "page": 511 }] } ] }
FieldMeaning
stateAVAILABLE, NOTHING_APPLIES (published data exists for the model and none reaches this car) or NOT_YET_AVAILABLE (items is []; unavailableItemCodes lists what ROOL cannot yet say). All three are HTTP 200. A car with no published schedule is not an error.
fixtureDatatrue means the schedule is test data (staging only). Production refuses fixtures. Never present a fixtureData: true schedule as real.
due.stateNOT_DUE, DUE_SOON, OVERDUE, UNKNOWN_LAST_SERVICE, NEEDS_VEHICLE_INFO, NO_FIXED_INTERVAL, NOT_SCHEDULED. The enum may grow; map unknown values to "not available". OVERDUE and DUE_SOON are defined in openapi.json and are not exercised by the staging fixture.
odometerKm (top level)The highest confirmed value across odometer readings and service-event odometers, in km; null when there is none. Not the same as Vehicle.latestOdometer (§10.5).
due.distanceRemainingKm, dueAtOdometerKmkilometres; null when the last service has no odometer, or the state is unknown.
due.monthsRemaining, dueOnwhole months and the calendar date; null when unknown.
UNKNOWN_LAST_SERVICEno service event recorded for the item: every due field is null, lastService is null, reasons is [{ code: "NO_SERVICE_RECORD" }]. Ask the owner when it was last done.
NEEDS_VEHICLE_INFOthe item depends on a fact the owner has not given (reasons[0].params.facts, e.g. ENGINE); questions lists the choices.
applicabilityAPPLIES, or MAY_APPLY with applicabilityReasons (e.g. ENGINE_UNKNOWN when no engine variant is set).

The staging fixture covers one generation, Nissan Rogue T32 (engine QR25DE). Every other generation answers NOT_YET_AVAILABLE. Production has no published maintenance at all as of 2026-10-06 (the catalog is empty).

10.6.1 Reason codes in maintenance responses

Unlike the rest of §10, this subsection was read from the code, not observed on staging: the emission sites in src/modules/maintenance/domain/ (applicability.ts, due.ts, schedule.ts) at main 00d3bbe (which includes ROOL-201), with each shape also checked by a local integration run at the earlier main 50e70a2 and the domain unit tests re-run on the current candidate. Not all of it is deployed. Staging 205d1e9 and production 0697919 run the code of 50e70a2: they still send MARKET_DIFFERS (below); main no longer does. Reason is a provisional schema, and so is this list.

Every reason is { "code": string, "params": object }. params is always an object, {} when the code has none. They appear in two places:

Reasons that explain why a rule does not reach the car (a model year outside the schedule, an engine or gearbox that differs, severe use or a condition that was not selected, and, on main, a car whose market the schedule does not support) are never sent: that rule is absent from items, so no code exists for them on the wire. Do not rely on the order of reasons in a list or on a code being present: the same item can carry several.

Units in params: distances are whole kilometres (km), rounded, whatever unit the manual printed (the printed unit is in interval.distance); months are whole months; dates are YYYY-MM-DD. engines holds the engine labels as printed (for example QR25DE), not ids; the ids are in questions[].options[].value.

applicabilityReasons:

CodeparamsSent when
MODEL_YEAR_COVEREDmodelYear int, from int, to int or null (open end)Always, first: the car's year is inside the schedule
SEVERE_USE_SELECTEDnoneA severe-use schedule, and the car has severeUse: true
CONDITION_DECLAREDcondition string (condition code from getVariantOptions)A condition-specific schedule, and the owner declared that condition
SCHEDULE_OPTION_SELECTEDoption string (option code)The car's scheduleOptions contains this schedule's option
SCHEDULE_OPTION_UNKNOWNoption stringThe schedule belongs to an option and the car selected none: MAY_APPLY, a SCHEDULE_OPTION question
MARKET_UNKNOWNscheduleMarkets string[] (alpha-2 or EU)The schedule is limited to markets and the car's market is null: MAY_APPLY, a MARKET question
MARKET_DIFFERSscheduleMarkets string[], vehicleMarket stringOnly on staging 205d1e9 and production 0697919, until their next release; main (ROOL-201) does not send it. The car's market is outside the schedule's: MAY_APPLY, the item is kept with a computed due state. On main the same car gets no item from that schedule (internally NOT_APPLICABLE / MARKET_NOT_SUPPORTED, never sent), no countdown, and, if nothing else applies, state NOTHING_APPLIES; a car whose market is unknown is still asked (MARKET_UNKNOWN, MAY_APPLY, no countdown)
ENGINE_UNKNOWNengines string[]The schedule is limited to engines and the car has no engineVariantId: MAY_APPLY, an ENGINE question
ENGINE_NAMEDengines string[]The car's engine is one of the schedule's
TRANSMISSION_UNKNOWN, TRANSMISSION_NAMEDtransmissions string[] (MANUAL, AUTOMATIC, CVT, DCT, SINGLE_SPEED)As for the engine, on the car's transmission
DRIVETRAIN_UNKNOWN, DRIVETRAIN_NAMEDdrivetrains string[] (FWD, RWD, AWD, FOUR_WD)As for the engine, on the car's drivetrain
IF_EQUIPPEDnoneAn if-equipped schedule that the car's stated variant does not settle: MAY_APPLY

due.reasons:

CodeparamsSent when
VEHICLE_INFO_NEEDEDfacts string[], any of ENGINE, TRANSMISSION, DRIVETRAIN, MARKET, SCHEDULE_OPTION (order not significant)due.state is NEEDS_VEHICLE_INFO; the only reason then. Lists what this rule waits on, so it can be shorter than questions. The names match questions[].dimension
NO_SERVICE_RECORDnoneUNKNOWN_LAST_SERVICE: no event and no SINCE_NEW baseline. Also appended to a condition-based item with a backstop and no starting point
NOT_SCHEDULED_BY_MANUFACTURERnoneNOT_SCHEDULED: the manufacturer prints no scheduled replacement
FIRST_SERVICE_ONLY_DONEnoneNOT_SCHEDULED: a first-service-only schedule that is already done; ROOL does not invent a repeat
INSPECTION_STANDS_INnoneThe last covering event was an INSPECT standing in for a REPLACE item
COUNTING_FROM_NEWinServiceOn date or nullNo event, and the car's serviceBaseline is SINCE_NEW: counting from delivery at 0 km
FIRST_SERVICE_INTERVALnoneThe first-service interval is used instead of the repeat interval
CONDITION_BASEDnoneThe manufacturer says "by condition" (the car's monitor decides)
BACKSTOPkm int or null, months int or nullA condition-based item with a stated outer limit
SERVICE_ODOMETER_UNKNOWNnoneThe distance half cannot be counted: the service event has no odometerKm
ODOMETER_UNKNOWNnoneThe distance half cannot be counted: the car has no odometer value at all
IN_SERVICE_DATE_UNKNOWNnoneThe time half cannot be counted: SINCE_NEW without inServiceOn
DISTANCE_REMAININGkm int, 0 or moreThe distance half was counted, not yet due
DISTANCE_OVERDUEkm int, how far past, rounded to whole km (so a few hundred metres past shows 0)The distance half was counted, past due
MONTHS_REMAININGmonths int, 0 or more; dueOn dateThe time half was counted, not yet due
MONTHS_OVERDUEmonths int, 1 or more, how far past; dueOn dateThe time half was counted, past due

Example, as emitted for the Rogue T32 FIXTURE schedule (a 2018 car with no engine set, then a 2016 QR25DE with an oil change recorded at 51,500 km and an odometer of 52,000 km; items abridged to their reasons):

{ "itemCode": "ENGINE_OIL", "applicability": "MAY_APPLY",
  "applicabilityReasons": [ { "code": "MODEL_YEAR_COVERED", "params": { "modelYear": 2018, "from": 2014, "to": 2019 } },
                            { "code": "ENGINE_UNKNOWN", "params": { "engines": ["QR25DE"] } } ],
  "due": { "state": "NEEDS_VEHICLE_INFO",
           "reasons": [ { "code": "VEHICLE_INFO_NEEDED", "params": { "facts": ["ENGINE"] } } ] } }

{ "itemCode": "ENGINE_OIL", "applicability": "APPLIES",
  "applicabilityReasons": [ { "code": "MODEL_YEAR_COVERED", "params": { "modelYear": 2016, "from": 2014, "to": 2019 } },
                            { "code": "ENGINE_NAMED", "params": { "engines": ["QR25DE"] } } ],
  "due": { "state": "NOT_DUE",
           "reasons": [ { "code": "DISTANCE_REMAINING", "params": { "km": 7547 } },
                        { "code": "MONTHS_REMAINING", "params": { "months": 5, "dueOn": "2027-04-01" } } ] } }

Unknown codes. The list grows additively. A client that meets a code it does not know ignores it and shows the wording that fits the item's applicability and due.state (which are the enums that carry the verdict). It never shows an unknown reason as "all clear", and it ignores params keys it does not know. ENGINE_UNKNOWN, ENGINE_NAMED and MARKET_DIFFERS also appear in the intelligence list in §8 (for maintenance, MARKET_DIFFERS only on the deployed releases, see its row) with different params (engineCodes, engineCode, sourceMarket). That list is not served yet; the shapes above are the only ones sent today, and a client must key its parsing on the endpoint, not on the code alone.

10.7 Service events

POST /api/v1/me/vehicles/{id}/service-events, Idempotency-Key required:

{ "itemCode": "ENGINE_OIL", "action": "REPLACE", "performedOn": "2026-10-01",
  "odometerKm": 51500, "note": "optional, max 500" }

→ 201 { id, itemCode, action, performedOn, odometerKm, note, createdAt }. action is REPLACE, INSPECT or SERVICE (anything else is 400); itemCode must be a code ROOL knows (422 unknown_item_code); performedOn in the future is 422 performed_on_in_future; odometerKm is optional (without it only the time interval can count: the item is NOT_DUE with reason SERVICE_ODOMETER_UNKNOWN and dueAtOdometerKm: null).

10.8 Errors

Application errors are RFC 9457 application/problem+json with type (always about:blank), title, status, code, detail (absent on 5xx), instance, requestId and, for 400, errors: [{ field, message }]. Every problem keeps the field set above; branch on code.

StatusWhencode
400body or query fails validation (unknown field, wrong type, missing Idempotency-Key)validation_failed
401no, malformed, expired or revoked access tokenunauthenticated
404unknown route under /api/v1not_found
404another user's resourcenot_found (same as unknown)
409duplicate emailemail_taken
429rate limitrate_limited + Retry-After

Not in problem+json. These come from the edge, not the application:

WhereWhat the client sees
Staging without or with a wrong X-Rool-Staging-Key404, empty body, no content type, on every path
/health/ready, /internal/* on any hostname404, empty body (never routed publicly)
Request body over 1 MB413, empty body
Plain HTTP to production308 redirect to HTTPS (to any other host, 404)

Handle "404 with an empty body" as "wrong environment or missing key", not as "not found".

10.9 Ownership

Two disposable accounts were used: the second cannot list, read, update, delete, read maintenance or service events of, submit odometer readings to, or create service events on the first account's vehicle. All answer 404 not_found, and the first account's data is unchanged.