# Location

## Request location sharing

`client.chats.location.request(stringchatID, RequestOptionsoptions?): LocationRequestResponse`

**post** `/v3/chats/{chatId}/location/request`

Request a contact in a chat to share their location. They receive an iMessage
prompt and must accept before any location is available; once they do, read their
location coordinates with `GET /v3/chats/{chatId}/location`.

The request is delivered asynchronously. The endpoint returns immediately with
`{ "success": true, "message": "Location request sent" }` and does not return
coordinates.

Rejected with `409` if the recipient is already sharing — read their
location with `GET /v3/chats/{chatId}/location` instead of re-requesting.

Rate limited per chat, since each request prompts the recipient's device.
Exceeding it returns `429` with a `Retry-After` header.

Location requests only work in **1:1 iMessage chats** (Apple limitation):

- Group chats (any service) return `409` with code `2016`
  (`GroupChatNotSupported`).
- 1:1 SMS and RCS chats return `409` with code `2017`
  (`ChatServiceNotSupported`).

### Parameters

- `chatID: string`

### Returns

- `LocationRequestResponse`

  - `message: string`

  - `success: boolean`

### Example

```typescript
import LinqAPIV3 from '@linqapp/sdk';

const client = new LinqAPIV3({
  apiKey: process.env['LINQ_API_V3_API_KEY'], // This is the default and can be omitted
});

const locationRequestResponse = await client.chats.location.request(
  '975d0776-bd17-4273-8337-f346b4c661b0',
);

console.log(locationRequestResponse.message);
```

#### Response

```json
{
  "success": true,
  "message": "Location request sent"
}
```

## Get location data

`client.chats.location.retrieve(stringchatID, RequestOptionsoptions?): GetChatLocationResponse`

**get** `/v3/chats/{chatId}/location`

Retrieve the current location for contacts sharing with you in a chat.

The response is wrapped in the standard `{ "success": true, "data": ... }` envelope —
the body is **not** a bare GeoJSON document. `data` is a
[GeoJSON](https://datatracker.ietf.org/doc/html/rfc7946) `FeatureCollection` with a
`Feature` for each participant actively sharing their location.

Works for both 1:1 and group chats. In group chats, `data.features` contains a separate
feature for each participant who is sharing. Each feature's `properties.handle` identifies the user.

A participant appears as soon as their first position arrives, typically
within a second or two of sharing starting.

Returns an empty `data.features` array if no one is sharing or no location data is
available yet. If sharing started but this stays empty, see the **Location Sharing**
overview.

Poll this endpoint to track a moving contact. `properties.updated_at`
reflects when each participant's location was last updated. There is no
coordinate-update webhook. See the **Location Sharing** overview for polling
guidance.

### Parameters

- `chatID: string`

### Returns

- `GetChatLocationResponse`

  - `data: Data`

    - `features: Array<Feature>`

      - `geometry: Geometry`

        - `coordinates: Array<number>`

          [longitude, latitude]

        - `type: "Point"`

          - `"Point"`

      - `properties: Properties`

        - `handle: string`

          Phone number or email of the person sharing their location

        - `address?: string`

          Full street address

        - `locality?: string`

          City or locality name

        - `updated_at?: string`

          When the location was last updated

      - `type: "Feature"`

        - `"Feature"`

    - `type: "FeatureCollection"`

      - `"FeatureCollection"`

  - `success: boolean`

### Example

```typescript
import LinqAPIV3 from '@linqapp/sdk';

const client = new LinqAPIV3({
  apiKey: process.env['LINQ_API_V3_API_KEY'], // This is the default and can be omitted
});

const getChatLocationResponse = await client.chats.location.retrieve(
  '975d0776-bd17-4273-8337-f346b4c661b0',
);

console.log(getChatLocationResponse.data);
```

#### Response

```json
{
  "error": {
    "status": 400,
    "code": 1002,
    "message": "Phone number must be in E.164 format",
    "doc_url": "https://docs.linqapp.com/channel/imessage/error/codes/1xxx/1002/"
  },
  "success": false
}
```

## Stop location sharing

`client.chats.location.stop(stringchatID, LocationStopParamsbody, RequestOptionsoptions?): StopChatLocationSharingResponse`

**delete** `/v3/chats/{chatId}/location`

Stop a contact's location share with you. `handle` is required and names whose
share to end.

Returns `202` when the request is accepted. The stop is carried out on the contact's
device, and the `location.sharing.stopped` webhook fires once sharing has ended.

Sharing is per contact, so this ends that contact's share in every chat you have
with them.

Returns `404` if the contact isn't currently sharing.

### Parameters

- `chatID: string`

- `body: LocationStopParams`

  - `handle: string`

    Phone number (E.164 format) or email address of the contact whose share to end

### Returns

- `StopChatLocationSharingResponse`

  - `message: string`

  - `success: boolean`

### Example

```typescript
import LinqAPIV3 from '@linqapp/sdk';

const client = new LinqAPIV3({
  apiKey: process.env['LINQ_API_V3_API_KEY'], // This is the default and can be omitted
});

const stopChatLocationSharingResponse = await client.chats.location.stop(
  '975d0776-bd17-4273-8337-f346b4c661b0',
  { handle: '+15551234567' },
);

console.log(stopChatLocationSharingResponse.message);
```

#### Response

```json
{
  "success": true,
  "message": "Location sharing stop requested"
}
```

## Domain Types

### Get Chat Location Response

- `GetChatLocationResponse`

  - `data: Data`

    - `features: Array<Feature>`

      - `geometry: Geometry`

        - `coordinates: Array<number>`

          [longitude, latitude]

        - `type: "Point"`

          - `"Point"`

      - `properties: Properties`

        - `handle: string`

          Phone number or email of the person sharing their location

        - `address?: string`

          Full street address

        - `locality?: string`

          City or locality name

        - `updated_at?: string`

          When the location was last updated

      - `type: "Feature"`

        - `"Feature"`

    - `type: "FeatureCollection"`

      - `"FeatureCollection"`

  - `success: boolean`

### Location Request Response

- `LocationRequestResponse`

  - `message: string`

  - `success: boolean`

### Stop Chat Location Sharing Response

- `StopChatLocationSharingResponse`

  - `message: string`

  - `success: boolean`
