{"openapi":"3.0.3","info":{"title":"Airbnb Access PIN API","version":"1.0.0","description":"Booking API that issues a temporary, self-expiring door PIN via TTLock once payment is confirmed. Public endpoints handle browsing rooms and creating bookings; admin endpoints (protected by an API key) manage room-to-lock assignments and oversee active bookings."},"servers":[{"url":"https://thehiddendormus/tenisontechnologies.com","description":"Configured server"}],"components":{"securitySchemes":{"adminKey":{"type":"apiKey","in":"header","name":"x-admin-key","description":"Shared admin secret set via ADMIN_API_KEY in the environment."}},"schemas":{"Room":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","example":"Room 2 - Garden View"},"status":{"type":"string","enum":["vacant","occupied","maintenance"]},"pricePerNight":{"type":"string","example":"350.00"}}},"RoomAdmin":{"allOf":[{"$ref":"#/components/schemas/Room"},{"type":"object","properties":{"lockId":{"type":"string","example":"12345678"},"lockSerial":{"type":"string","example":"AA:BB:CC:DD:EE:FF"}}}]},"LockAssignment":{"type":"object","properties":{"lockId":{"type":"string"},"lockAlias":{"type":"string"},"lockMac":{"type":"string"},"assigned":{"type":"boolean"},"assignedRoomId":{"type":"string","format":"uuid","nullable":true},"assignedRoomName":{"type":"string","nullable":true}}},"Guest":{"type":"object","properties":{"name":{"type":"string","example":"Kofi Mensah"},"email":{"type":"string","format":"email"},"phone":{"type":"string","example":"+233201234567"}}},"Booking":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"roomId":{"type":"string","format":"uuid"},"checkIn":{"type":"string","format":"date-time"},"checkOut":{"type":"string","format":"date-time"},"totalAmount":{"type":"string","example":"1050.00"},"paymentStatus":{"type":"string","enum":["pending","paid","failed","refunded","cancelled"]},"pinStatus":{"type":"string","enum":["not_generated","active","expired","revoked","failed"]},"pinCode":{"type":"string","nullable":true,"example":"4821"}}},"CreateBookingRequest":{"type":"object","required":["roomId","checkIn","checkOut","guest"],"properties":{"roomId":{"type":"string","format":"uuid"},"checkIn":{"type":"string","format":"date-time"},"checkOut":{"type":"string","format":"date-time"},"guest":{"$ref":"#/components/schemas/Guest"}}},"CreateBookingResponse":{"type":"object","properties":{"bookingId":{"type":"string","format":"uuid"},"reference":{"type":"string"},"checkoutUrl":{"type":"string","format":"uri"}}},"CreateRoomRequest":{"type":"object","required":["name","lockId","pricePerNight"],"properties":{"name":{"type":"string","example":"Room 4 - Poolside"},"lockId":{"type":"string","example":"12345678"},"pricePerNight":{"type":"number","example":400},"status":{"type":"string","enum":["vacant","occupied","maintenance"]}}},"UpdateRoomRequest":{"type":"object","properties":{"name":{"type":"string"},"lockId":{"type":"string"},"pricePerNight":{"type":"number"},"status":{"type":"string","enum":["vacant","occupied","maintenance"]}}},"PinAuditLog":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"bookingId":{"type":"string","format":"uuid"},"action":{"type":"string","enum":["create","delete","modify","reconcile_check","reconcile_fix"]},"status":{"type":"string","enum":["success","failed"]},"detail":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}}},"ExternalCalendarFeed":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"roomId":{"type":"string","format":"uuid"},"source":{"type":"string","enum":["airbnb","booking_com","other"]},"label":{"type":"string","nullable":true},"feedUrl":{"type":"string","format":"uri"},"lastSyncedAt":{"type":"string","format":"date-time","nullable":true},"lastSyncStatus":{"type":"string","enum":["pending","success","failed"]},"lastSyncError":{"type":"string","nullable":true}}},"AddCalendarFeedRequest":{"type":"object","required":["source","feedUrl"],"properties":{"source":{"type":"string","enum":["airbnb","booking_com","other"]},"feedUrl":{"type":"string","format":"uri","example":"https://www.airbnb.com/calendar/ical/12345.ics?s=abcdef"},"label":{"type":"string","example":"Airbnb - Room 2 listing"}}},"Error":{"type":"object","properties":{"error":{"type":"string"}}}}},"paths":{"/api/rooms":{"get":{"summary":"List all rooms (public view)","description":"Returns room name, status, and price. Lock IDs are never exposed on this public endpoint.","tags":["Rooms - Public"],"responses":{"200":{"description":"List of rooms","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Room"}}}}}}}},"/api/rooms/available":{"get":{"summary":"List rooms available for a given date range","description":"Excludes rooms with an overlapping paid internal booking OR an overlapping block synced from a connected Airbnb/Booking.com calendar.","tags":["Rooms - Public"],"parameters":[{"in":"query","name":"checkIn","required":true,"schema":{"type":"string","format":"date-time"}},{"in":"query","name":"checkOut","required":true,"schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"Rooms with no overlapping booking or external block in the window","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"pricePerNight":{"type":"string"}}}}}}},"400":{"description":"Missing checkIn/checkOut params","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/calendar/{token}.ics":{"get":{"summary":"Export a room's booked dates as an iCal feed","description":"Public URL (no admin key) protected only by an unguessable per-room token. Paste this into the \"Import calendar\" / \"Sync calendar\" field in your Airbnb listing settings and your Booking.com extranet so those platforms block out dates booked through this system. Contains dates only - no guest names, emails, or phone numbers.\n","tags":["Calendar Sync - Public"],"parameters":[{"in":"path","name":"token","required":true,"schema":{"type":"string","format":"uuid"},"description":"Room's icalExportToken (get it from GET /api/admin/rooms/{id}/export-url)"}],"responses":{"200":{"description":"iCal (.ics) feed","content":{"text/calendar":{"schema":{"type":"string"}}}},"404":{"description":"No room matches this token"}}}},"/api/admin/overview":{"get":{"summary":"Room grid with each room's current active booking, if any","tags":["Admin - Dashboard"],"security":[{"adminKey":[]}],"responses":{"200":{"description":"Rooms with nested active booking and guest info"},"401":{"description":"Missing or invalid admin key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/bookings":{"get":{"summary":"Full booking history (most recent 200)","tags":["Admin - Dashboard"],"security":[{"adminKey":[]}],"responses":{"200":{"description":"List of bookings with room and guest included"},"401":{"description":"Missing or invalid admin key"}}}},"/api/admin/bookings/{id}/audit":{"get":{"summary":"Lock action audit trail for one booking","tags":["Admin - Dashboard"],"security":[{"adminKey":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Ordered list of audit log entries","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PinAuditLog"}}}}},"401":{"description":"Missing or invalid admin key"}}}},"/api/admin/bookings/{id}/revoke":{"post":{"summary":"Manually revoke a guest's PIN early","description":"Deletes the passcode from the lock immediately (e.g. early checkout, dispute, or cancellation).","tags":["Admin - Dashboard"],"security":[{"adminKey":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","example":"guest checked out early"}}}}}},"responses":{"200":{"description":"Updated booking","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Booking"}}}},"401":{"description":"Missing or invalid admin key"},"500":{"description":"Revocation failed (e.g. lock unreachable)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/locks":{"get":{"summary":"List every lock on the TTLock account and its room assignment status","description":"Use this to populate the lock dropdown when adding or editing a room - only shows unassigned locks as available.","tags":["Admin - Rooms & Locks"],"security":[{"adminKey":[]}],"responses":{"200":{"description":"Locks with assignment info","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/LockAssignment"}}}}},"401":{"description":"Missing or invalid admin key"}}}},"/api/admin/rooms":{"get":{"summary":"List all rooms with full details (including lock IDs)","tags":["Admin - Rooms & Locks"],"security":[{"adminKey":[]}],"responses":{"200":{"description":"Full room list","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/RoomAdmin"}}}}},"401":{"description":"Missing or invalid admin key"}}},"post":{"summary":"Add a new room and link it to a TTLock device","tags":["Admin - Rooms & Locks"],"security":[{"adminKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateRoomRequest"}}}},"responses":{"201":{"description":"Room created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomAdmin"}}}},"400":{"description":"Missing required fields","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"lockId not found on the TTLock account","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Lock is already assigned to another room","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/rooms/{id}":{"get":{"summary":"Get one room's full details","tags":["Admin - Rooms & Locks"],"security":[{"adminKey":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Room details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomAdmin"}}}},"404":{"description":"Room not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Edit a room's details or reassign its lock","description":"Refuses to reassign the lock while the room has an active booking.","tags":["Admin - Rooms & Locks"],"security":[{"adminKey":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateRoomRequest"}}}},"responses":{"200":{"description":"Updated room","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomAdmin"}}}},"404":{"description":"Room or lockId not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Lock already assigned elsewhere, or room has an active booking","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete a room","description":"Refuses if the room has any booking history - set status to 'maintenance' instead to take it out of service.","tags":["Admin - Rooms & Locks"],"security":[{"adminKey":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"204":{"description":"Room deleted"},"404":{"description":"Room not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Room has booking history and cannot be deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/rooms/{id}/export-url":{"get":{"summary":"Get the iCal export URL to paste into Airbnb/Booking.com","description":"Returns the full .ics URL for this room. Paste it into Airbnb's listing calendar \"Import calendar\" field and Booking.com's extranet calendar sync settings.","tags":["Admin - Calendar Sync"],"security":[{"adminKey":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Export URL","content":{"application/json":{"schema":{"type":"object","properties":{"exportUrl":{"type":"string","format":"uri"}}}}}},"404":{"description":"Room not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/rooms/{id}/calendar-feeds":{"get":{"summary":"List external calendar feeds (Airbnb/Booking.com) imported for this room","tags":["Admin - Calendar Sync"],"security":[{"adminKey":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"List of feeds","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ExternalCalendarFeed"}}}}},"404":{"description":"Room not found"}}},"post":{"summary":"Add an Airbnb/Booking.com calendar feed to import into this room","description":"Get the feed URL from Airbnb (listing → Availability → Sync calendars → Export calendar) or Booking.com (extranet → Calendar → Sync calendars). Runs an immediate first sync.\n","tags":["Admin - Calendar Sync"],"security":[{"adminKey":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddCalendarFeedRequest"}}}},"responses":{"201":{"description":"Feed added (check initialSync for immediate sync result)","content":{"application/json":{"schema":{"type":"object","properties":{"feed":{"$ref":"#/components/schemas/ExternalCalendarFeed"},"initialSync":{"type":"object"}}}}}},"400":{"description":"Missing or invalid source/feedUrl","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Room not found"}}}},"/api/admin/calendar-feeds/{feedId}":{"delete":{"summary":"Remove an external calendar feed and its synced blocks","tags":["Admin - Calendar Sync"],"security":[{"adminKey":[]}],"parameters":[{"in":"path","name":"feedId","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"204":{"description":"Feed deleted"},"404":{"description":"Feed not found"}}}},"/api/admin/calendar-feeds/{feedId}/sync":{"post":{"summary":"Manually trigger an immediate resync of one feed","description":"Normally feeds sync automatically every 30 minutes - use this to force a resync right away (e.g. right after a guest books on Airbnb).","tags":["Admin - Calendar Sync"],"security":[{"adminKey":[]}],"parameters":[{"in":"path","name":"feedId","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Sync result"},"404":{"description":"Feed not found"},"502":{"description":"Could not fetch or parse the external feed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/bookings":{"post":{"summary":"Create a booking hold and start payment","description":"Creates a 'pending' booking and returns a Paystack checkout URL. The room is not marked occupied and no PIN is generated until the payment webhook confirms the charge succeeded.\n","tags":["Bookings - Public"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateBookingRequest"}}}},"responses":{"201":{"description":"Booking hold created; redirect the guest to checkoutUrl","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateBookingResponse"}}}},"400":{"description":"Missing or invalid fields","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Room not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Room not available for the selected dates (internally booked or blocked by a synced Airbnb/Booking.com reservation)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/bookings/{id}":{"get":{"summary":"Get booking status (for the guest's \"your access code\" screen)","description":"Poll this after payment. pinCode is only included once pinStatus is 'active' - it is omitted while pending or if issuance failed.\n","tags":["Bookings - Public"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Booking status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Booking"}}}},"404":{"description":"Booking not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"tags":[]}