A small mock of the Doorstep agent API. It follows the JSON:API conventions.
npm install
npm start # http://localhost:3000, and your machine's network address
npm testAll data lives in memory. Restarting the server resets every change you made and signs everyone out.
| Variable | Default | Effect |
|---|---|---|
PORT |
3000 |
Port to listen on (all interfaces) |
LATENCY_MIN_MS / LATENCY_MAX_MS |
200 / 900 |
Each API response is delayed by a random time in this range |
FAILURE_RATE |
0 |
Share of API requests (0 to 1) that fail with a 503 |
LOG_REQUESTS |
on | Set to 0 to stop logging each request |
- Responses use
Content-Type: application/vnd.api+json. Requests can sendapplication/vnd.api+jsonorapplication/json. - Every endpoint except
POST /auth/token,GET /and/images/*needsAuthorization: Bearer <accessToken>. - Related resources are always returned in
included, so a response has everything needed to show itsdata. - Ids are strings.
- Date-times are ISO 8601 instants in UTC, e.g.
2026-11-04T09:30:00.000Z. When you send one, include an offset (Zor+01:00). - Dates in filters are
YYYY-MM-DDand refer to the UK calendar day (Europe/London). - Viewing data in
data/*.jsonis written around January 2030. At startup it is moved, whole weeks at a time, so that it falls in the current week.
Errors come back as an errors array. Every error has a status, a machine-readable code and a title. Some also have a detail, a source and a meta object.
{
"errors": [
{
"status": "422",
"code": "invalid_field",
"title": "Choose an interest level",
"source": { "pointer": "/data/attributes/interestLevel" }
}
]
}| Status | When |
|---|---|
400 |
Malformed body or query parameter (source.parameter names it) |
401 |
Missing, invalid or expired token; wrong credentials |
404 |
Unknown resource or route |
409 |
Conflict: a time clash, a duplicate, or a type/id that does not match |
422 |
Validation failed. There is one error per problem, and source.pointer names the field |
503 |
Simulated outage (see FAILURE_RATE) |
Collections marked paginated accept page[number] (from 1) and page[size] (default 20; larger values are treated as 50). They return links.first, links.prev, links.next and links.last, plus meta.total. links.prev and links.next are null at the ends.
Body (plain JSON): { "email": "alex.morgan@example.com", "password": "doorstep" }. Every seeded agent uses the password doorstep.
201: a tokens resource with accessToken, tokenType and expiresAt (12 hours), related to the signed-in agents resource. 401 invalid_credentials when the email or password is wrong.
The signed-in agent.
Everyone in the branch.
Reference lists. Filter with filter[category]:
| Category | Used for |
|---|---|
cancellation-reason |
cancellationReason when cancelling a viewing |
interest-level |
interestLevel on feedback |
feedback-quick-response |
quickResponses on feedback |
viewing-duration |
durationMinutes on a viewing (value is in minutes) |
The signed-in agent's viewings, earliest first. Accepts one of:
filter[date]=YYYY-MM-DD. Defaults to today.filter[from]=YYYY-MM-DD&filter[to]=YYYY-MM-DD, both required, both inclusive.
Viewings are shared across the branch. Any signed-in agent can fetch or change any viewing by id.
Books a viewing for the signed-in agent. Other agents can be added to it.
{
"data": {
"type": "viewings",
"attributes": { "startsAt": "2026-11-09T10:00:00Z", "durationMinutes": 30, "notes": "Optional, max 1000 characters" },
"relationships": {
"property": { "data": { "type": "properties", "id": "12" } },
"applicant": { "data": { "type": "people", "id": "40" } },
"agents": { "data": [{ "type": "agents", "id": "2" }] }
}
}
}durationMinutesdefaults to 30.- New viewings start as
unconfirmed. 422when a field is invalid orstartsAtis not in the future.409when the slot overlaps another live viewing:property_unavailableapplicant_unavailableagent_unavailable- The error's
detailsays when the clashing viewing is booked, andmeta.viewingIdgives its id.
Send only the attributes that change.
- Confirm:
{ "status": "confirmed" }. - Cancel:
{ "status": "cancelled", "cancellationReason": "<lookup id>" }. A cancelled viewing cannot be changed again (422 viewing_cancelled). - Reschedule:
{ "startsAt": "..." }and/or{ "durationMinutes": 45 }. The viewing goes back tounconfirmed. The same409clash rules apply as for booking. - Notes:
{ "notes": "..." }(max 1000 characters;nullclears them).
data.id must match the URL, or the request fails with 409 id_mismatch.
{ "data": { "type": "feedback", "attributes": { "interestLevel": "13", "quickResponses": ["15", "18"], "notes": "Optional, max 1000 characters" } } }422 viewing_not_startedbefore the viewing's start time.422 viewing_cancelledfor a cancelled viewing.409 feedback_existsif feedback has already been recorded.
filter[q]: matches the address, town or postcode.filter[market]:salesorlettings.
filter[q]: matches the name, the email, or 3 or more digits of the phone number.filter[role]:applicantorowner.
Creates an applicant.
{ "data": { "type": "people", "attributes": { "firstName": "Sam", "lastName": "Lee", "phone": "07700 900999", "email": "sam.lee@example.com" } } }- First and last name are required, plus at least one of phone or email.
409 duplicate_personwhen the email already belongs to someone.meta.personIdgives that person's id.
Static photos. No auth needed. Image resources carry an absolute url, built from the host you called.
| Type | Attributes | Relationships |
|---|---|---|
agents |
firstName, lastName, email, phone, jobTitle, branch |
|
people |
firstName, lastName, email, phone, roles (owner, applicant), requirements* (market, minBedrooms, maxPrice, position) |
|
properties |
address (line1, line2, town, city, postcode, latitude, longitude), market, status, price (amount, currency, qualifier, frequency), propertyType, bedrooms, bathrooms, receptions, tenure, councilTaxBand, epcRating, description, keyFeatures, accessNotes, keySafeCode* |
owner → people, images → images[] |
images |
url, width, height, caption |
|
viewings |
startsAt, endsAt, status (unconfirmed, confirmed, cancelled), cancellationReason, notes |
property, applicant → people, agents → agents[], feedback* |
feedback |
interestLevel, quickResponses, notes*, submittedAt |
|
lookups |
category, label, value*, sortOrder |
* can be null.