← Blog

·

How to request and receive a location with the WhatsApp API

Updated on November 4, 2026

To request a location with the WhatsApp Business API, send an interactive message of type location_request_message, which shows a short text and a Send location button. When the customer shares, you get a messages webhook with type: "location", latitude, longitude and, if the customer chooses, the place’s name and address. To send your store’s location, use a type: "location" message or a template with a map header.

Below are the three payloads, the webhook format, a Python example that finds the nearest branch, and the privacy considerations.

Three ways to work with location

What you wantMessage typeWhen you can send it
Ask for the customer’s locationInteractive location_request_messageInside the 24-hour window
Send a pin (store, pickup point)type: "location"Inside the 24-hour window
Send a pin outside the window (e.g. delivery notice)Template with a LOCATION header (utility or marketing)Any time, with an approved template

The window rule applies to the whole official WhatsApp API: free-form and interactive messages only within 24 hours of the customer’s last message; after that, templates only.

Request the customer’s location

The location request is an interactive message with body text and the send_location action:

{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "16505551234",
  "type": "interactive",
  "interactive": {
    "type": "location_request_message",
    "body": {
      "text": "To quote delivery, tap *Send location* and share where you are. Or just type your address with ZIP code."
    },
    "action": {
      "name": "send_location"
    }
  }
}

According to the location request messages documentation, the body accepts up to 1,024 characters and can include URLs. When the customer taps the button, WhatsApp opens its own location-sharing screen.

Copy tip: always offer the option to type the address. Not every customer wants to (or can) share GPS, and people on desktop may struggle.

Meta’s documentation also lists location request templates in the utility templates section. Check the requirements on that page before using it outside the window.

Want to try it while you read? Create a Vectalk account and send your first message through the official API. Create free account →

What arrives in the webhook

When the customer shares, you get a messages webhook. If they were answering your request, there’s also a context pointing to the message you sent:

{
  "object": "whatsapp_business_account",
  "entry": [{
    "id": "102290129340398",
    "changes": [{
      "field": "messages",
      "value": {
        "messaging_product": "whatsapp",
        "metadata": {
          "display_phone_number": "15550783881",
          "phone_number_id": "106540352242922"
        },
        "contacts": [{ "profile": { "name": "Sarah" }, "wa_id": "16505551234" }],
        "messages": [{
          "context": {
            "from": "15550783881",
            "id": "wamid.HBgLMTY1MDU1NTEyMzQVAgARGBI1QjJGRjI1RDY0RkE4Nzg4QzcA"
          },
          "from": "16505551234",
          "id": "wamid.HBgLMTY1MDU1NTEyMzQVAgASGBQzQTRCRDcwNzgzMTRDNTAwRTgwRQA=",
          "timestamp": "1762250400",
          "type": "location",
          "location": {
            "latitude": 37.4419,
            "longitude": -122.1430,
            "name": "Home",
            "address": "123 Example St, Palo Alto, CA"
          }
        }]
      }
    }]
  }]
}

Key fields:

FieldTypeNotes
location.latitude / location.longitudeNumber (decimal degrees)Always present
location.name / location.addressStringOnly if the customer chooses to share them
location.urlStringUsually only for business locations
context.idStringwamid of the request message the customer answered

Source: location messages webhook reference. The same webhook arrives when the customer sends a location on their own (no context) or through a Click to WhatsApp ad.

Two things to watch in your code: latitude and longitude arrive as numbers in the webhook but are sent as strings when you send a location. And the documented webhook carries a single position, not continuous tracking: if the customer moves, you get no updates.

Send your store’s location

To send a pin inside the customer service window:

{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "16505551234",
  "type": "location",
  "location": {
    "latitude": "37.44216",
    "longitude": "-122.16153",
    "name": "Downtown Store",
    "address": "101 Forest Ave, Palo Alto, CA 94301"
  }
}

Latitude and longitude are required; name and address are optional but matter: without them the customer sees just a dot on a map. Source: location messages.

Send a location outside the window: map templates

For notices like “your order is on its way, see the drop-off point”, use a template with a location header. According to the location templates documentation:

  • only utility or marketing templates can have a location header;
  • latitude, longitude, name and address are set at send time, not at creation;
  • real-time locations are not supported;
  • the template supports a body (up to 1,024 characters), an optional footer (up to 60) and buttons.

Create:

{
  "name": "order_pickup_location",
  "language": "en_US",
  "category": "UTILITY",
  "parameter_format": "named",
  "components": [
    { "type": "HEADER", "format": "LOCATION" },
    {
      "type": "BODY",
      "text": "Hi {{name}}! Order {{order}} is ready for pickup at the location shown on the map above.",
      "example": {
        "body_text_named_params": [
          { "param_name": "name", "example": "Sarah" },
          { "param_name": "order", "example": "#4821" }
        ]
      }
    }
  ]
}

Send, with the coordinates in the header component:

{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "16505551234",
  "type": "template",
  "template": {
    "name": "order_pickup_location",
    "language": { "code": "en_US" },
    "components": [
      {
        "type": "header",
        "parameters": [{
          "type": "location",
          "location": {
            "latitude": "37.44216",
            "longitude": "-122.16153",
            "name": "Downtown Store",
            "address": "101 Forest Ave, Palo Alto, CA 94301"
          }
        }]
      },
      {
        "type": "body",
        "parameters": [
          { "type": "text", "parameter_name": "name", "text": "Sarah" },
          { "type": "text", "parameter_name": "order", "text": "#4821" }
        ]
      }
    ]
  }
}

Keep in mind that since October 1, 2026, utility templates are billed even inside the customer service window (for recipients in Brazil, BRL 0.0350 per delivered message; other countries follow Meta’s rate card). Inside the window, a plain type: "location" message is usually the simpler option.

Example: find the nearest branch (Python)

A common case: the customer shares their location and the bot replies with the closest store. The snippet below computes straight-line distance (Haversine formula) and replies with the pin:

import math, os, requests

BASE = os.environ["WA_BASE_URL"]  # e.g. https://graph.facebook.com/v26.0/<PHONE_NUMBER_ID>
TOKEN = os.environ["WA_TOKEN"]

STORES = [
    {"name": "Downtown Store", "lat": 37.44216, "lng": -122.16153, "addr": "101 Forest Ave, Palo Alto, CA"},
    {"name": "South Store", "lat": 37.39420, "lng": -122.07810, "addr": "80 Sample Rd, Mountain View, CA"},
]

def distance_km(lat1, lng1, lat2, lng2):
    r = 6371.0
    p1, p2 = math.radians(lat1), math.radians(lat2)
    dp, dl = math.radians(lat2 - lat1), math.radians(lng2 - lng1)
    a = math.sin(dp / 2) ** 2 + math.cos(p1) * math.cos(p2) * math.sin(dl / 2) ** 2
    return 2 * r * math.asin(math.sqrt(a))

def send(payload):
    payload["messaging_product"] = "whatsapp"
    r = requests.post(f"{BASE}/messages", json=payload,
                      headers={"Authorization": f"Bearer {TOKEN}"}, timeout=15)
    r.raise_for_status()
    return r.json()

def handle_location(msg):
    loc = msg["location"]
    store = min(STORES, key=lambda s: distance_km(loc["latitude"], loc["longitude"], s["lat"], s["lng"]))
    km = distance_km(loc["latitude"], loc["longitude"], store["lat"], store["lng"])
    send({
        "to": msg["from"],
        "type": "text",
        "text": {"body": f"Your nearest branch is {store['name']}, about {km:.1f} km away in a straight line."},
    })
    send({
        "to": msg["from"],
        "type": "location",
        "location": {"latitude": str(store["lat"]), "longitude": str(store["lng"]),
                     "name": store["name"], "address": store["addr"]},
    })

Straight-line distance isn’t road distance. For delivery fees or ETAs, use a routing API from your maps provider. To build the server that receives the webhook, see WhatsApp bot with Python and FastAPI.

Use cases

  • Food delivery: confirm the delivery address before closing the order and avoid “I can’t find your street”. More ideas in WhatsApp for food delivery and restaurants.
  • Logistics: a map template for pickup points, and a location request when a delivery attempt fails. See delivery notifications.
  • Field service (internet, HVAC, solar): the technician gets the exact spot, handy in rural areas or large gated communities.
  • Store or clinic networks: “which branch is closest?” answered with the right pin.
  • Pickups and rides: the customer shares the pickup point directly.

Privacy

A location is personal data and, combined with a phone number, identifies a person. If you serve customers in Brazil, the General Data Protection Law (LGPD, Law 13,709/2018) requires a defined purpose, necessity and transparency; other jurisdictions have similar rules (such as the GDPR in Europe). In practice: say why you need the location, keep only what the delivery or service requires, and set a retention period. This is not legal advice; consult a lawyer. More in LGPD and WhatsApp.

How to do this with Vectalk

With Vectalk, payloads are Meta’s: swap the base URL for https://apis.vectalk.com.br/api and use the token generated in the dashboard. The docs (in Portuguese) describe sending a location via POST /api/messages, and forwarded webhooks are Meta’s own, with type: "location" and the latitude and longitude fields (see Webhooks). The interactive location request and the map template use the same messages endpoint, with the JSON shown above.

Vectalk has no native inbox or bot: the “find the nearest store” logic runs in your system, which receives the webhook and replies through the API. Create your account to try it.

Frequently asked questions

Can I ask for a location from someone who has never messaged me?

Not with the interactive message, which can only be sent inside the 24-hour window. Outside it, the message must be an approved template.

Can I track a customer’s location in real time?

The documented webhook carries one point (latitude and longitude) per message. For location templates, Meta states that real-time locations are not supported.

Why didn’t the address come in the webhook?

The name and address fields only appear if the customer chooses to share them. Latitude and longitude always come. If you need a formatted address, use reverse geocoding from your maps provider.

Does the location request work on WhatsApp Web?

The location request documentation doesn’t detail behavior per platform. To be safe, always offer the option to type the address.

Is a map template utility or marketing?

It depends on the content. Meta accepts location headers in both categories: an order pickup notice is utility, while an invitation to visit your new store is marketing. See how Meta categorizes templates.


Official sources consulted on November 4, 2026: Location request messages, Location messages, Location messages webhook reference, Location templates (utility), Law 13,709/2018 (LGPD), Vectalk: Send location, Vectalk: Webhooks.

Put your business on the official WhatsApp

Create your account, connect your number to the official API (you can keep the app with coexistence) and start serving customers and sending messages.