Send a location on WhatsApp with "type": "location" and a location object holding latitude and longitude as strings, plus an optional name and address. Contact cards use "type": "contacts" and a contacts array. When a user shares either one with you, the messages webhook delivers the same objects back, with coordinates as JSON numbers.
All three message types in this post are service messages. Meta’s send guide says that when the 24-hour customer service window closes, “you can only send pre-approved template messages” (Meta send messages, accessed 2026-11-04). Outside the window these sends fail with error 131047.
Send a location
The location object takes four fields (Meta location messages, accessed 2026-11-04). latitude and longitude are required strings in decimal degrees. name and address are optional, and Meta states no length limit for either. This is the body of Meta’s example.
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "+16505551234",
"type": "location",
"location": {
"latitude": "37.44216251868683",
"longitude": "-122.16153582049394",
"name": "Philz Coffee",
"address": "101 Forest Ave, Palo Alto, CA 94301"
}
}
The response has the usual shape, with the recipient in contacts[0].wa_id and the message ID in messages[0].id. That ID means Meta accepted the send. Delivery arrives later as a status webhook.
Ask the user for their location
A location request message shows a button that opens WhatsApp’s location sharing screen. It’s an interactive message with interactive.type set to location_request_message and action.name set to send_location (Meta location request messages, accessed 2026-11-04). The body text allows up to 1024 characters. This is Meta’s example body, taken out of its curl call, where the apostrophe was shell-escaped.
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"type": "interactive",
"to": "+16505551234",
"interactive": {
"type": "location_request_message",
"body": {
"text": "Let's start with your pickup. You can either manually *enter an address* or *share your current location*."
},
"action": {
"name": "send_location"
}
}
}
The reply is an ordinary type: location message. It carries a context object whose id is the ID of your request, so you can match the answer to the question you asked. address and name appear only if the user chooses to share them. Other interactive types, with their limits, are in interactive buttons and list messages.
Send a contact card
Each entry in contacts needs a name with formatted_name (Meta contacts messages, accessed 2026-11-04). The optional parts are addresses, birthday (YYYY-MM-DD), emails, org, phones and urls. The Messages API reference marks the contact object with “Additional Properties: Not allowed” (Meta Messages API reference, accessed 2026-11-04). Send only the listed fields.
The wa_id on a phone entry changes what the recipient sees. With it, the card shows Message and Save contact buttons. Meta says that “if you omit the wa_id property, both buttons will be replaced with an Invite to WhatsApp button”.
Meta allows “up to 257 contacts” per message and recommends sending fewer. Addresses, birthdays and emails “may not be supported by the recipient, especially on their primary device”. Rely on the name and phone entries, and treat the rest as extras that may not render.
Send and parse from Python
This script sends the three message types and parses inbound location and contacts webhooks. The send payloads follow Meta’s examples. The contact sender is a minimal card built from the field reference, with a name and one phone. It needs Python 3.9 or later and requests.
# location_contacts.py
import json
import os
import sys
import requests
GRAPH_VERSION = os.environ.get("GRAPH_VERSION", "v26.0")
def post_message(payload):
url = (
f"https://graph.facebook.com/{GRAPH_VERSION}/"
f"{os.environ['PHONE_NUMBER_ID']}/messages"
)
headers = {"Authorization": f"Bearer {os.environ['WHATSAPP_TOKEN']}"}
r = requests.post(url, json=payload, headers=headers, timeout=10)
try:
data = r.json()
except ValueError: # a non-JSON error page
r.raise_for_status()
raise
if not r.ok or "error" in data:
err = data.get("error", {})
sys.exit(f"HTTP {r.status_code}, code {err.get('code')}: {err.get('message')}")
return data["messages"][0]["id"]
def base(to, kind):
return {"messaging_product": "whatsapp", "recipient_type": "individual", "to": to, "type": kind}
def location_payload(to, lat, lng, name=None, address=None):
location = {"latitude": str(lat), "longitude": str(lng)} # strings when sending
if name:
location["name"] = name
if address:
location["address"] = address
return {**base(to, "location"), "location": location}
def location_request_payload(to, text):
interactive = {
"type": "location_request_message",
"body": {"text": text},
"action": {"name": "send_location"},
}
return {**base(to, "interactive"), "interactive": interactive}
def contact_payload(to, formatted_name, phone, wa_id=None):
entry = {"phone": phone, "type": "Mobile"}
if wa_id:
entry["wa_id"] = wa_id # without it the card shows Invite to WhatsApp
name = {"formatted_name": formatted_name, "first_name": formatted_name.split()[0]}
return {**base(to, "contacts"), "contacts": [{"name": name, "phones": [entry]}]}
def parse_event(event):
found = []
for entry in event.get("entry", []):
for change in entry.get("changes", []):
for msg in change.get("value", {}).get("messages", []):
sender = msg.get("from") or msg.get("from_user_id")
if msg.get("type") == "location":
loc = msg["location"]
found.append({
"type": "location",
"sender": sender,
"lat": float(loc["latitude"]), # numbers when receiving
"lng": float(loc["longitude"]),
"name": loc.get("name"),
"address": loc.get("address"),
"url": loc.get("url"),
"in_reply_to": msg.get("context", {}).get("id"),
})
elif msg.get("type") == "contacts":
for card in msg.get("contacts", []):
found.append({
"type": "contact",
"sender": sender,
"name": card.get("name", {}).get("formatted_name"),
"phones": [[p.get("phone"), p.get("wa_id")] for p in card.get("phones", [])],
"origin": card.get("origin"),
"has_vcard": "vcard" in card,
})
return found
USAGE = (
"usage: location_contacts.py location TO LAT LNG [NAME] [ADDRESS]"
" | ask-location TO TEXT | contact TO FORMATTED_NAME PHONE [WA_ID] | parse FILE"
)
if __name__ == "__main__":
args = sys.argv[1:]
cmd = args[0] if args else ""
if cmd == "location" and len(args) >= 4:
print("accepted:", post_message(location_payload(*args[1:6])))
elif cmd == "ask-location" and len(args) == 3:
print("accepted:", post_message(location_request_payload(args[1], args[2])))
elif cmd == "contact" and len(args) >= 4:
print("accepted:", post_message(contact_payload(*args[1:5])))
elif cmd == "parse" and len(args) == 2:
with open(args[1]) as f:
for item in parse_event(json.load(f)):
print(json.dumps(item))
else:
sys.exit(USAGE)
Run the sends with your token and number ID in the environment.
pip install requests
export WHATSAPP_TOKEN="ACCESS_TOKEN"
export PHONE_NUMBER_ID="PHONE_NUMBER_ID"
python location_contacts.py location +16505551234 37.44216251868683 -122.16153582049394 "Philz Coffee" "101 Forest Ave, Palo Alto, CA 94301"
python location_contacts.py ask-location +16505551234 "Share your pickup location."
python location_contacts.py contact +16505551234 "Barbara J. Johnson" +19175559999 19175559999
The first_name in contact_payload is the first word of the formatted name. Replace it with real name parts if you store them.
Receive a location
A location webhook fires when a user sends a location, including through a Click to WhatsApp ad (Meta location webhook, accessed 2026-11-04). Inbound latitude and longitude are JSON numbers, while you send them as strings. Meta describes url as “Usually only included for business locations.” Save Meta’s example as location.json to test the parser.
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "102290129340398",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "15550783881",
"phone_number_id": "106540352242922"
},
"contacts": [
{
"profile": {
"name": "Sheena Nelson"
},
"wa_id": "16505551234"
}
],
"messages": [
{
"from": "16505551234",
"id": "wamid.HBgLMTY1MDM4Nzk0MzkVAgASGBQzQUFERjg0NDEzNDdFODU3MUMxMAA=",
"timestamp": "1744344496",
"location": {
"address": "101 Forest Ave, Palo Alto, CA 94301",
"latitude": 37.44221496582,
"longitude": -122.16165924072,
"name": "Philz Coffee",
"url": "https://philzcoffee.com/"
},
"type": "location"
}
]
},
"field": "messages"
}
]
}
]
}
python location_contacts.py parse location.json
The parser casts both coordinates with float(), so it accepts strings and numbers alike. A referral object appears only on messages from Click to WhatsApp ads. Meta’s location webhook page says nothing about live location, so test that case on a real device before you rely on it.
Receive a contact card
Inbound contacts use the same contacts array, with gaps (Meta contacts webhook, accessed 2026-11-04). Meta warns that “many contact properties may be omitted” when the user or the device withholds them. Phone type varies, with Meta’s examples such as “cell, mobile, main, iPhone, home, or work”. The parser reads every field with .get() for that reason.
Meta’s business-scoped user IDs page adds fields the contacts webhook page doesn’t show yet (Meta business-scoped user IDs, accessed 2026-11-04). Its May 4, 2026 changelog entry put from_user_id, origin and vcard into the contacts payload. Each card’s origin is contact_request when the user tapped a REQUEST_CONTACT_INFO button, and other when they shared a contact in the chat.
vcard holds the user’s vCard only when origin is other. The same page says from “Will be omitted if the phone number cannot be included”, which is why the parser falls back to from_user_id. The full rules are in usernames and business-scoped user IDs.
To ask for the user’s own details, Meta documents an interactive request_contact_info message on the same page. It was renamed from contact_request on May 28, 2026.
Field limits Meta does not publish
Meta publishes no character limits for location name and address, or for contact fields. The documented limits are the 1024-character body on location requests and the 257 contacts per message. Validate lengths against what your own database stores. If you store these next to Telegram or Instagram messages, see one message model for four channels. A Node.js receiver is in the Express webhook guide.
Z-API Omni team