# GET /v1/postcodes/{postcode}

> Index: https://kartpunkt.se/llms.txt

operationId: `lookupPostcode`. A postnummer's postorter and kommuner.
Tag: `addresses`.

The postorter and kommuner a postnummer is used in, with how many addresses each has, from the address register. To find or check a whole address, use `POST /v1/geocode` or `POST /v1/addresses/validate`.

## Request

`GET https://api.kartpunkt.se/v1/postcodes/{postcode}` with `Authorization: Bearer $KARTPUNKT_API_KEY`, from your backend (never browser code: the key would leak, and CORS is not enabled).

Parameters:
- `postcode` (path, string, pattern `^\d{3} ?\d{2}$`, required): Postnummer, five digits, optionally with a space after the third (URL-encode the space).

## Response 200

Example:

```json
{
  "postcode": "75797",
  "localities": [
    {
      "locality": "Uppsala",
      "municipality_code": "0380",
      "municipality": "Uppsala",
      "county_code": "03",
      "county": "Uppsala län",
      "addresses": 30
    }
  ],
  "provenance": {
    "synthetic": true,
    "sources": [
      {
        "id": "synthetic",
        "name": "Kartpunkt synthetic test addresses",
        "licence": "CC0-1.0",
        "attribution": "Syntetiska testadresser från Kartpunkt, inte verkliga adresser.",
        "url": "https://creativecommons.org/publicdomain/zero/1.0/",
        "updated": "2026-10-13"
      }
    ]
  }
}
```

- `postcode` (string): Postnummer, five digits without space.
- `localities` (array of object): Postorter and kommuner the postnummer is used in, most addresses first. Usually one.
  - `locality` (string | null): Postort; null for the addresses with this postnummer that have none.
  - `municipality_code` (string): Kommunkod, four digits.
  - `municipality` (string): Kommun name.
  - `county_code` (string | null): Länskod, two digits as the register delivers it (e.g. '03' for Uppsala län); null when the address has none.
  - `county` (string | null): Län name as SCB writes it, e.g. 'Uppsala län'; null when county_code is null or is not one of Sweden's 21 län codes.
  - `addresses` (integer): Number of current addresses with this postnummer in this postort and kommun.
- `provenance` ([Provenance](https://api.kartpunkt.se/docs/shapes/Provenance.md))

## Errors

Every error is `{ error, message, param?, doc_url }`; `message` says what to do next. All codes: [https://api.kartpunkt.se/errors](https://api.kartpunkt.se/errors). What to do on each, with retries: [https://api.kartpunkt.se/docs/recipes/errors-and-retries.md](https://api.kartpunkt.se/docs/recipes/errors-and-retries.md).

- [`invalid_request`](https://api.kartpunkt.se/errors/invalid_request) (400): The request does not match the API schema. Fix the fields named in this message; see /openapi.json.
- [`unauthorized`](https://api.kartpunkt.se/errors/unauthorized) (401): Missing or unknown API key. Send it as 'Authorization: Bearer <key>' (or 'x-api-key'), read from the KARTPUNKT_API_KEY environment variable. The user creates a kp_test_ key on their Kartpunkt account page (https://kartpunkt.se/konto) and puts it in KARTPUNKT_API_KEY themselves; never ask them to paste a key into chat.
- [`live_access_required`](https://api.kartpunkt.se/errors/live_access_required) (403): This account is not approved for live data: kp_live_ keys are for customers under contract. Use a kp_test_ key. To ask for live access, the account holder writes to hej@kartpunkt.se, or orders a plan at https://kartpunkt.se/konto#plan.
- [`use_not_permitted`](https://api.kartpunkt.se/errors/use_not_permitted) (403): This operation would use a data source in a way its licence or approval does not allow (see GET /v1/sources). It cannot be answered for this key.
- [`not_found`](https://api.kartpunkt.se/errors/not_found) (404): Nothing matches. Check the value; postnummer used only for PO boxes (box addresses) are not in the address register.
- [`quota_exceeded`](https://api.kartpunkt.se/errors/quota_exceeded) (429): Request limit or plan quota reached (per minute, per day, or the account plan's monthly quota). Wait the number of seconds in the Retry-After header, then retry; without Retry-After, no wait helps: tell the account holder what this message says.
- [`internal_error`](https://api.kartpunkt.se/errors/internal_error) (500): Something failed on our side. Retry after a few seconds; if it keeps failing, contact hej@kartpunkt.se.
- [`live_data_unavailable`](https://api.kartpunkt.se/errors/live_data_unavailable) (503): Live data is not available yet: it opens when Kartpunkt's import of Lantmäteriet's address register completes. Use a kp_test_ key until then.

## Limits

none

## Metering

With a `kp_live_` key, one live call per request; its postorter are counted as results but toward no address limit.
