> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cyclemate.club/llms.txt
> Use this file to discover all available pages before exploring further.

# Place Details

> Resolve a picked autocomplete prediction to coordinates, closing the Google billing session

## Overview

Resolves a `placeId` from [Place Autocomplete](/api-reference/places/autocomplete) to its coordinates via Google Place Details (field mask `id,displayName,formattedAddress,location`). Passing the interaction's `sessionToken` closes the Google Autocomplete session, billing the whole typing interaction (N autocomplete calls + this one) as a single session — clients should always pass it when they have one.

## Authentication

Same as autocomplete — any authenticated caller; shares the `place-search` rate-limit bucket (120 / 60 per 60s, user / anon).

## Body Parameters

<ParamField body="placeId" type="string" required>
  The Google `placeId` from an autocomplete prediction (raw, without the client-side `google:` namespace prefix).
</ParamField>

<ParamField body="sessionToken" type="string">
  The session token the autocomplete calls used. Optional but strongly recommended — omitting it bills the preceding autocomplete calls per-request instead of per-session.
</ParamField>

## Response

<ResponseField name="id" type="string">
  The canonical Google place id.
</ResponseField>

<ResponseField name="displayName" type="object">
  `{ text }` — the place's display name (e.g. `"Waterloo Station"`).
</ResponseField>

<ResponseField name="formattedAddress" type="string">
  Formatted address string.
</ResponseField>

<ResponseField name="location" type="object">
  `{ latitude, longitude }` — **note the order**: this is Google's lat/lng object, not a Mapbox-style `[lng, lat]` pair. The planner client (`fetchGooglePlaceDetails`) owns the axis swap; this contract is locked in by `packages/shared/__fixtures__/google-place-details-waterloo.json` and its regression test.
</ResponseField>

## Example

```bash theme={null}
curl -s -X POST 'https://YOUR_PROJECT.supabase.co/functions/v1/place-search/details' \
  -H 'Authorization: Bearer YOUR_PUBLISHABLE_KEY' \
  -H 'Content-Type: application/json' \
  -d '{ "placeId": "ChIJq5ZP7bkEdkgRehp2VdTG7Vs", "sessionToken": "33333333-3333-4333-8333-333333333333" }'
```

```json theme={null}
{
  "id": "ChIJq5ZP7bkEdkgRehp2VdTG7Vs",
  "displayName": { "text": "Waterloo Station" },
  "formattedAddress": "London, UK",
  "location": { "latitude": 51.5032404, "longitude": -0.1134032 }
}
```

## Errors

Same table as [Place Autocomplete](/api-reference/places/autocomplete); a `502` here means the Google details call itself failed (`upstream_status` in the body — e.g. `404` for an unknown placeId surfaces as `502` with `upstream_status: 404`).
