WhatsApp space invitation — Twilio Content template

Required for production WhatsApp invites outside the 24-hour session window (Twilio 63016).

WhatsApp space invitations and Twilio error 63016

Symptom: 63016 Failed to send freeform message because you are outside the allowed window. If you are using WhatsApp, please use a Message Template.

Cause: WhatsApp Business only allows session messages (freeform Body) for ~24 hours after the user last messaged your number. Cold outbound invites must use a Meta-approved message template sent via Twilio Content SID (ContentSid + ContentVariables).

Fix: Create an approved template in Twilio Content / WhatsApp, then set on backend-api:

TWILIO_WHATSAPP_INVITE_CONTENT_SID=HXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Template copy (match variable order)

Use a text (or approved) template with five variables, in this order:

Variable Meaning Example
{{1}} Space name Acme Team
{{2}} Role label Team Member
{{3}} Short invite code 042891
{{4}} Full join URL https://app.gograb.space/join/...
{{5}} Inviter display name Jane

Suggested English body (submit to Meta for approval; wording must stay consistent with what you approve):

You've been invited to join {{1}} as {{2}}.

Your code: {{3}}

Accept invitation: {{4}}

— {{5}}

After Meta approves the template and Twilio assigns a Content SID (HX...), set TWILIO_WHATSAPP_INVITE_CONTENT_SID in the same environment as TWILIO_ACCOUNT_SID / TWILIO_AUTH_TOKEN / TWILIO_NUMBER.

Production without a template

If TWILIO_WHATSAPP_INVITE_CONTENT_SID is not set, the API tries freeform WhatsApp first (works when the recipient is inside the ~24h session with the same Twilio WhatsApp sender used by backend-api). If that fails (e.g. 63016 cold outreach), it retries the same text via SMS so the invite still delivers.

Set TWILIO_WHATSAPP_INVITE_CONTENT_SID when you need reliable WhatsApp to numbers that have never messaged your business line, or when backend-api uses a different WhatsApp sender than Vitto (session with Vitto ≠ session with the invite sender).

Sandbox

In sandbox mode, the API tries freeform WhatsApp first; if Twilio returns 63016, it retries via SMS. Production with a Content SID uses the template; if that fails, it also falls back to SMS once.

Related code

If you change variable count or order in the approved template, update buildInviteWhatsAppContentVariables in that service to match.