Read this first#
Four facts decide most of your design, and all four cost less to accept now than to discover in week three.
- Hospitality is authoritative for the redemption. Your till asks Hospitality to spend value and Hospitality decides. It does not ask your system for permission, and it does not wait for your system to confirm. If you need the discount to land on the customer's real bill, that is a second step your till performs after Hospitality has said yes.
- A till or a feed is an API client, never a person. The operator issues your system its own client id and secret, bound to one venue and to the contact your system acts as. Everything you may do follows from that venue's capabilities, enforced on the server. People sign in with their own member login; there is no PIN or shared staff sign-in to borrow.
- Every write is idempotent by an identity you supply. A value operation needs an idempotency key you generate and persist — per business operation, not per HTTP attempt; a call without one is refused. A stay or visit needs your system's own id for it, and sending it again updates the same record rather than creating a second.
- You push; Hospitality never pulls. It does not poll your PMS or POS and it sends no webhooks. A stay or visit exists in HubSpot because your system sent it.
Base URL: https://<the portal's public domain>/hs/serverless/
JSON in, JSON out. Every response carries success, and every failure carries a structured code you can switch on. The portal's domain is the customer's own HubSpot site domain — ask the operator for it, and do not assume it matches any other environment.
Authenticating a till or a feed: an API client#
A till, a booking engine, a POS vendor, any system — your integration gets an API client: a credential issued to your system alone, which the operator can switch off or re-key without touching any other till or feed. There is no PIN and no staff e-mail sign-in, for anyone. Status: Live (proven on a portal 4 November 2026: mint, a feed through it, disable, re-enable, a new secret and delete).
The operator creates the client (a client id such as pos-front-desk, the venue it acts at, the
contact it acts as) and gives you its id and a secret of at least 32 characters over a secure
channel. You exchange them for a token — once per till, then reuse it until it is refused:
POST /hs/serverless/hospitality-client-session
Content-Type: application/json
{ "clientId": "pos-front-desk", "clientSecret": "<the secret the operator gave you>" }
{ "success": true, "token": "<service token>", "tokenClass": "service", "expiresAt": 1786000000000,
"clientId": "pos-front-desk", "contactId": "…",
"location": { "id": "…", "name": "…", "locationType": "…", "capabilities": ["redeem", "earn"] } }
- Send it as
staffTokenin the JSON body of every authenticated call (never a header — the platform drops custom headers). It works with the capabilities of the venue the operator bound your client to — includingingestif that venue carries it. - It expires after 60 minutes by default. On
401withSTAFF_TOKEN_INVALIDorSTAFF_TOKEN_REQUIRED, mint again and retry the call once. Do not treat it as fatal, and do not re-mint on every request. - One answer for every bad credential: an unknown client id, a client without a secret and a
wrong secret all get
401 CLIENT_AUTH_FAILED. Do not retry in a loop; check what you were given. - When the operator acts on your client: disabled → your calls get
401 SERVICE_TOKEN_REVOKEDand a new mint gets403 CLIENT_DISABLED(enabling it again revives the same tokens); a new secret → every token minted with the old one is refused for good, and only the new secret mints; deleted →401 SERVICE_TOKEN_REVOKED. A change takes effect within seconds of the operator saving it. Stop and contact the operator — none of these is a retry case. - One client, one venue. A multi-till site asks for one client per till, which also gives per-till attribution — every ledger row records the client's contact.
- Rotating the portal's signing secret ends every token at once; your till re-mints with its own, unchanged secret. Build the 401 path first and you get this for free.
- The token and the secret are credentials. HTTPS only, never logged, never in a receipt or a URL, stored the way you would store a password.
A feed signs in the same way, with a client bound to a venue that has ingest. That
capability is privileged and never a default — typically one head-office venue per portal. That
venue does not limit where records land: each record names its own venue. Keep value and facts on
separate clients where you can — a till's redeem client at its own counter venue, and an ingest
client at the venue that holds ingest.
Who else signs in, and how — for orientation; neither is a way in for your system:
- People — the staff at a counter using the app's own scanner — sign in with their own HubSpot member login on the customer's site; the operator switches scanner access on per person.
- Our own sibling apps (Commerce, Events), installed on the same portal, are linked: each proves which app it is with a short-lived signed app assertion, checked against a public key it published on the portal, and acts as itself at its own venue. Nothing is configured or shared.
What a scan contains#
Your scanner will meet two payload shapes, whether the QR is printed, in an email, or on the guest's phone in their wallet:
| Scanned thing | Payload | What it means |
|---|---|---|
| Member loyalty card, or the membership QR in the wallet | A wallet URL — https://<domain>/wallet?t=<token> | Identity. Take the t parameter; that is the input to hospitality-resolve-token |
| Voucher or gift card, printed or the voucher QR in the wallet | The code itself — 12 letters and digits, e.g. K72M8DMAAA5B | Value. The code is the record's identifier — input to hospitality-fetch-incentive and to a redeem |
The parsing rule, which mirrors the scanner's own: if the payload is a URL, take ?t= when it holds a token, otherwise ?id= or the last path segment when either is a 12-character code. A bare xxxxx.yyyyy base64url pair is a token. A 12-character run of letters and digits is a code; codes are case-insensitive and the server uppercases them. Anything else is not ours — an EVT-… code is an Events ticket, which our scanner hands to the Events scanner when that pairing is configured.
Warning
If you decode token payloads in a browser, re-pad the base64url before decoding. Browsers reject unpadded base64 where server-side decoders accept it, so this works in your Node prototype and fails on the tablet.
Endpoint index#
Generated by cross-checking two independent sources inside the app — the deployment manifests that tell HubSpot what to publish, and the policy manifest whose own test asserts full coverage against them. Neither the list nor the auth column is typed by hand, and a disagreement between them fails the build rather than producing a plausible table.
Public, Staff and Customer are surfaces you may call. Workflow endpoints are HubSpot automation backends and Install endpoints belong to provisioning; both are listed for completeness and are not part of your contract, which is why this page does not document them. Retired endpoints still answer, with 410 — they are listed precisely so a cached client gets an explanation instead of a mystery.
34 endpoints — 7 public, 9 staff, 4 customer, 2 admin, 4 workflow, 4 server-to-server, 2 install, 2 retired.
| Endpoint | Surface | Auth required |
|---|---|---|
GET/POST hospitality-fetch-locations | Public | None |
GET/POST hospitality-reports | Public | None (no personal data) |
GET/POST hospitality-workflow-options | Public | None (no personal data) |
POST hospitality-claim-incentive | Public | None |
POST hospitality-fetch-incentive | Public | None |
POST hospitality-fetch-product | Public | None |
POST hospitality-whoami | Public | None |
POST hospitality-enrollment-create | Staff | Staff token + the location capability for the action |
POST hospitality-enrollment-search | Staff | Staff token + the location capability for the action |
POST hospitality-generate-incentives | Staff | Staff token + the location capability for the action |
POST hospitality-ingest-stay | Staff | Staff token + the location capability for the action |
POST hospitality-ingest-visit | Staff | Staff token + the location capability for the action |
POST hospitality-print-member-card | Staff | Staff token + the location capability for the action |
POST hospitality-staff-config | Staff | Staff token + the location capability for the action |
POST hospitality-staff-home | Staff | Staff token + the location capability for the action |
POST hospitality-transact | Staff | Staff token + the location capability for the action |
POST hospitality-fetch-wallet | Customer | Customer token — identity comes from the token |
POST hospitality-offer-decision | Customer | Customer token — identity comes from the token |
POST hospitality-request-link | Customer | Customer token — identity comes from the token |
POST hospitality-resolve-token | Customer | Customer token — identity comes from the token |
POST hospitality-member-session | Admin | Authenticated user: a CRM card, or a signed-in member |
POST hospitality-staff-session | Admin | Authenticated user: a CRM card, or a signed-in member (the signed-in member, who must have scanner access; nothing in the body identifies the caller) |
POST hospitality-workflow-award-points | Workflow | HubSpot signature (v3) |
POST hospitality-workflow-enroll | Workflow | HubSpot signature (v3) |
POST hospitality-workflow-issue-voucher | Workflow | HubSpot signature (v3) |
POST hospitality-workflow-mint-magic-link | Workflow | HubSpot signature (v3) |
GET/POST hospitality-qr-sheet | Server-to-server | Portal + shared secret |
POST hospitality-app-session | Server-to-server | Signed by a linked app on the same portal |
POST hospitality-client-session | Server-to-server | Portal + shared secret |
POST hospitality-link-sweep | Server-to-server | Signed by a linked app on the same portal |
GET hospitality-status | Install | None |
POST hospitality-bootstrap | Install | Portal + shared secret (deliberate — it runs before any token can exist) |
POST hospitality-user-create | Retired | Retired — returns 410 ENDPOINT_RETIRED |
POST hospitality-user-lookup | Retired | Retired — returns 410 ENDPOINT_RETIRED |
Use case → endpoint#
| What your system needs to do | Call | Requires |
|---|---|---|
| Read a voucher or gift card — balance, type, validity, whether it is claimed | hospitality-fetch-incentive { incentiveId: <code> } | nothing |
| Identify a guest from a scanned member card | hospitality-resolve-token { token, staffToken } | the scanned token proves identity; adding a staff token also records the identification |
| List venues and their capabilities | hospitality-fetch-locations | nothing |
| Read what can be issued or awarded here | hospitality-staff-config { staffToken } | staff token |
| Read today's activity at this venue | hospitality-staff-home { staffToken } | staff token |
| Redeem a voucher in full | hospitality-transact action: "redeem" { code } | redeem capability |
| Spend part of a gift-card balance | hospitality-transact action: "redeem" { code, amount } | redeem capability |
| Top up a gift-card balance | hospitality-transact action: "reload" { recordId, amount } | issue capability |
| Issue a voucher from the catalogue | hospitality-transact action: "issue" { templateKey, contactId | email } | issue capability |
| Award points from a spend amount — also records the sale as a visit | hospitality-transact action: "award" { contactId | email, programId, amount } | earn capability |
| Award a literal number of points | hospitality-transact action: "award" { contactId | email, programId, points } | earn capability |
| Reverse a transaction | hospitality-transact action: "void" { transactionId } | staff token |
| Enrol a guest at the counter | hospitality-enrollment-search then hospitality-enrollment-create | staff token |
| Create vouchers in bulk for a campaign | hospitality-generate-incentives | staff token |
| Push stays from a booking engine or PMS | hospitality-ingest-stay { records: [stay, …] } | ingest capability |
| Push visits from a POS, till or spa system | hospitality-ingest-visit { records: [visit, …] } | ingest capability |
| Read aggregate numbers, with no personal data | hospitality-reports | nothing |
There is no hard delete. Hospitality is a ledger: reversing something is void, which writes a compensating row and leaves the original visible.
Warning
There is no unauthenticated contact lookup, and there will not be one. Two endpoints that once offered it — hospitality-user-lookup and hospitality-user-create — were withdrawn in a security review: one returned a contact's phone, address and company to anyone who guessed an email, and the other wrote to a contact record without checking the caller owned it. They still answer, with 410 ENDPOINT_RETIRED, so a cached client gets an explanation. If your design needs to find a guest without a scan, resolve them through a staff-gated call instead.
The flows at the counter#
Scan a voucher, show it, redeem it#
Read before you charge, so the cashier can see what they are holding:
POST /hs/serverless/hospitality-fetch-incentive
{ "incentiveId": "K72M8DMAAA5B" }
{
"success": true,
"incentive": {
"hs_object_id": "59134760886",
"incentive_id": "K72M8DMAAA5B",
"incentive_type": "voucher",
"redemption_type": "balance",
"value": 50,
"initial_balance": 50,
"current_balance": 32.5,
"discount_unit": "currency",
"discount_mode": null,
"currency": "EUR",
"expiry_date": null,
"status": "active",
"incentive_sku": null,
"is_personal": false,
"valid_scope": "all",
"is_expired": false,
"where_valid": [],
"is_claimed": true,
"is_claimable": true,
"fetchedAt": "2026-11-04T19:30:00.000Z",
"display_value": "EUR 32.5 remaining"
},
"message": "Incentive fetched successfully"
}
display_value is pre-formatted for a cashier-facing screen, so you need not reconstruct it from the balance and currency. is_claimed and is_claimable are independent — a claimed instrument can still be claimable — so do not treat one as the negation of the other. An unknown code answers 404 with an error and no code.
Then the mutation:
POST /hs/serverless/hospitality-transact
{
"action": "redeem",
"staffToken": "<staff token>",
"idempotencyKey": "<a UUID your till generated and stored>",
"code": "K72M8DMAAA5B",
"amount": 12.5
}
{ "success": true, "transactionId": "<id>", "remainingBalance": 20 }
- Omit
amounton a balance instrument to spend the whole remaining value. - An empty
where_validmeans valid anywhere. Otherwise a redeem at the wrong venue returns409 INVALID_LOCATIONwith the list of venues where it would work — show that to the cashier rather than retrying silently. - A repeat with the same
idempotencyKeyreturnssuccess: true, duplicate: trueand the unchanged state. Never a double charge. - Pass
recordIdinstead ofcodefor a voucher created moments ago — code lookup goes through a search index that lags writes by seconds.

That is our own scanner, and it is a plain HTTP client of the endpoints above — the screen your till is replacing, or sitting beside. The venue name and capability chips along the top are the authority model made visible: this device may redeem here because the venue record says so, and the server re-checks that on the call rather than trusting what the screen believes.
Scan a member card, identify, award points#
POST /hs/serverless/hospitality-resolve-token
{ "token": "<the t parameter from the card>", "staffToken": "<staff token>" }
{
"success": true, "valid": true, "tokenClass": "member",
"expiresAt": 1817818040684,
"identified": false,
"contact": { "id": "236761208998", "firstName": "Sarah", "lastName": "Johnson" },
"memberships": [
{ "membershipId": "…", "programId": "…", "programName": "Rewards Club",
"pointsName": "Points", "accentColor": "#2680c2",
"pointsBalance": 292, "tier": null, "joinedDate": "2026-07-21" }
],
"incentives": [
{ "recordId": "…", "code": "NA3J43C2AEBB", "redemptionType": "balance",
"currentBalance": 37.5, "currency": "EUR", "status": "active",
"engagementStatus": "viewed", "claimedAt": null, "redeemedAt": null }
],
"ledger": [
{ "transactionId": "…", "label": "Earn +42 Points · Rewards Club",
"reason": "earn", "pointsDelta": 42, "valueDelta": null,
"occurredAt": 1786282058164, "voided": false }
],
"pointsEarnedLifetime": 292
}
The response carries name only — never email or phone. That is deliberate data minimisation on a device that stands on a counter, and it is not a gap to work around.
Two things about this response cost time if you meet them by surprise:
identifiedis not "did we recognise them". It reports whether an identification was recorded against a venue, which happens only when you send astaffTokenand that venue holds theidentifycapability. Reading a member card without one returnsidentified: falsealongside a perfectly valid contact — checkvalidandcontact, neveridentified, to decide whether you know who this is.- The casing changes between endpoints. This response is camelCase (
currentBalance,redemptionType,pointsBalance) whilehospitality-fetch-incentivereturns the CRM property names in snake_case (current_balance,redemption_type). The two describe the same instrument. That is a wart rather than a design, and it is not going to change under you — but map both explicitly rather than assuming one shape.
POST /hs/serverless/hospitality-transact
{
"action": "award",
"staffToken": "<staff token>",
"idempotencyKey": "<UUID>",
"contactId": "<from resolve>",
"programId": "<from staff-config>",
"amount": 87.40
}
amount is the spend, converted by the programme's earn rate. Send points instead for a literal delta — which may be negative for a correction, and may never be zero.
An award with amount is also a visit. Hospitality records the sale as a purchase visit at your venue, earns the points on that visit, and rebuilds the guest's profile; the response gains a visitId. A retry with the same idempotencyKey finds the same visit and earns nothing twice. If the visit cannot be written, the award answers 502 VISIT_WRITE_FAILED with no point moved — retry with the same key. If only the profile rebuild fails, the award still succeeds and carries a guestProfileWarning. An award with points and no amount writes no visit.
Important
One sale, one report. Because an award with amount already records the sale as a visit, do not also push that sale to hospitality-ingest-visit — the two reports carry different identities, so the guest's spend would count twice. Either award from the spend, or push the visit and award with points.
Pushing stays and visits#
A booking engine or PMS pushes stays; a POS, till or spa system pushes visits. A stay becomes a deal in the portal's Stays pipeline, a visit becomes a visit record, and both are linked to the guest's contact — after which that guest's profile is rebuilt from their facts. Both endpoints take a batch and answer per record.
| Path | Body | Requires |
|---|---|---|
POST hospitality-ingest-stay | { staffToken, records: [stay, …] } | a staff token minted at a venue with ingest |
POST hospitality-ingest-visit | { staffToken, records: [visit, …] } | the same |
Send the token in the body, as everywhere else on this surface. We have seen HubSpot's ingress drop custom request headers before they reach the function, so do not rely on a header-borne token.
A stay, and a visit during it#
POST /hs/serverless/hospitality-ingest-stay
Content-Type: application/json
{
"staffToken": "<token minted at the venue with ingest>",
"records": [
{
"source_system": "pms",
"source_record_id": "RES-48213",
"status": "confirmed",
"arrival_date": "2026-12-18",
"departure_date": "2026-12-21",
"externalGuestId": "G-90211",
"email": "ann@example.com",
"locationExternalId": "HOTEL-01",
"guests": [{ "email": "ben@example.com" }],
"booking_reference": "48213",
"accommodation_type": "Double room",
"adults": 2,
"booking_channel": "direct_web",
"total_value": 642,
"currency": "EUR"
}
]
}
POST /hs/serverless/hospitality-ingest-visit
Content-Type: application/json
{
"staffToken": "<token minted at the venue with ingest>",
"records": [
{
"source_system": "pos-restaurant",
"source_record_id": "T-20261219-0042",
"occurred_at": "2026-12-19T20:15:00Z",
"externalGuestId": "G-90211",
"locationExternalId": "RESTAURANT-01",
"visit_type": "purchase",
"amount": 86.5,
"currency": "EUR",
"covers": 2
}
]
}
The stay names its lead booker by both an external id and an email. If no contact carries G-90211 yet, the stay finds the guest by email and writes the id onto that contact — which is why the visit can name her by the id alone, once HubSpot's search has caught up a few seconds later (within one call it is immediate). The visit falls inside the stay's dates at a venue of the same brand as the hotel, so it attaches to the stay.
The answer is 200 with one result per record, in order:
{
"success": true,
"kind": "visit",
"received": 1,
"summary": { "created": 1, "updated": 0, "skipped": 0, "error": 0 },
"results": [
{ "index": 0, "source_system": "pos-restaurant", "source_record_id": "T-20261219-0042",
"status": "created", "id": "<visit id>", "contactId": "<contact id>",
"venueId": "<venue id>", "venueCategory": "fnb", "stayId": "<stay deal id>",
"attribution": "same_brand", "warnings": [] }
],
"touchedContactIds": ["<contact id>"],
"profiles": { "recomputed": ["<contact id>"], "failed": [], "deferred": [] },
"location": { "id": "<your client's venue id>", "name": "<your client's venue name>" }
}
statusiscreated,updated,skipped(nothing written — send it again) orerror(nothing written for this record — seecodeanderror).successis true only when every record was created or updated. A bad record never stops the rest of the batch, so readresults, not only the HTTP status.profilesreports the guest-profile rebuild for every contact a record touched. Afailedordeferredrebuild never fails the call and never un-writes a record; the next delivery for that guest, or the operator's full recompute, catches it up.warningsare problems that did not stop the record — a co-guest that could not be found, an external guest id that could not be linked.
Retries never duplicate#
Every record carries source_system + source_record_id — your system's name (1–40 characters of A–Z a–z 0–9 . _ -) and your id for the record (up to 200 characters). Together they form a unique key that is claimed in the same write that creates the record:
- The same record sent again updates the same CRM record. It never creates a second one — including in the seconds after a write while HubSpot's search index has not caught up. The endpoint never searches for a stay or visit to decide between create and update.
- An update writes only the fields you send; a field you leave out is not blanked. Associations only grow — an update never removes a guest or a link an earlier delivery made.
- The same identity twice in one call: the second comes back
skippedwithDUPLICATE_IN_BATCH.
So the retry rule is simple: on a timeout, a 5xx, or a skipped result, send the same records again.
Who the record is about#
Each record names its guest by contactId, externalGuestId or email, tried in that order. Ingest never creates contacts.
| Outcome | Result |
|---|---|
| Found | The record is linked to that contact |
| None of the three sent | error / MISSING_CONTACT |
A contactId that does not exist, or nothing matches | error / UNKNOWN_CONTACT. Nothing is written. Create the contact, then send the record again |
| Two contacts match | error / AMBIGUOUS_CONTACT |
externalGuestIdis your system's id for the guest. It lives on the contact as External guest ID, which is unique. When you send it and the contact is found bycontactIdoremailinstead, the id is written onto that contact — if it has none yet — so later deliveries can send the id alone, including later records in the same call.emailmatches case-insensitively.- Matching by
externalGuestIdoremailgoes through HubSpot's search, which lags writes by seconds. A contact created a moment ago may answerUNKNOWN_CONTACT; send the record again shortly, or send itscontactId.
Stay fields (hospitality-ingest-stay)#
| Field | Required | Notes |
|---|---|---|
source_system, source_record_id | yes | the identity |
arrival_date, departure_date | yes | YYYY-MM-DD, real dates, departure not before arrival |
status | no — confirmed | enquiry · option · confirmed · checked_in · checked_out · cancelled · no_show — the stage in the Stays pipeline |
contactId / externalGuestId / email | yes | the lead booker |
locationId or locationExternalId | yes | the property. locationExternalId matches the venue's own external record id, set by the operator |
guests | no | [{ contactId | externalGuestId | email }], at most 20. An unknown co-guest is a warning, not an error |
booking_reference, nights, accommodation_type, accommodation_unit, party_size, adults, children, booking_channel, booking_date, total_value, currency, purpose, notes, label | no | nights and party_size are derived when left out. booking_channel: direct_web · app · phone · ota · agent · business · other. purpose: leisure · business · group · event |
companyId | no | for business bookings |
Record errors: INVALID_STAY (a bad date, a departure before the arrival, an unknown status, channel or purpose, a negative value), MISSING_IDENTITY, INVALID_SOURCE, INVALID_RECORD, MISSING_PROPERTY, UNKNOWN_LOCATION, AMBIGUOUS_LOCATION, and the contact codes above.
Visit fields (hospitality-ingest-visit)#
| Field | Required | Notes |
|---|---|---|
source_system, source_record_id | yes | the identity |
occurred_at | yes | epoch milliseconds or an ISO datetime |
contactId / externalGuestId / email | yes | the guest |
locationId or locationExternalId | no | the venue. Left out, it is your client's venue — a till posting for its own counter |
visit_type | no — purchase | purchase · reservation · attendance · treatment · booking |
status | no — completed | booked · completed · cancelled · no_show. Only completed visits count as spend on the profile. reversed undoes an earlier visit — below |
amount, currency, covers, items_count, external_reference, notes, label | no | numbers zero or more, counts whole |
venue_category | no | accommodation · fnb · retail · wellness · activities · other. By default a snapshot of the venue's own revenue category |
stay_reference | no | forces the link to a stay — below |
Record errors: INVALID_VISIT (a bad occurred_at, an unknown type, status or category, a negative amount), STAY_NOT_FOUND, AMBIGUOUS_STAY, plus the identity, location and contact codes.
Undoing a sale. When a sale you reported is refunded in full or charged back, send the same record — the same source_system and source_record_id — with status: "reversed". Hospitality marks that visit reversed (it keeps the sale's own date; the reversal's occurred_at is not written), takes it out of the guest's spend and visit count, and voids the points it earned, once. The result's status is reversed, or unchanged when it was already reversed or never existed (code: "VISIT_NOT_FOUND" — nothing is created); neither is a failure. A voucher redeemed with the sale stays redeemed: that is the operator's call.
How a visit finds its stay#
- By rule, when no
stay_referenceis sent. The visit is linked when it falls inside a stay of the same guest at the same property — the visit's venue is the stay's property (attribution: "same_venue"), or carries the same brand, as a resort's restaurant does ("same_brand"). Inside runs from the arrival day 00:00 UTC to the end of the departure day. Onlyconfirmed,checked_inandchecked_outstays attract visits. When several qualify, the exact venue beats the brand, then the latest arrival wins. Anything else is a day visit:attribution: "none",stayId: null. The same-venue rule is proven on a portal; the same-brand rule is tested offline but not yet seen on one. - By
stay_reference, which forces the link whatever the dates or venue ("stay_reference"). It matches a stay'sbooking_reference, itssource_record_id, or its record id. A reference that matches nothing is an error (STAY_NOT_FOUND), never a quiet day visit — a stay pushed moments ago for another guest may not be searchable yet, so send the visit again later. - Attribution happens when the visit arrives. Push stays before their visits. A stay that arrives after its visits does not pick them up unless they are sent again.
Points from a visit#
The operator can switch on earn points on visits (off by default). Then a completed visit with an amount, at an active venue holding earn, for a guest whose membership covers that venue, earns once — keyed on the visit, so a resend never earns twice — and every visit result carries an earn block with applied, duplicate, skipped (with a reason), refused or error. The visit is written either way. This path is built and tested but has not yet run on a portal; confirm it on yours before depending on it.
Batch size and time#
- At most 50 records per call — more is refused with
400 BATCH_TOO_LARGEbefore anything is read. - No record starts after 14 seconds, because HubSpot stops the function at 20. Records that did not start come back
skipped/TIME_BUDGET; send exactly those again. A record costs roughly four to eight CRM calls, so 20–30 records is the comfortable size, and nearer 15–20 with points on visits switched on. - There is no rate limit on the ingest call itself.
| Call-level answer | HTTP | What your system should do |
|---|---|---|
INVALID_JSON, INVALID_BODY | 400 | Fix the payload; nothing was processed |
BATCH_TOO_LARGE | 400 | Split the batch |
STAFF_TOKEN_REQUIRED / STAFF_TOKEN_INVALID | 401 | Re-mint, retry once |
CAPABILITY_MISSING | 403 | Your client's venue lacks ingest. An operator decision; nothing was written |
GUEST_MODEL_NOT_INSTALLED | 503 | Stays and visits are not set up on this portal. Stop and call the operator |
NOT_BOOTSTRAPPED | 503 | The app is not initialised on this portal. Stop and call the operator |
Our own apps push the same way#
Commerce and Events report through hospitality-ingest-visit like any other source, under one rule: the app that took the money reports the sale.
| Fact | Reported by | source_system | visit_type |
|---|---|---|---|
| A paid webshop or quote order | Commerce | commerce | purchase |
| A paid event ticket group | Events (Commerce skips orders Events owns) | events | purchase |
| A door check-in | Events | events | attendance |
If your till sells something one of those apps also sells, decide which system reports it — never both. Both pushes are off until the operator switches them on in that app.
Idempotency#
Two mechanisms, one principle: the identity of the operation comes from you, and it is stable across retries.
| Call | The identity | A repeat answers |
|---|---|---|
hospitality-transact | idempotencyKey — required, or refused with IDEMPOTENCY_KEY_REQUIRED | success: true, duplicate: true and the current state |
hospitality-ingest-stay, -visit | source_system + source_record_id on each record | status: "updated" on the same record id |
For hospitality-transact:
- Generate one UUID per business operation — per sale line, not per HTTP attempt.
- Persist it before you send, alongside the sale, and reuse it for every retry of that operation.
- Treat
duplicate: trueas success. It is: the state it returns is authoritative.
For ingest, use the id your own system already has — the reservation number, the receipt number — and never generate a new one on a retry.
The failure this prevents is the ordinary one. A till sends a redeem, the network times out after the server committed, the till retries. Without a stable key that is two redemptions and an angry customer — or, for a visit, a guest whose spend counts twice.
A reference client#
Every integration writes this, and the parts that get written wrong are always the same three: re-minting on a 401, generating the idempotency key in the wrong place, and retrying a network failure as though it were a failed redemption. Here it is, in about sixty lines, with those three done properly, plus the ingest call.
// hospitality.js — minimal reference client. No dependencies; Node 18+ or a browser.
export class Hospitality {
// `store` persists idempotency keys across a crash — a Map is fine for a demo,
// but a real till needs the key on disk BEFORE the request goes out.
constructor({ baseUrl, clientId, clientSecret, store = new Map() }) {
Object.assign(this, { baseUrl, clientId, clientSecret, store });
this.token = null;
}
async #post(path, body) {
const res = await fetch(`${this.baseUrl}/hs/serverless/${path}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
return { status: res.status, data: await res.json() };
}
async signIn() {
const { data } = await this.#post('hospitality-client-session', {
clientId: this.clientId, clientSecret: this.clientSecret,
});
if (!data.success) throw new Error(`sign-in refused: ${data.code}`);
this.token = data.token;
}
// One re-mint, then give up. Re-minting on every call defeats the point of a
// token; never re-minting turns a routine expiry into a dead till.
async #authed(path, body) {
if (!this.token) await this.signIn();
let r = await this.#post(path, { ...body, staffToken: this.token });
if (r.status === 401 && /STAFF_TOKEN_(INVALID|REQUIRED)/.test(r.data.code || '')) {
await this.signIn();
r = await this.#post(path, { ...body, staffToken: this.token });
}
return r;
}
fetchIncentive(code) {
return this.#post('hospitality-fetch-incentive', { incentiveId: code });
}
// saleId is YOUR id for the sale line — stable across retries, which is the
// whole contract. Deriving the key from it means a retry cannot double-spend.
async transact(saleId, action, fields) {
let key = this.store.get(saleId);
if (!key) { key = crypto.randomUUID(); this.store.set(saleId, key); } // persist BEFORE sending
const { status, data } = await this.#authed('hospitality-transact', {
action, idempotencyKey: key, ...fields,
});
if (data.success) return data; // duplicate:true is success — state is authoritative
if (status === 429) {
await new Promise((r) => setTimeout(r, data.retryAfterMs ?? 1000));
return this.transact(saleId, action, fields); // same key, so this is safe
}
throw Object.assign(new Error(data.error || data.code), { code: data.code, data });
}
// kind is 'stay' or 'visit'. Each record's source identity is its idempotency
// key, so sending a record again is always safe. Returns what to send again.
async ingest(kind, records) {
const { data } = await this.#authed(`hospitality-ingest-${kind}`, { records });
if (!Array.isArray(data.results)) { // refused as a whole: nothing processed
throw Object.assign(new Error(data.error || data.code), { code: data.code, data });
}
return {
resend: data.results.filter((r) => r.status === 'skipped').map((r) => records[r.index]),
errors: data.results.filter((r) => r.status === 'error'), // e.g. UNKNOWN_CONTACT
data,
};
}
}
Using it, with the failure branches a cashier actually meets:
const kr = new Hospitality({
baseUrl: 'https://www.example.com',
clientId: 'pos-front-desk',
clientSecret: process.env.HOSPITALITY_CLIENT_SECRET, // never in code
});
const { incentive } = await kr.fetchIncentive(scannedCode); // show the cashier first
try {
const result = await kr.transact(sale.lineId, 'redeem', { code: scannedCode, amount: 12.5 });
applyDiscountOnTill(result); // your side, after Hospitality said yes
} catch (e) {
switch (e.code) {
case 'INSUFFICIENT_BALANCE': offerPartial(e.data.currentBalance); break;
case 'INVALID_LOCATION': showValidVenues(e.data.validLocations); break;
case 'ALREADY_REDEEMED':
case 'EXPIRED': tellCashierTerminal(e.code); break;
case 'CAPABILITY_MISSING': tellCashierNotPermitted(); break;
default: tellCashierGeneric(e.code);
}
}
Warning
A thrown network error is not a failed redemption. The one branch this sketch leaves to you is a timeout or a dropped connection, because the right behaviour is not generic: retry transact with the same saleId, and read what comes back. The server may already have committed, and the idempotency key is what lets you find out safely instead of guessing. The same holds for ingest: on a timeout, send the same records again.
Machine-readable contract#
The same surface as an OpenAPI 3.1 document, for generating a client or pointing an agent at:
/docs/hospitality-openapi.json
Read what it does and does not promise. The endpoint inventory is generated from the app's own deployment and policy manifests, so it cannot list something that is not deployed or omit something that is. The request and response shapes are hand-written, carry this page's verified date, and exist for seven endpoints: the staff session, fetch-incentive, transact, resolve-token, fetch-locations, staff-config and staff-home. Every other path — including the two ingest endpoints, which this page documents in prose — is marked x-shape-documented: false rather than being given an invented schema. A generated client that types those as unknown is telling you the truth.
Authentication appears in the request schemas rather than as a security scheme, because a staff token is a body field rather than a header.
Errors, and how a till should behave#
Every failure carries a code. These are the ones a till must handle by name rather than by showing a generic message:
| Code | HTTP | What the till should do |
|---|---|---|
STAFF_TOKEN_REQUIRED / STAFF_TOKEN_INVALID | 401 | Re-mint the token, retry the call once |
SERVICE_TOKEN_REVOKED / CLIENT_DISABLED / CLIENT_AUTH_FAILED | 401 / 403 / 401 | The operator changed your client, or the credential is wrong. Stop and contact the operator; do not loop |
RATE_LIMITED | 429 | Wait retryAfterMs and retry. Do not tighten the loop |
INSUFFICIENT_BALANCE | 409 | Show currentBalance and offer to spend that instead |
ALREADY_REDEEMED / ALREADY_VOIDED / EXPIRED | 409 | Terminal. Tell the cashier; do not retry |
INVALID_LOCATION | 409 | Show the returned validLocations. Do not retry elsewhere |
CAPABILITY_MISSING | 403 | This till is not permitted to do this. An operator decision, not a bug |
VOID_NOT_ALLOWED | 403 | Needs a manager. Surface it as such |
NOT_FOUND | 404 | The code does not exist. Check for a scanner mis-read before blaming the guest |
VISIT_WRITE_FAILED | 502 | An award from a spend could not record its visit; no point moved. Retry with the same key |
NOT_BOOTSTRAPPED | 503 | The app is not initialised on this portal. Stop and call the operator |
Also returned and worth handling generically: NOT_REDEEMABLE, INVALID_AMOUNT, INVALID_POINTS, TEMPLATE_NOT_FOUND (which returns the available keys), CONTACT_NOT_FOUND, PROGRAM_NOT_FOUND, PROGRAM_INACTIVE, LOCATION_INACTIVE, MISSING_PARAMETER, INVALID_ACTION. The ingest codes are listed with the ingest calls above.
Rate limit: value operations through hospitality-transact are limited per identity — your client's contact — 30 per minute by default. One client per till keeps normal counter traffic far below it; a client shared across a whole site does not.
Rules for integrators#
- Do not cache voucher state across sales. Balances move. Re-read at scan time; the read endpoint is unauthenticated and cheap.
- Do not try to enrich the identity response. Name-only is the contract, not an oversight.
- Do not put the token or the client secret anywhere they can be read — logs, receipts, query strings, crash reports.
- Do not treat a network failure as a failed redemption. Retry with the same key and read the answer; the server may already have committed.
- Report each sale once. Not as an award with
amountand an ingested visit; not from your till and from Commerce or Events. - Create the guest before you push their facts. Ingest resolves a contact or refuses the record; it never creates one.
- Push stays before their visits, or a visit becomes a day visit until it is sent again.
What does not exist yet#
Say these out loud before designing around them.
- No per-client capability mask. An API client can do everything its venue's capabilities allow. If you should be able to do less than the staff there, the operator gives your client a venue of its own.
- No rate limit on ingest or on the mint. The per-identity limit covers value-moving calls only; batch your feed sensibly (see Batch size and time).
- No webhooks or event push. Hospitality never calls you. If you want activity, poll
hospitality-reportsorhospitality-staff-home. - No pull. Hospitality never reads your PMS or POS; a fact it has not been sent does not exist for it.
- No per-token revoke. The finest grain is an API client (disabled or re-keyed as a whole).
- No late re-attachment. A visit that arrived before its stay stays a day visit until it is sent again.
- No self-service sandbox. Test against a demo portal arranged with the operator. Never develop against a live venue.
Change policy#
- The endpoint index above is generated from the running app's own deployment manifests. If an endpoint is listed, it is deployed; if it is deployed, it is listed. That is a structural guarantee, not a promise to keep a table updated.
- Request and response bodies are hand-written and carry a
verifieddate (in this file's frontmatter). Check it. If it is more than a few months old, confirm the specific field you depend on before shipping. - Additive changes — new optional fields, new error codes, new endpoints — should be expected and must not break your client. Parse defensively and treat an unrecognised
codeas a generic failure rather than crashing. - Breaking changes are communicated, not discovered. There is no version prefix on these paths, so an integration that matters should be registered with us so it can be told. Send it through worksby.design/contact.
Onboarding checklist#
- Operator: create your system's API client (Security tab: a name, the venue it acts at, the contact it acts as, a secret of 32+ characters handed over securely), and confirm the venue's capabilities are exactly what it may do —
ingestonly on the venue a feed acts at. For a feed, set the venues' external ids if you will name venues by your own ids, and register yoursource_systemin the Guests & sources settings. - You: implement the mint → 401 → re-mint loop, the scan parsing rule, idempotency-key persistence, resending
skippedrecords, and the error tables above. - Prove it on a demo portal, in this order. A till: read a voucher · redeem it · replay the same key and confirm nothing changed twice · spend part of a balance · attempt a redeem at the wrong venue and confirm it refuses · void a transaction · have the operator replace your client's secret and confirm the old token is refused and the new secret mints. A feed: push a stay and a visit inside it · send both again and confirm
updatedwith the same ids · confirm the visit carries the stay's id · push a record for an unknown guest and confirmUNKNOWN_CONTACTwith nothing written · open the guest's profile in HubSpot and see it move. - Only then point at a real install.
Step 3 is the whole test plan. Every line of it is a failure that has bitten someone, and the ones most commonly skipped — the replay, the resend and the rotation — are the ones that surface in production rather than in testing.