---
title: "Search locations by prefix"
method: GET
path: "/api/v2/numbers/countries/{country_id}/locations"
tags: ["Numbers & Inventory"]
---

# Search locations by prefix

`GET /api/v2/numbers/countries/{country_id}/locations`

## Request

- Base URL: `https://app.didlogic.com`
- URL: `https://app.didlogic.com/api/v2/numbers/countries/{country_id}/locations`
- Auth: HTTP bearer

Search for locations (cities) that have DID numbers starting with a specific prefix.

**Important notes:**
- Useful for finding locations with specific area codes
- Prefix can be partial number (e.g., "212" for NYC area code)
- Returns combined location information (country, state, city)

**When to use:**
- Implementing "vanity number" search by prefix
- Finding locations with specific area codes
- Reverse lookup of number to location

`locations[].city_id` feeds numbers_countries_cities_dids_index and numbers_search_show
(`city_id`). `locations[].state_id` feeds numbers_search_show (`region_id`).

## Path parameters

- `country_id` integer, required

## Query parameters

- `prefix` integer, required
- `sms_enabled` string

## Response `200`

returns list of locations

- object
  - `locations` object[], required: List of locations matching search criteria
    - `city_id` integer, required: City identifier
    - `city_name` string, required: City name
    - `country_name` string, required: Country name
    - `state_id` integer, required: State identifier (if applicable)
    - `country_id` integer, required: Country identifier
    - `label` string, required: Combined location label for display
    - `city_code` integer, required: City code/area code
    - `state_name` string, required: State name (if applicable)

## Other responses

- `401`: returns unauthorized
- `403`: returns forbidden
- `404`: returns not found

---

[API](https://skmtc.dev/didlogic/apis/get-started.md) · [All operations](https://skmtc.dev/didlogic/apis/get-started/llms.txt) · [OpenAPI document](https://skmtc.dev/didlogic/apis/get-started/revisions/dc972d592b34?raw)
