Skip to Content

Guest webhook

Push guests from Google Sheets, Zapier or Make to a hotel with one secret key. Fields, answers, and copy-paste recipes.

One endpoint takes guests as JSON from any tool that can send a web request. It uses the same checks as the file importer: the phone is normalised (a local 8 digit number is read as +216), a guest already in the hotel is merged by phone and never duplicated, and the same row sent twice is safe.

The key

The hotel owner makes the key in the dashboard, on Guests, Import, under "Send guests from a sheet or Zapier".

  • It is shown once and stored only as a hash. Lost it? Make a new one.
  • Making a new key replaces the old one at once. Revoke stops all sending.
  • One key belongs to one hotel. Nothing in the body can name another hotel.
  • Limits: 120 calls per minute per hotel, and a body of at most 256 KB. Send lists of up to 100 guests per call instead of one call per row.
  • A call with a wrong or missing key counts against the sender's address: after 30 in a minute it gets a 429 even with the right key. Good calls never count against the address, so tools that share an address (Zapier, Make, Google) do not slow each other down.
  • On a 429, wait the seconds in the retry-after header and send the same call again. It is safe: a guest already saved is merged, not duplicated.

The request

POST https://<api address>/import/guests
Authorization: Bearer rit_...   (or the header x-api-key)
Content-Type: application/json

The address is shown next to the key in the dashboard. The body is one guest, or a list of up to 100 guests.

{
  "name": "Amel Ben Salah",
  "phone": "20 123 456",
  "language": "fr",
  "email": "amel@example.com",
  "birthday": "1990-12-31",
  "consent": { "email": true, "whatsapp": true }
}
FieldNeededNotes
nameyes
phoneyesLocal Tunisian numbers, +216..., 00216... or any international number
languagenoen, fr or ar. The hotel default when missing
email, birthdaynoBirthday as YYYY-MM-DD
consent.email, consent.whatsappat least onetrue or false (also "yes" and "no"). Never assumed: a body without them is rejected
consent.profile, country, citynoCountry and city are kept only with consent.profile: true

A guest gets a consent only for a channel you send as true. A false is recorded as a no. A guest who unsubscribed is not opted in again by a push.

Answers

StatusMeaning
200ok: true when everything was saved. With a list, ok: false and errors when some rows failed and others were saved
400The body is not JSON, or the list is empty or longer than 100
401The key is missing, wrong, replaced or revoked
403The hotel is suspended
422Nothing was saved. errors lists index and message for each guest
413The body is over 256 KB. Send fewer guests per call
429Too many calls. Wait the seconds in retry-after, then retry

Every answer has a readable message and the counts created, merged, consentKept and errors. Error messages name the field, never the value.

consentKept counts guests who had withdrawn a channel and were sent as true again. The withdrawal stays: only the guest can opt in again. The message says so, so a sheet owner knows why a guest did not get the consent.

Guests from the webhook are stored with the source csv, like an import. That is on purpose: an import sends no welcome message and counts no visit, which is right for a list pushed from another system. Use the QR page for a guest who is at the desk now.

Phone numbers

Spreadsheets treat a phone as a number and drop a leading + or 0: +216 20 123 456 becomes 216 20 123 456 and 020 123 456 becomes 20123456. A number without + is read as Tunisian (+216), so an international guest written that way is rejected or saved on the wrong number. Keep the column as text (Format, Number, Plain text) and write foreign numbers with their +.

Google Sheets (Apps Script)

In the sheet: Extensions, Apps Script. Put the key in Project Settings, Script properties as RITORNO_KEY, and the address as RITORNO_URL. Columns: A name, B phone, C email, D accepts WhatsApp (a checkbox), E sent. Set column B to plain text (sheet.getRange("B:B").setNumberFormat("@"), or Format, Number, Plain text) before you paste numbers, so + and a leading 0 are kept.

The script sends up to 100 rows per call and retries once when the answer is a 429.

function sendNewGuests() {
  const props = PropertiesService.getScriptProperties()
  const sheet = SpreadsheetApp.getActiveSheet()
  const last = sheet.getLastRow()
  if (last < 2) return
  const rows = sheet.getRange(2, 1, last - 1, 5).getDisplayValues()
  const todo = rows.map((row, i) => ({ row, line: i + 2 })).filter(({ row }) => row[1] && !row[4])
  for (let from = 0; from < todo.length; from += 100) {
    const batch = todo.slice(from, from + 100)
    const payload = JSON.stringify(
      batch.map(({ row: [name, phone, email, whatsapp] }) => ({
        name,
        phone,
        email,
        consent: { whatsapp: whatsapp === "TRUE" },
      })),
    )
    const send = () =>
      UrlFetchApp.fetch(props.getProperty("RITORNO_URL"), {
        method: "post",
        contentType: "application/json",
        headers: { Authorization: "Bearer " + props.getProperty("RITORNO_KEY") },
        payload,
        muteHttpExceptions: true,
      })
    let response = send()
    if (response.getResponseCode() === 429) {
      Utilities.sleep(Number(response.getHeaders()["retry-after"] || 30) * 1000)
      response = send()
    }
    const answer = JSON.parse(response.getContentText())
    const failed = new Map((answer.errors || []).map((e) => [e.index, e.message]))
    batch.forEach(({ line }, i) => {
      const note = response.getResponseCode() >= 400 && !answer.errors ? answer.message : failed.get(i)
      sheet.getRange(line, 5).setValue(note || "ok")
    })
  }
}

Run it by hand or add a time driven trigger. The fifth column keeps the answer per row: a failed row shows its reason and a row marked ok is not sent again (clear the cell to send it again, it is merged, not duplicated). The sheet has no email consent column, so no email consent is sent: add a column and send email: true only for guests who agreed.

Zapier

Needs a paid Zapier plan for webhooks.

  1. Pick your trigger (a new row in Google Sheets, a form answer, a PMS event).
  2. Add the action Webhooks by Zapier, POST.
  3. URL: the address. Payload type: Json.
  4. Data: name, phone, language, email, consent__whatsapp and consent__email (Zapier turns a double underscore into the nested consent object). Map the consent fields to a column holding true or false, never a fixed true unless your form asked the guest.
  5. Headers: Authorization with Bearer <key>.
  6. Test the step. A rejected guest shows the message in the step result.

Make

Free tier available.

  1. Add the module HTTP, Make a request after your trigger.
  2. URL: the address. Method: POST. Body type: Raw, content type JSON.
  3. Header: Authorization = Bearer <key>. Parse response: yes.
  4. Request content:
{
  "name": "{{1.name}}",
  "phone": "{{1.phone}}",
  "email": "{{1.email}}",
  "consent": { "whatsapp": {{1.whatsappConsent}}, "email": {{1.emailConsent}} }
}

Use a filter on the route when ok is false to log or email the message.

On this page