Housekeeping → Maintenance

A guide for the developer of the housekeeping system: how to send maintenance issues to the Maintenance app, and how to follow what becomes of them.

Contents

  1. How it works
  2. The address and the key
  3. Requests and replies
  4. GET /options
  5. POST /issues
  6. GET /issues/{ref} and ?refs=
  7. GET /changes
  8. POST /issues/{ref}/notes
  9. POST /issues/{ref}/cancel
  10. The issue object
  11. Statuses
  12. Errors
  13. Building it: a checklist
  14. Example code

1. How it works

  1. Housekeeping finds a problem and sends it with POST /issues, with its own number (ref).
  2. It lands in Maintenance's To do as a new report, unassigned. Coordinators and supervisors are told at once.
  3. A coordinator gives it to an artisan, with a due date.
  4. The artisan starts it, finishes it, and a supervisor checks it.
  5. Housekeeping follows it with GET /changes (or asks about one with GET /issues/{ref}).

Housekeeping can also add a note to an issue (the artisan sees it), and call an issue off while nobody has been given it yet.

2. The address and the key

Base address

https://ibjmiyehfhsmupsokyqt.supabase.co/functions/v1/housekeeping

Every address below is added to this one, for example …/housekeeping/issues.

The key

The Maintenance admin makes the key in the app (More › Settings › Rooms & lists › Housekeeping system) and gives it to you. It starts with hk_. Send it with every request, in this header:

X-Housekeeping-Key: hk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Authorization: Bearer hk_… works too.

Keep the key on your server. Call these addresses from your server only, never from a web page or a phone app, where anybody could read the key. Keep it in your server's settings (an environment variable), not in your code. If it is ever seen by somebody it should not be, ask the admin for a new one: making a new key stops the old one at once.

There is one key at a time, and the admin can turn the link off. A wrong or turned-off key gets 401.

3. Requests and replies

GET

/options

The rooms, areas, kinds of work and properties the Maintenance app knows. Use these words when you send an issue: a room it does not know is refused. They change seldom; read them once a day, or when an issue is refused with code room.

curl -s https://ibjmiyehfhsmupsokyqt.supabase.co/functions/v1/housekeeping/options \
  -H "X-Housekeeping-Key: $HK_KEY"
{
  "ok": true,
  "rooms": ["Room 1", "Room 2", "Room 14", "B2 Room 3"],
  "areas": ["Laundry", "Corridor", "Kitchen"],
  "categories": ["Plumbing", "Electrical", "Carpentry", "Air-conditioning", "Other"],
  "properties": [],
  "priorities": ["normal", "urgent"]
}

Matching is not case-sensitive ("room 14" is "Room 14"), but it is otherwise exact. If your room names differ from these, keep a small table that turns yours into theirs.

POST

/issues

Report one issue.

FieldNeededWhat it is
refyesYour own number for this issue, unique in your system (up to 80 characters). How you will ask about it later, and what stops it being made twice.
roomyesThe room or area, one of rooms or areas from /options.
descriptionyesWhat is wrong, in words an artisan understands (up to 2,000 characters). For example “Shower drips all night; tap handle loose.”
categorynoThe kind of work, one of categories. Left out, it goes in as the general kind (“Other”), and the coordinator sorts it.
priorityno"normal" (the default) or "urgent". Urgent: a guest cannot use the room, water is leaking, something is unsafe. Urgent issues are chased much sooner.
propertynoWhich property, one of properties, when there is more than one.
reported_bynoThe name of the housekeeper who found it (up to 60 characters). The app shows “Housekeeping · Ama Mensah”.
photosnoUp to 6 web addresses of photos, each starting https://. They must open for anyone with the address (no sign-in) for as long as the job is open: send addresses, not the pictures themselves.
curl -s -X POST https://ibjmiyehfhsmupsokyqt.supabase.co/functions/v1/housekeeping/issues \
  -H "X-Housekeeping-Key: $HK_KEY" -H "Content-Type: application/json" \
  -d '{
    "ref": "HK-2026-001234",
    "room": "Room 14",
    "category": "Plumbing",
    "description": "Shower drips all night; tap handle loose.",
    "priority": "urgent",
    "reported_by": "Ama Mensah",
    "photos": ["https://housekeeping.example.com/photos/1234-1.jpg"]
  }'

201 Created the first time; 200 with "duplicate": true if that ref was already sent (you get the issue as it is now; nothing in it is changed):

{
  "ok": true,
  "duplicate": false,
  "issue": {
    "id": "4d8c608b-5176-4e88-a5c0-cb96a5dd4022",
    "ref": "HK-2026-001234",
    "room": "Room 14",
    "category": "Plumbing",
    "description": "Shower drips all night; tap handle loose.",
    "priority": "urgent",
    "property": null,
    "reported_by": "Ama Mensah",
    "reported_at": "2026-11-27T09:12:40.118Z",
    "status": "waiting",
    "status_text": "Waiting to be given to an artisan",
    "assigned_to": null, "assigned_at": null, "due_date": null,
    "done_at": null, "checked_at": null,
    "cancelled_at": null, "cancel_reason": null,
    "changed_at": "2026-11-27T09:12:40.118Z"
  }
}

To change something about an issue already sent, add a note. A different problem in the same room is a new issue, with a new ref.

GET

/issues/{ref}

One issue, as it is now. 404 (code missing) if there is none with that ref.

curl -s https://ibjmiyehfhsmupsokyqt.supabase.co/functions/v1/housekeeping/issues/HK-2026-001234 \
  -H "X-Housekeeping-Key: $HK_KEY"
{ "ok": true, "issue": { "ref": "HK-2026-001234", "status": "assigned",
  "status_text": "Given to Kojo, due 28 Nov", "assigned_to": "Kojo", "due_date": "2026-11-28", … } }
GET

/issues?refs=HK-1,HK-2,HK-3

Several at once, up to 100, comma-separated. You get back those it knows, oldest first; any it does not know are left out.

{ "ok": true, "issues": [ { "ref": "HK-1", … }, { "ref": "HK-3", … } ] }
GET

/changes?since=2026-11-27T08:00:00Z

Every issue you sent whose status, artisan, due date or priority has changed (or that got a note) since that time, oldest change first, up to 500. This is the way to keep your system up to date.

{
  "ok": true,
  "issues": [ { "ref": "HK-2026-001234", "status": "in_progress", "status_text": "Kojo is working on it", … } ],
  "next_since": "2026-11-27T10:41:07.552Z",
  "more": false
}
  1. Keep next_since. Next time, ask from it: ?since=<next_since>.
  2. If "more": true, there were over 500: ask again straight away from the new next_since.
  3. Ask every 2 to 5 minutes. More often gains nothing; much less, and your staff see old news.
  4. The first time, ask from the moment you started sending issues.

An issue can come back more than once (it changed twice): keep the latest, by ref.

POST

/issues/{ref}/notes

More to say about an open issue: the room is free after 10, the guest checks out tomorrow, it got worse. It is added to the job's notes, which the artisan and coordinator see.

curl -s -X POST https://ibjmiyehfhsmupsokyqt.supabase.co/functions/v1/housekeeping/issues/HK-2026-001234/notes \
  -H "X-Housekeeping-Key: $HK_KEY" -H "Content-Type: application/json" \
  -d '{"note": "Room is free after 10:00, guest has checked out.", "by": "Ama Mensah"}'

note is needed (up to 1,000 characters); by is the person's name (optional). You get back the issue. A note to an issue that is done, checked or cancelled is refused (409, code closed): report a new one.

POST

/issues/{ref}/cancel

Call an issue off (sent by mistake, or it turned out to be nothing), while it is still waiting, before anybody has been given it.

curl -s -X POST https://ibjmiyehfhsmupsokyqt.supabase.co/functions/v1/housekeeping/issues/HK-2026-001234/cancel \
  -H "X-Housekeeping-Key: $HK_KEY" -H "Content-Type: application/json" \
  -d '{"reason": "Sent by mistake: it was Room 15."}'

You get back the issue, "status": "cancelled". Cancelling one already cancelled is fine (you get it back as it is). Once an artisan has it, it is refused (409, code started): ask Maintenance to call it off; you will see it in /changes when they do.

The issue object

FieldWhat it is
idMaintenance's own id for the job.
refYour number for it.
room, category, description, priority, propertyAs the app holds them (a coordinator may correct the kind of work or the priority).
reported_by, reported_atWho you said found it, and when it arrived.
statusWhere it is: see Statuses. Use this in your code.
status_textThe same, in words for your staff: “Given to Kojo, due 28 Nov”.
assigned_to, assigned_atThe artisan's first name, and when it was given to them.
due_dateThe day it is due, when a coordinator has set one.
done_at, checked_atWhen the artisan finished it, and when a supervisor checked it.
cancelled_at, cancel_reasonWhen it was called off, and why.
changed_atWhen any of this last changed.

Statuses

statusMeaning
waitingIn To do, not yet given to an artisan. You can still cancel it.
assignedGiven to an artisan (assigned_to), not started.
in_progressThe artisan is working on it.
doneFinished by the artisan, waiting for a supervisor to check it. For housekeeping, the room is usable again.
checkedDone, and checked by a supervisor. Closed.
cancelledCalled off, by you or by Maintenance (cancel_reason). Closed.

Usually: waiting → assigned → in_progress → done → checked. Maintenance can also send a job back to the artisan, so a status can go back a step; just take the latest.

Errors

HTTPcodeMeaning, and what to do
400ref, room, category, description, priority, property, photos, note, sinceThat field is missing or not right. The message says what to put right. Do not send it again unchanged.
400json, shapeThe body is not JSON, or not a JSON object.
401keyNo key, a wrong key, or the link is turned off. Stop sending, and ask the Maintenance admin.
404missingNo issue from housekeeping has that ref.
404pathNo such address.
405methodGET where POST is wanted, or the other way round (the Allow header says which).
409startedToo late to cancel: an artisan has it. Ask Maintenance.
409closedThe issue is done, checked or cancelled: no more notes to it.
413sizeOver 64 KB.
500serverSomething went wrong on the Maintenance side. Wait a minute and try again, with the same ref; if it keeps happening, tell the Maintenance admin.

A network failure or no reply at all: treat it as a 500. Try again after 1, 2, 4, 8 … minutes, with the same ref, and keep the issue in your system as “not yet sent” until you get a 201 or 200.

Building it: a checklist

  1. Keep the key in your server's settings. Check it with GET /ping: {"ok": true, "version": "1"}.
  2. Read /options, and map your room names to theirs. Read it again once a day.
  3. When a housekeeper reports a problem, save it in your system with your ref, then send it. Keep the id and status you get back.
  4. If sending fails (no reply or 5xx), try again later with the same ref. Do not make a new ref.
  5. Every few minutes, ask /changes from the last next_since, and update your issues by ref. Show status_text to your staff.
  6. Add notes and cancel from your system with the two POSTs, if your staff need to.
  7. Try every error: a wrong key, a room not on the list, a missing description, the same ref twice, cancelling one already given out.
  8. Agree a test with the Maintenance admin before going live: issues you send appear in their To do straight away, and their staff are told.

Example code

JavaScript (Node 18 or later, on your server)

const BASE = 'https://ibjmiyehfhsmupsokyqt.supabase.co/functions/v1/housekeeping';
const KEY = process.env.HK_KEY;            // the key, kept in the server's settings

async function hk(method, path, body) {
  const res = await fetch(BASE + path, {
    method,
    headers: { 'X-Housekeeping-Key': KEY, 'Content-Type': 'application/json' },
    body: body ? JSON.stringify(body) : undefined,
  });
  const data = await res.json().catch(() => ({ ok: false, error: { code: 'server', message: 'No JSON' } }));
  if (!data.ok) { const e = new Error(data.error.message); e.code = data.error.code; e.status = res.status; throw e; }
  return data;
}

// report one (safe to repeat with the same ref)
const { issue, duplicate } = await hk('POST', '/issues', {
  ref: 'HK-2026-001234', room: 'Room 14', category: 'Plumbing',
  description: 'Shower drips all night.', priority: 'urgent', reported_by: 'Ama Mensah',
});

// keep up to date
let since = loadSince() || '2026-11-27T00:00:00Z';
for (;;) {
  const { issues, next_since, more } = await hk('GET', '/changes?since=' + encodeURIComponent(since));
  for (const i of issues) saveStatus(i.ref, i.status, i.status_text);
  since = next_since; saveSince(since);
  if (!more) break;
}

Python 3 (with requests)

import os, requests
BASE = "https://ibjmiyehfhsmupsokyqt.supabase.co/functions/v1/housekeeping"
H = {"X-Housekeeping-Key": os.environ["HK_KEY"]}

r = requests.post(BASE + "/issues", headers=H, timeout=20, json={
    "ref": "HK-2026-001234", "room": "Room 14",
    "description": "Shower drips all night.", "priority": "urgent",
})
data = r.json()
if not data["ok"]:
    print(r.status_code, data["error"]["code"], data["error"]["message"])
else:
    print(data["issue"]["status_text"])   # Waiting to be given to an artisan