# Get Station

> Find GHN post offices (stations) near a district, e.g. to let a shop drop off parcels at a station.

## Endpoint

| Environment | URL |
| --- | --- |
| Production | `https://online-gateway.ghn.vn/shiip/public-api/v2/station/get` |
| Staging | `https://dev-online-gateway.ghn.vn/shiip/public-api/v2/station/get` |

**Method**: `GET`

## Headers

| Header | Required | Description |
| --- | --- | --- |
| `Token` | Yes | Shop token (issued by GHN) — [get a token](https://developer.ghn.vn/en/docs/token/get-token.md) |
| `ShopId` | Yes | Shop ID (int) |
| `captcha` | Conditional | Some accounts (those without the station-lookup permission) must send a captcha token here, or the call returns HTTP 422. Contact GHN if you hit this |

## Parameters

- **district_id** (String): District ID (from [Get District](https://developer.ghn.vn/en/docs/master-data/get-district.md)).
- **ward_code** (String): Ward code (from [Get Ward](https://developer.ghn.vn/en/docs/master-data/get-ward.md)) to narrow the search
- **offset** (Int): Pagination offset. Default: `0`
- **limit** (Int): Page size. Default: GHN-defined

## Request Example

```bash
curl -X GET "https://dev-online-gateway.ghn.vn/shiip/public-api/v2/station/get?district_id=1444&offset=0&limit=20" \
  -H "Token: 5c1d8a9e-2f4b-11ed-..." \
  -H "ShopId: 92837"
```

## Response

`data` is an **array** of station objects (`[]` when there are no results, never `null`).

_Shape per GHN's field spec — this test account requires a captcha token, so a live success sample could not be captured (see the 422 below)._

```json
{
  "code": 200,
  "message": "Success",
  "data": [
    {
      "locationId": 1888,
      "locationName": "Bưu cục 1888 - Quận 1",
      "address": "123 Lê Lợi, Phường Bến Thành, Quận 1, TP. Hồ Chí Minh",
      "wardName": "Phường Bến Thành",
      "districtName": "Quận 1",
      "provinceName": "Hồ Chí Minh",
      "latitude": 10.7721,
      "longitude": 106.698,
      "email": "buucuc1888@ghn.vn"
    }
  ]
}
```

### Response Fields

| Field | Type | Description |
| --- | --- | --- |
| `locationId` | Int | **Station ID** — use it as `pick_station_id` when creating an order |
| `locationName` | String | Station name |
| `address` | String | Station address |
| `wardName` | String | Ward name |
| `districtName` | String | District name |
| `provinceName` | String | Province name |
| `latitude` | Float | Latitude |
| `longitude` | Float | Longitude |
| `email` | String | Station email |

### Error — captcha required (HTTP 422)

_Captured from a real Staging-environment call — this account lacks the station-lookup permission, so the endpoint requires a captcha token._

```json
{
  "code": 422,
  "message": "token contains an invalid number of segments",
  "data": null,
  "code_message": "SECURITY_CHECK_FAILED",
  "code_message_value": "Discover fraud and abuse potential"
}
```

## Error Codes

| code_message | HTTP | When |
| --- | --- | --- |
| `SECURITY_CHECK_FAILED` | 422 | The account needs a captcha token in the `captcha` header — contact GHN |
| `USER_ERR_COMMON` | 400 | Invalid input |
| `STATION_INVALID` | 400 | Station lookup failed on GHN's side |
| `SERVER_ERROR_COMMON` | 500 | Internal error |
