# Send and request location

> Send a map pin or ask the contact to share their location on WhatsApp.

Two location tasks, both WhatsApp only: sending a map pin and asking for the contact's location. Fields shared by every type (`to`, `reply_to`, `typing`, `delay_ms`, the 24 h window) are in [Common fields](/en/send/text/#common-fields).

## Send a location

Use `type: "location"` in `POST /v1/messages`.

| Field | Rule |
| --- | --- |
| `location.latitude` | Number from -90 to 90 |
| `location.longitude` | Number from -180 to 180 |
| `location.name` | Optional, up to 256 characters |
| `location.address` | Optional, up to 512 characters |

  **cURL**

```bash
curl -X POST https://api.messajo.com/v1/messages \
  -H "Authorization: Bearer $MESSAJO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "connection_id": "con_123",
  "to": "5511999990000",
  "type": "location",
  "location": {
    "latitude": -23.5614,
    "longitude": -46.6559,
    "name": "Paulista Store",
    "address": "Av. Paulista, 1000, São Paulo"
  }
}'
```

  **TypeScript**

```ts
import { Messajo } from "@messajo/sdk";

const messajo = new Messajo({ apiKey: process.env.MESSAJO_API_KEY! });

const message = await messajo.messages.send({
  connection_id: "con_123",
  to: "5511999990000",
  type: "location",
  location: {
    latitude: -23.5614,
    longitude: -46.6559,
    name: "Paulista Store",
    address: "Av. Paulista, 1000, São Paulo",
  },
});
console.log(message.id, message.status);
```

  **n8n**
n8n HTTP Request: POST https://api.messajo.com/v1/messages

```json
{
  "connection_id": "con_123",
  "to": "5511999990000",
  "type": "location",
  "location": {
    "latitude": -23.5614,
    "longitude": -46.6559,
    "name": "Paulista Store",
    "address": "Av. Paulista, 1000, São Paulo"
  }
}
```

The response is `201` with `id` (`msg_…`), `status: "queued"` and `conversation_id`. The final state arrives by webhook.

## Request the contact's location

Use `type: "interactive"` with `interactive.type: "location_request_message"`. The contact sees the text and a button to share their location. `body.text` is up to 1024 characters and `action.name` is always `send_location`.

  **cURL**

```bash
curl -X POST https://api.messajo.com/v1/messages \
  -H "Authorization: Bearer $MESSAJO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "connection_id": "con_123",
  "to": "5511999990000",
  "type": "interactive",
  "interactive": {
    "type": "location_request_message",
    "body": { "text": "Where should we deliver your order?" },
    "action": { "name": "send_location" }
  }
}'
```

  **TypeScript**

```ts
await messajo.messages.send({
  connection_id: "con_123",
  to: "5511999990000",
  type: "interactive",
  interactive: {
    type: "location_request_message",
    body: { text: "Where should we deliver your order?" },
    action: { name: "send_location" },
  },
});
```

  **n8n**
n8n HTTP Request: POST https://api.messajo.com/v1/messages

```json
{
  "connection_id": "con_123",
  "to": "5511999990000",
  "type": "interactive",
  "interactive": {
    "type": "location_request_message",
    "body": { "text": "Where should we deliver your order?" },
    "action": { "name": "send_location" }
  }
}
```

### Receive the answer

When the contact shares their location, a [`message.received`](/en/webhooks/events/) event arrives with `content.type: "location"`:

```json
{
  "type": "location",
  "latitude": -23.5614,
  "longitude": -46.6559,
  "name": null,
  "address": null,
  "url": null
}
```

`name`, `address` and `url` are `null` when the contact does not provide them. If they ignore the request, nothing arrives.

## Instagram and Messenger

They accept neither `location` nor `interactive`: both return `422 type_not_supported_by_channel`.

## Errors

| Code | Status | When |
| --- | --- | --- |
| `outside_service_window` | 422 | Free-form message outside the 24 h window |
| `validation_failed` | 400 | Latitude or longitude out of range, or text above the limit |
| `type_not_supported_by_channel` | 422 | Instagram or Messenger |
