Menu/bookings/{booking_id}/messages

Send a message to the guest of a booking

POST/api/v1/bookings/{booking_id}/messages
Nécessite messages.write

Sends the text right away, the way the ZenHost inbox does, and answers once it is sent. platform writes on the messaging of the Sales Channel of the booking; email and sms use the guest contact details ZenHost holds. The message is attributed to your App: the host sees "Sent by" and the name of your App in the inbox.

To attach photos, send the same fields as multipart/form-data with up to 5 photos parts (JPEG, PNG, WebP or AVIF, 10 MB each), on platform only; email and SMS answer validation_failed. In practice a whole call stays under about 4.5 MB (see below). The text and each photo reach the guest as separate messages, the way the ZenHost inbox sends them: the answer is the text message, and GET /bookings/{booking_id}/messages lists the photo messages right after it, with their files. Once the text has reached the guest, the request answers 201 with it even if a photo was refused or its fate is unknown: check that list for the photos before sending them again. Whatever these limits, the hosting platform refuses a request body above 4.5 MB with a 413 that is not the JSON error of the API: send fewer or smaller photos per call.

**SMS are billed to the host**, €0.10 per segment, on their ZenHost subscription. When the subscription cannot be billed, the request answers sms_billing_unavailable: nothing is sent and nothing is billed.

Refusals known before sending answer 422 and send nothing: channel_unavailable (the chosen channel cannot reach the guest, try another one: on platform, the Sales Channel of the booking has no messaging, no conversation exists there yet, or the host must restore their connection to it; on email, the account has no sending address), missing_guest_contact (no email or phone for the chosen channel; a platform relay address such as @guest.booking.com counts as no email). When the send fails, delivery_failed tells in details.delivery_outcome whether the message certainly did not leave (not_sent: safe to send again) or its fate is unknown (unknown: check GET /bookings/{booking_id}/messages before sending again).

For Zenny, a message from your App is a reply of the host: a reply Zenny was preparing for this conversation is dropped, and a conversation Zenny handed over to the host is released. Your message never becomes Knowledge. A booking outside the Connection Scope answers not_found, exactly like a missing one. Counts against the send rate limit.

Paramètres

Paramètres de chemin

  • booking_idstring (uuid)obligatoire

    Booking id.

En-têtes

  • Idempotency-Keystring

    Replaying the same key on the same App Connection within 24 hours answers what the first request did (the same message, or the same refusal) and sends nothing new. Reusing it with a different body answers idempotency_key_reused; while the first request is still sending, idempotency_key_in_use.

    au plus 255 caractères

Corps de la requête

application/jsonSendMessageRequest

A text to the guest of the booking.

  • channelstringobligatoire

    platform is the messaging of the Sales Channel of the booking (Airbnb, Booking.com…); email and sms reach the guest contact details ZenHost holds.

    Parmi : platform email sms

  • textstringobligatoire

    The message. Shortcodes require their corresponding read permission, including nested custom values: bookings.read (plus prices.read for amounts), guests.read, properties.read for title/currency, property_guide.read for guide/custom values, or lock_codes.read. Missing permission refuses the send with forbidden_permission. Portal credentials and invoice/payment links cannot be expanded by Apps.

    au plus 10000 caractères

  • subjectstring

    Email only. Shortcodes follow the same read-permission checks as the text. Without it, the email takes the name of the Property.

    au plus 255 caractères

Réponses

201The message, sent.

application/jsonMessage

  • idstring (uuid)obligatoire
  • directionstringobligatoire

    inbound from the guest, outbound to the guest.

    Parmi : inbound outbound

  • authorMessageAuthorobligatoire

    Who wrote the message. Never carries a guest email or phone, nor the name of the team member.

    Afficher 2 attributs enfants
    • typestringobligatoire

      guest (inbound), host (the host or a team member), zenny (written by Zenny, the ZenHost assistant), automation (a Scheduled Message) or app (an App, see app_name). Version 1 may add values.

      Parmi : guest host zenny automation app

    • app_namestring

      Name of the App that sent the message, when type is app.

  • channelstringobligatoire

    platform is the messaging of the Sales Channel of the booking (Airbnb, Booking.com…). Version 1 may add values.

    Parmi : platform email sms

  • textstringobligatoire
  • subjectstring | nullobligatoire

    Email subject.

  • attachmentsMessageAttachment[]obligatoire
    Afficher 5 attributs enfants
    • indexintegerobligatoire

      Position of the file in the message, as in the download URL. Files that cannot be downloaded are left out, so indexes may skip.

      min 0

    • typestringobligatoire

      Only images in version 1; other types may be added.

      Parmi : image

    • file_namestring | nullobligatoire
    • content_typestring | nullobligatoire

      MIME type when known; the download answers with the actual one.

    • urlstring (uri)obligatoire

      Download URL of the file. Call it with the access token of the App Connection, like any other endpoint.

  • delivery_statusstringobligatoire

    received for an inbound message. For an outbound one: pending while it is not confirmed sent (in flight, or its fate is not known yet), sent, or rejected when it did not reach the guest: the Sales Channel refused it, or its send failed or stayed unconfirmed for a minute, as the ZenHost inbox shows it. Version 1 may add values.

    Parmi : received pending sent rejected

  • sent_atstring (date-time)obligatoire
  • created_atstring (date-time)obligatoire

    When ZenHost recorded the message; the list is sorted on it.

401Error code: unauthorized, connection_revoked.

Codes d’erreur

  • unauthorized Le jeton d’accès est absent, inconnu, expiré ou révoqué, ou a été émis avant que le compte ne reconnecte l’App. Rafraîchissez-le ; si le rafraîchissement échoue, demandez au propriétaire de reconnecter l’App.
  • connection_revoked Le propriétaire a révoqué la connexion d’App (ou votre App a révoqué son propre jeton de rafraîchissement). Cessez les appels pour ce compte et supprimez ses jetons.
402Error code: subscription_blocked.

Codes d’erreur

  • subscription_blocked L’abonnement ZenHost du compte est bloqué (impayé, résilié…). La connexion est conservée : prévenez votre client, les appels refonctionnent dès que l’abonnement est rétabli.
403Error code: app_suspended, forbidden_permission.

Codes d’erreur

  • app_suspended ZenHost a suspendu votre App, ou ne l’autorise plus sur ce compte. Cessez les appels et contactez ZenHost.
  • forbidden_permission Votre App n’a pas reçu la permission que cet endpoint exige.
404Error code: not_found.

Codes d’erreur

  • not_found La ressource n’existe pas ou est hors du périmètre de connexion (les deux cas sont indiscernables), ou le chemin n’est pas un endpoint de /api/v1.
409Error code: idempotency_key_in_use.

Codes d’erreur

  • idempotency_key_in_use Une requête avec cette Idempotency-Key est encore en cours de traitement. Réessayez dans quelques secondes pour obtenir sa réponse.
422Error code: validation_failed, idempotency_key_reused, channel_unavailable, missing_guest_contact, sms_billing_unavailable.

Codes d’erreur

  • validation_failed La requête, les en-têtes ou le corps sont invalides ; details.issues désigne chaque problème (path, message, et maximum quand une valeur ou une liste est trop grande).
  • idempotency_key_reused Cette Idempotency-Key a déjà été utilisée sur cette connexion d’App avec un autre corps.
  • channel_unavailable Le canal choisi ne peut pas joindre le voyageur de cette réservation. Sur platform : le canal de vente n’a pas de messagerie pour elle, aucune conversation n’y existe encore, ou l’hôte doit rétablir sa connexion. Sur email : le compte n’a pas d’adresse d’envoi. Rien n’a été envoyé ; essayez un autre canal.
  • missing_guest_contact Le voyageur de cette réservation n’a pas d’adresse email (pour email) ou de numéro de téléphone (pour sms). Rien n’a été envoyé.
  • sms_billing_unavailable L’abonnement ZenHost du compte ne permet pas de facturer le SMS. Rien n’a été envoyé ni facturé ; utilisez un autre canal.
429Error code: rate_limited.

En-tête Retry-After — Seconds to wait before the next call is allowed. Limits per App Connection: 60 reads (GET), 10 writes (other POST) and 30 messages sent to guests per minute.

Codes d’erreur

  • rate_limited Trop d’appels sur cette connexion d’App. Attendez le nombre de secondes indiqué dans Retry-After.
500Error code: internal_error.

Codes d’erreur

  • internal_error ZenHost n’a pas pu répondre. Réessayez plus tard avec un délai croissant.
502Error code: delivery_failed.

Codes d’erreur

  • delivery_failed Le message n’a pas pu être distribué. details.delivery_outcome vaut not_sent s’il n’est sûrement pas parti (vous pouvez l’envoyer à nouveau) ou unknown si son sort est inconnu (relisez les messages de la réservation avant de l’envoyer à nouveau).

Tous les codes d’erreur et la conduite à tenir