# AutoPostcode developer centre

Build with the AutoPostcode UK postcode lookup and validation API. Explore REST contracts, MCP tools, secure setup and credit rules.

Canonical page · https://autopostcode.com/developers

## Make your first call

Start with public product facts. When you’re ready, check an authenticated MCP connection for free or use a website key to look up a UK postcode.

- [Follow the API quickstart](https://autopostcode.com/api-quickstart)

- [Connect an agent](https://autopostcode.com/mcp-docs#setup)

- [Choose your MCP client](https://autopostcode.com/mcp-docs#clients)

- [Open developer centre](https://autopostcode.com/dashboard/developer)

Unix shell

```bash
curl -fsS 'https://autopostcode.com/api/public/facts'
```

## Find the right operation

Use a postcode lookup for a checkout button, autocomplete for a search-as-you-type form, and the contact-validation endpoints for email, phone or UK bank checks.

- [Postcode lookup](https://autopostcode.com/rest-api-reference#lookup)

- [Address autocomplete](https://autopostcode.com/rest-api-reference#autocomplete)

- [Record address selection](https://autopostcode.com/rest-api-reference#select)

- [Email validation](https://autopostcode.com/rest-api-reference#validate-email)

- [Phone validation](https://autopostcode.com/rest-api-reference#validate-phone)

- [UK bank account validation](https://autopostcode.com/rest-api-reference#validate-bank)

- [MCP tool reference](https://autopostcode.com/mcp-docs#tools)

## Developer resources

Download the JSON contract or copy the Markdown into your project’s development instructions.

- [OpenAPI 3.1 JSON](https://autopostcode.com/openapi.json)

- [Full Markdown documentation](https://autopostcode.com/developers.md)

- [WordPress and WooCommerce plugin setup](https://autopostcode.com/wordpress-plugin-install-guide)

- [Request logs](https://autopostcode.com/webhooks-and-logs)

---

# AutoPostcode API quickstart

Make a free AutoPostcode API call, configure a server-side website key and look up a UK postcode in cURL, PowerShell, JavaScript or Python.

Canonical page · https://autopostcode.com/api-quickstart

## Read product facts for free

This public endpoint requires no key and consumes no credits. A successful response is a JSON object with coverage.region, products, billing and developer links. An empty object indicates an unexpected response.

Unix shell

```bash
curl -fsS 'https://autopostcode.com/api/public/facts'
```

PowerShell

```powershell
Invoke-RestMethod -Uri 'https://autopostcode.com/api/public/facts'
```

JavaScript (Node.js)

```js
const response = await fetch('https://autopostcode.com/api/public/facts');
if (!response.ok) throw new Error('HTTP ' + response.status);
console.log(await response.json());
```

Python

```python
import json
from urllib.request import urlopen

with urlopen('https://autopostcode.com/api/public/facts', timeout=10) as response:
    print(json.load(response))
```

## Make an authenticated lookup

Create a website and API key in Dashboard → API Keys. Store it as AUTOPOSTCODE_API_KEY in your server or service’s secret store. The key starts with ap_live_. Configure it on the machine that actually sends the request.

These examples use SW1A 1AA. A matched lookup consumes one credit. A no-match lookup returns HTTP 404 and consumes no credit when billing access is active.

The response example shows the shape with synthetic address data. Let the user choose a candidate or enter their address manually.

- [API key dashboard](https://autopostcode.com/dashboard/api-keys)

- [Troubleshoot a request](https://autopostcode.com/api-error-handling)

- [Build an autocomplete flow](https://autopostcode.com/rest-api-reference#autocomplete)

Unix shell

```bash
curl -sS --get 'https://autopostcode.com/api/public/lookup' --data-urlencode 'postcode=SW1A 1AA' -H "x-api-key: $AUTOPOSTCODE_API_KEY"
```

PowerShell

```powershell
Invoke-RestMethod -Uri 'https://autopostcode.com/api/public/lookup?postcode=SW1A%201AA' -Headers @{ 'x-api-key' = $env:AUTOPOSTCODE_API_KEY }
```

JavaScript (Node.js)

```js
const key = process.env.AUTOPOSTCODE_API_KEY;
if (!key) throw new Error('Configure AUTOPOSTCODE_API_KEY on this server');
const url = new URL('https://autopostcode.com/api/public/lookup');
url.searchParams.set('postcode', 'SW1A 1AA');
const response = await fetch(url, { headers: { 'x-api-key': key } });
const requestId = response.headers.get('x-request-id');
if (response.status === 404) console.log('Offer manual address entry');
else if (!response.ok) throw new Error('HTTP ' + response.status + ' (' + requestId + ')');
else console.log(await response.json());
```

Python

```python
import json, os
from urllib.error import HTTPError
from urllib.request import Request, urlopen

request = Request('https://autopostcode.com/api/public/lookup?postcode=SW1A%201AA',
                  headers={'x-api-key': os.environ['AUTOPOSTCODE_API_KEY']})
try:
    with urlopen(request, timeout=15) as response:
        print(json.load(response))
except HTTPError as error:
    if error.code == 404:
        print('Offer manual address entry')
    else:
        print(error.code, error.headers.get('X-Request-Id'))
```

Illustrative response

```json
[
  {
    "postcode": "SW1A 1AA",
    "company": "",
    "line1": "1 Example Street",
    "line2": "",
    "line3": "",
    "dependent_locality": "",
    "town": "LONDON",
    "county": "Greater London",
    "country": "United Kingdom",
    "line1_full": "1 Example Street",
    "formatted_address": "1 Example Street, LONDON, Greater London, SW1A 1AA"
  }
]
```

---

# AutoPostcode REST API reference

HTTP methods, schemas, authentication, credit charges and examples for every supported AutoPostcode REST operation.

Canonical page · https://autopostcode.com/rest-api-reference

## Authentication and request format

The base URL is https://autopostcode.com/api/public. Use HTTPS and send an active website key as x-api-key or Authorization: Bearer. Access follows the website and workspace billing status.

The legacy api-key header, plain Authorization value and api_key query parameter remain accepted. Keep keys out of URLs and use documented headers for new integrations. POST validation calls also accept query parameters, with JSON body values taking precedence.

Pass personal data in POST for validation. Optional provider fields can be null, absent or unavailable. No developer REST operation exposes cursor pagination.

- [OpenAPI 3.1 JSON](https://autopostcode.com/openapi.json)

- [API key setup](https://autopostcode.com/api-authentication-and-keys)

## Postcode lookup

GET /api/public/lookup

Fill a UK checkout or verify delivery point options from a full postcode.

Access — active website API key and eligible workspace billing.

A matched lookup costs 1 credit. A no-match lookup records an attempt and consumes no credit when billing access permits the request.

200 returns an array of address candidates sourced from Royal Mail PAF. Empty address fields are strings. 404 means there were no addresses. No cursor is supplied. The fallback dataset can return up to 100 results. Let the user choose a delivery point. Repeating a successful request can charge again.

postcode (required, or use documented alias). Full UK postcode. Spaces and case are normalised.

Possible status codes include 400, 401, 402, 403, 404, 500, 503.

- [Error recovery](https://autopostcode.com/api-error-handling)

Request

```bash
curl -sS --get 'https://autopostcode.com/api/public/lookup' --data-urlencode 'postcode=SW1A 1AA' -H "x-api-key: $AUTOPOSTCODE_API_KEY"
```

JSON response schema

```json
{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "postcode": {
        "type": "string"
      },
      "company": {
        "type": "string"
      },
      "line1": {
        "type": "string"
      },
      "line2": {
        "type": "string"
      },
      "line3": {
        "type": "string"
      },
      "dependent_locality": {
        "type": "string"
      },
      "town": {
        "type": "string"
      },
      "county": {
        "type": "string"
      },
      "country": {
        "type": "string"
      },
      "line1_full": {
        "type": "string"
      },
      "formatted_address": {
        "type": "string"
      }
    },
    "required": [
      "postcode",
      "company",
      "line1",
      "line2",
      "line3",
      "dependent_locality",
      "town",
      "county",
      "country",
      "line1_full",
      "formatted_address"
    ]
  }
}
```

Illustrative response

```json
[
  {
    "postcode": "SW1A 1AA",
    "company": "",
    "line1": "1 Example Street",
    "line2": "",
    "line3": "",
    "dependent_locality": "",
    "town": "LONDON",
    "county": "Greater London",
    "country": "United Kingdom",
    "line1_full": "1 Example Street",
    "formatted_address": "1 Example Street, LONDON, Greater London, SW1A 1AA"
  }
]
```

## Address autocomplete

GET /api/public/autocomplete

Suggest UK addresses as the shopper types, then expand any returned group token.

Access — active website API key and eligible workspace billing.

1 credit for the first matched search in a session, with a rolling one-hour deduplication window. Short inputs and group expansion are free. An empty match set consumes no credit.

Use one session per address selection journey and reset when the shopper selects or clears the address. Without a client session, the server derives a 10-minute bucket from the key and visitor metadata. Debounce requests. Short or unsearchable input returns empty arrays. When credit fields are present they reflect settlement. Omitted values mean settlement was unavailable or did not apply. Group tokens expand results.

q (optional). Free text for initial search, minimum 3 characters. Alias: query. Omit when expanding a group.

group (optional). Opaque group token from the search response, maximum 512 characters. Takes precedence over q.

session (optional). Stable random ID for one search, up to 128 characters. Alias: session_id.

x-session-id (optional). Session identifier when neither query alias is supplied.

Possible status codes include 400, 401, 402, 403, 503.

- [Error recovery](https://autopostcode.com/api-error-handling)

Request

```bash
curl -sS --get 'https://autopostcode.com/api/public/autocomplete' --data-urlencode 'q=10 Downing' --data-urlencode "session=$AUTOPOSTCODE_SEARCH_ID" -H "x-api-key: $AUTOPOSTCODE_API_KEY"
```

JSON response schema

```json
{
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "query": {
          "type": "string"
        },
        "count": {
          "type": "integer",
          "minimum": 0
        },
        "groups": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "token": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "postcode": {
                "type": "string"
              },
              "count": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "token",
              "label",
              "postcode",
              "count"
            ]
          }
        },
        "suggestions": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "postcode": {
                "type": "string"
              },
              "company": {
                "type": "string"
              },
              "line1": {
                "type": "string"
              },
              "line2": {
                "type": "string"
              },
              "line3": {
                "type": "string"
              },
              "dependent_locality": {
                "type": "string"
              },
              "town": {
                "type": "string"
              },
              "county": {
                "type": "string"
              },
              "country": {
                "type": "string"
              },
              "line1_full": {
                "type": "string"
              },
              "formatted_address": {
                "type": "string"
              },
              "suggestion": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "raw": {
                "type": "object",
                "description": "Provider fields may vary. Use the normalised fields for display and storage."
              }
            },
            "required": [
              "postcode",
              "company",
              "line1",
              "line2",
              "line3",
              "dependent_locality",
              "town",
              "county",
              "country",
              "line1_full",
              "formatted_address",
              "suggestion",
              "label",
              "raw"
            ]
          }
        },
        "session": {
          "type": "string"
        },
        "credits_charged": {
          "type": "integer",
          "minimum": 0
        },
        "credits_remaining": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "query",
        "count",
        "groups",
        "suggestions"
      ]
    },
    {
      "type": "object",
      "properties": {
        "group": {
          "type": "string"
        },
        "count": {
          "type": "integer",
          "minimum": 0
        },
        "suggestions": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "postcode": {
                "type": "string"
              },
              "company": {
                "type": "string"
              },
              "line1": {
                "type": "string"
              },
              "line2": {
                "type": "string"
              },
              "line3": {
                "type": "string"
              },
              "dependent_locality": {
                "type": "string"
              },
              "town": {
                "type": "string"
              },
              "county": {
                "type": "string"
              },
              "country": {
                "type": "string"
              },
              "line1_full": {
                "type": "string"
              },
              "formatted_address": {
                "type": "string"
              },
              "suggestion": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "raw": {
                "type": "object",
                "description": "Provider fields may vary. Use the normalised fields for display and storage."
              }
            },
            "required": [
              "postcode",
              "company",
              "line1",
              "line2",
              "line3",
              "dependent_locality",
              "town",
              "county",
              "country",
              "line1_full",
              "formatted_address",
              "suggestion",
              "label",
              "raw"
            ]
          }
        }
      },
      "required": [
        "group",
        "count",
        "suggestions"
      ]
    }
  ]
}
```

Illustrative response

```json
{
  "query": "SW",
  "count": 0,
  "suggestions": [],
  "groups": [],
  "credits_charged": 0
}
```

## Record address selection

POST /api/public/select

Record the shopper's deliberate address selection for website analytics.

Access — active website API key and eligible workspace billing.

No credit charge. Billing access still applies.

Creates a selection analytics event. Submit once after a real selection. Use optional customer details only when authorised and necessary. Replays can create duplicate events.

Possible status codes include 400, 401, 402, 403, 500, 503.

- [Error recovery](https://autopostcode.com/api-error-handling)

Request

```bash
curl -sS 'https://autopostcode.com/api/public/select' -H "x-api-key: $AUTOPOSTCODE_API_KEY" -H 'content-type: application/json' --data '{"postcode":"SW1A 1AA"}'
```

JSON request schema

```json
{
  "type": "object",
  "properties": {
    "postcode": {
      "type": "string",
      "description": "Postcode originally searched."
    },
    "selected_postcode": {
      "type": "string",
      "description": "Postcode of the selected option."
    },
    "selected_address": {
      "type": "object",
      "description": "Selected address. Send the minimum supported fields."
    },
    "contact_name": {
      "type": "string"
    },
    "contact_email": {
      "type": "string"
    },
    "contact_phone": {
      "type": "string"
    }
  },
  "required": [
    "postcode"
  ]
}
```

JSON response schema

```json
{
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean"
    }
  },
  "required": [
    "ok"
  ]
}
```

Illustrative response

```json
{
  "ok": true
}
```

## Email validation

GET or POST /api/public/validate-email

Check address syntax and a mailbox verdict when NeverBounce is available.

Access — active website API key and eligible workspace billing.

1 credit for a local syntax rejection or provider verdict. Provider errors and unconfigured outcomes are free.

Prefer POST for personal data. Treat unknown as unresolved and risky as a request for review. A provider result does not guarantee delivery. Repeats can charge again.

email (required, or use documented alias). Email to check, up to 320 characters.

Possible status codes include 400, 401, 402, 403, 500, 503.

- [Error recovery](https://autopostcode.com/api-error-handling)

Request

```bash
curl -sS 'https://autopostcode.com/api/public/validate-email' -H "x-api-key: $AUTOPOSTCODE_API_KEY" -H 'content-type: application/json' --data '{"email":"example@example.com"}'
```

JSON request schema

```json
{
  "type": "object",
  "properties": {
    "email": {
      "type": "string",
      "description": "Email to check, up to 320 characters."
    }
  },
  "required": []
}
```

JSON response schema

```json
{
  "type": "object",
  "properties": {
    "email": {
      "type": "string"
    },
    "verdict": {
      "type": "string",
      "enum": [
        "valid",
        "invalid",
        "risky",
        "unknown"
      ]
    },
    "result": {
      "type": "string"
    },
    "flags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "suggested_correction": {
      "type": [
        "string",
        "null"
      ]
    },
    "credits_used": {
      "type": "integer",
      "minimum": 0
    },
    "credits_remaining": {
      "type": "integer",
      "minimum": 0
    }
  },
  "required": [
    "email",
    "verdict",
    "result",
    "flags",
    "suggested_correction",
    "credits_used",
    "credits_remaining"
  ]
}
```

Illustrative response

```json
{
  "email": "example@example.com",
  "verdict": "unknown",
  "result": "unknown",
  "flags": [
    "provider_not_configured"
  ],
  "suggested_correction": null,
  "credits_used": 0,
  "credits_remaining": 42
}
```

## Phone validation

GET or POST /api/public/validate-phone

Check phone format or request live HLR connectivity for an eligible number.

Access — active website API key and eligible workspace billing.

1 credit for format, 2 total when live HLR is performed and the provider reports no error.

valid describes formatting. verdict may also reflect an ABSENT HLR result. live=null means no HLR result was requested or attempted. unavailable denotes a provider issue. Unknown connectivity does not verify reachability. Repeats can charge again.

phone (required, or use documented alias). Phone number, up to 40 characters. Preserve its leading zero or + prefix.

country (optional). ISO two-letter parsing region for national numbers. Defaults to GB.

live (optional). Enable HLR for eligible numbers. Use true or 1.

Possible status codes include 400, 401, 402, 403, 500, 503.

- [Error recovery](https://autopostcode.com/api-error-handling)

Request

```bash
curl -sS 'https://autopostcode.com/api/public/validate-phone' -H "x-api-key: $AUTOPOSTCODE_API_KEY" -H 'content-type: application/json' --data '{"phone":"bad-format","country":"GB"}'
```

JSON request schema

```json
{
  "type": "object",
  "properties": {
    "phone": {
      "type": "string",
      "description": "Phone number, up to 40 characters. Preserve its leading zero or + prefix."
    },
    "country": {
      "type": "string",
      "description": "ISO two-letter parsing region for national numbers. Defaults to GB."
    },
    "live": {
      "description": "Enable HLR for eligible numbers. Use true or 1.",
      "oneOf": [
        {
          "type": "boolean"
        },
        {
          "type": "string",
          "enum": [
            "true",
            "false",
            "1",
            "0"
          ]
        }
      ]
    }
  },
  "required": []
}
```

JSON response schema

```json
{
  "type": "object",
  "properties": {
    "phone": {
      "type": "string"
    },
    "valid": {
      "type": "boolean"
    },
    "verdict": {
      "type": "string",
      "enum": [
        "valid",
        "invalid"
      ]
    },
    "country": {
      "type": [
        "string",
        "null"
      ]
    },
    "line_type": {
      "type": [
        "string",
        "null"
      ]
    },
    "national_format": {
      "type": [
        "string",
        "null"
      ]
    },
    "international_format": {
      "type": [
        "string",
        "null"
      ]
    },
    "live": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "properties": {
            "connectivity": {
              "type": "string"
            },
            "carrier": {
              "type": [
                "string",
                "null"
              ]
            },
            "ported": {
              "type": [
                "boolean",
                "null"
              ]
            }
          },
          "required": [
            "connectivity",
            "carrier",
            "ported"
          ]
        },
        {
          "type": "object",
          "properties": {
            "connectivity": {
              "type": "string",
              "enum": [
                "unavailable"
              ]
            }
          },
          "required": [
            "connectivity"
          ]
        }
      ]
    },
    "credits_used": {
      "type": "integer",
      "minimum": 0
    },
    "credits_remaining": {
      "type": "integer",
      "minimum": 0
    }
  },
  "required": [
    "phone",
    "valid",
    "verdict",
    "country",
    "line_type",
    "national_format",
    "international_format",
    "live",
    "credits_used",
    "credits_remaining"
  ]
}
```

Illustrative response

```json
{
  "phone": "bad-format",
  "valid": false,
  "verdict": "invalid",
  "country": null,
  "line_type": null,
  "national_format": null,
  "international_format": null,
  "live": null,
  "credits_used": 1,
  "credits_remaining": 41
}
```

## UK bank account validation

GET or POST /api/public/validate-bank

Check UK sort code and account number format with modulus checking, or attempt Confirmation of Payee.

Access — active website API key and eligible workspace billing.

1 credit for modulus, 10 total when CoP returns an available match outcome.

Use POST and keep leading zeroes. The offline check applies available modulus rules. Even a valid result cannot verify that the account exists or belongs to the named person. Review partial and unavailable CoP outcomes before deciding what to do. This operation does not initiate payment. Repeats can charge again.

sort_code (required, or use documented alias). UK sort code. Alias: sortcode.

account_number (required, or use documented alias). Account number as a string. Alias: account.

name (optional). Account holder name, required to attempt CoP.

cop (optional). Enable Confirmation of Payee. Use true or 1.

type (optional). Defaults to personal.

Possible status codes include 400, 401, 402, 403, 500, 503.

- [Error recovery](https://autopostcode.com/api-error-handling)

Request

```bash
curl -sS 'https://autopostcode.com/api/public/validate-bank' -H "x-api-key: $AUTOPOSTCODE_API_KEY" -H 'content-type: application/json' --data '{"sort_code":"00-00","account_number":"0000"}'
```

JSON request schema

```json
{
  "type": "object",
  "properties": {
    "sort_code": {
      "type": "string",
      "description": "UK sort code. Alias: sortcode."
    },
    "account_number": {
      "type": "string",
      "description": "Account number as a string. Alias: account."
    },
    "name": {
      "type": "string",
      "description": "Account holder name, required to attempt CoP."
    },
    "cop": {
      "description": "Enable Confirmation of Payee. Use true or 1.",
      "oneOf": [
        {
          "type": "boolean"
        },
        {
          "type": "string",
          "enum": [
            "true",
            "false",
            "1",
            "0"
          ]
        }
      ]
    },
    "type": {
      "type": "string",
      "enum": [
        "personal",
        "business"
      ],
      "description": "Defaults to personal."
    },
    "sortcode": {
      "type": "string",
      "description": "Alias for sort_code."
    },
    "account": {
      "type": "string",
      "description": "Alias for account_number."
    }
  },
  "required": []
}
```

JSON response schema

```json
{
  "type": "object",
  "properties": {
    "valid": {
      "type": "boolean"
    },
    "verdict": {
      "type": "string",
      "enum": [
        "valid",
        "invalid",
        "name_mismatch"
      ]
    },
    "sort_code": {
      "type": "string"
    },
    "account_number": {
      "type": "string"
    },
    "confirmation_of_payee": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "properties": {
            "match": {
              "type": "string",
              "enum": [
                "match",
                "partial",
                "no_match"
              ]
            },
            "account_name": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "match",
            "account_name"
          ]
        },
        {
          "type": "object",
          "properties": {
            "match": {
              "type": "string",
              "enum": [
                "unavailable"
              ]
            }
          },
          "required": [
            "match"
          ]
        }
      ]
    },
    "credits_used": {
      "type": "integer",
      "minimum": 0
    },
    "credits_remaining": {
      "type": "integer",
      "minimum": 0
    }
  },
  "required": [
    "valid",
    "verdict",
    "sort_code",
    "account_number",
    "confirmation_of_payee",
    "credits_used",
    "credits_remaining"
  ]
}
```

Illustrative response

```json
{
  "valid": false,
  "verdict": "invalid",
  "sort_code": "0000",
  "account_number": "0000",
  "confirmation_of_payee": null,
  "credits_used": 1,
  "credits_remaining": 40
}
```

## Product and pricing facts

GET /api/public/facts

Understand data coverage, integrations, published pricing and available documentation.

Access — anonymous.

Free. No key required.

Returns public facts only. No account usage, customer records or address rows. No pagination or writes.

- [Error recovery](https://autopostcode.com/api-error-handling)

Request

```bash
curl -sS 'https://autopostcode.com/api/public/facts'
```

JSON response schema

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "url": {
      "type": "string"
    },
    "summary": {
      "type": "string"
    },
    "data_source": {
      "type": "string"
    },
    "response_time": {
      "type": "string"
    },
    "coverage": {
      "type": "object",
      "properties": {
        "addresses": {
          "type": "string"
        },
        "postcodes": {
          "type": "string"
        },
        "region": {
          "type": "string"
        }
      },
      "required": [
        "addresses",
        "postcodes",
        "region"
      ]
    },
    "products": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "endpoint": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "name",
          "description",
          "endpoint"
        ]
      }
    },
    "billing": {
      "type": "object",
      "properties": {
        "unit": {
          "type": "string"
        },
        "autocomplete_rule": {
          "type": "string"
        },
        "trial_days": {
          "type": "integer",
          "minimum": 0
        },
        "annual_discount_pct": {
          "type": "integer",
          "minimum": 0
        },
        "currency": {
          "type": "string"
        },
        "vat": {
          "type": "string"
        },
        "plans": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "monthly_price_gbp": {
                "type": "number"
              },
              "monthly_lookups": {
                "type": "integer",
                "minimum": 0
              },
              "per_lookup_gbp": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "name",
              "monthly_price_gbp",
              "monthly_lookups",
              "per_lookup_gbp"
            ]
          }
        },
        "credit_packs": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "price_gbp": {
                "type": "number"
              },
              "credits": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "name",
              "price_gbp",
              "credits"
            ]
          }
        }
      },
      "required": [
        "unit",
        "autocomplete_rule",
        "trial_days",
        "annual_discount_pct",
        "currency",
        "vat",
        "plans",
        "credit_packs"
      ]
    },
    "price_beat_guarantee": {
      "type": "string"
    },
    "wordpress_plugin": {
      "type": "object",
      "properties": {
        "version": {
          "type": "string"
        },
        "download": {
          "type": "string"
        },
        "platforms": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "download",
        "platforms"
      ]
    },
    "developer": {
      "type": "object",
      "properties": {
        "openapi": {
          "type": "string"
        },
        "docs": {
          "type": "string"
        },
        "markdown": {
          "type": "string"
        },
        "mcp": {
          "type": "string"
        },
        "auth": {
          "type": "string"
        }
      },
      "required": [
        "openapi",
        "docs",
        "markdown",
        "mcp",
        "auth"
      ]
    },
    "contact": {
      "type": "string"
    }
  },
  "required": [
    "name",
    "url",
    "summary",
    "data_source",
    "response_time",
    "coverage",
    "products",
    "billing",
    "price_beat_guarantee",
    "wordpress_plugin",
    "developer",
    "contact"
  ]
}
```

---

# AutoPostcode MCP setup and tool reference

Connect an AI agent to AutoPostcode over Streamable HTTP. Read public product facts, verify a scoped connection and look up UK postcodes.

Canonical page · https://autopostcode.com/mcp-docs

## Connect over Streamable HTTP

Use https://autopostcode.com/mcp as a remote Streamable HTTP URL. The endpoint returns JSON over POST. The GET event stream, session deletion and legacy SSE transport are unavailable.

Public facts require no account or credential. For authenticated tools, the workspace owner creates a website-bound agent key in Dashboard → API & MCP. Choose connection:read for the free check, and add postcode:read only when the agent may spend credits on lookups.

Store the one-time secret as AUTOPOSTCODE_AGENT_KEY in the executing client host’s secret manager. Pass it as Authorization: Bearer. A remote or containerised client needs the value provisioned there. Keep the value out of source, prompts, chat, URLs and logs.

Run get_connection_status first. It should return connected=true, expires_at in UTC and the authorised scopes. Billing readiness is checked separately at lookup. For rotation, install and test a replacement key before revoking the old one.

- [Create an agent key](https://autopostcode.com/dashboard/developer)

- [MCP transport specification](https://modelcontextprotocol.io/specification/2025-11-25/basic/transports)

Coding agent setup prompt

```text
Integrate AutoPostcode for the task I describe. Read https://autopostcode.com/developers.md and follow its current contracts.

Start with public product facts. Choose only the permission needed. For an authenticated MCP smoke check, use get_connection_status with a connection:read key. It costs zero credits.

Ask me to configure AUTOPOSTCODE_AGENT_KEY in the client host's secret storage, including on a remote machine if that is where the client runs. Never ask for the value in chat, source, prompts or logs.

Show me the transport, tool, intended scope and expected result. Wait for my approval before consuming credits or sending customer information. For a lookup retry, reuse the same retry UUID. Report the X-Request-Id and redact secrets and customer data.
```

Initialize (cURL)

```bash
curl -i 'https://autopostcode.com/mcp' \
  -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
  --data '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"manual-check","version":"1.0.0"}}}'
```

Acknowledge initialization (cURL)

```bash
curl -i 'https://autopostcode.com/mcp' \
  -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
  --data '{"jsonrpc":"2.0","method":"notifications/initialized"}'
```

List tools (cURL)

```bash
curl -i 'https://autopostcode.com/mcp' \
  -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
  --data '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
```

Authenticated first read (cURL)

```bash
curl -i 'https://autopostcode.com/mcp' \
  -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
  -H "Authorization: Bearer $AUTOPOSTCODE_AGENT_KEY" \
  --data '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_connection_status","arguments":{}}}'
```

Authenticated first read (PowerShell)

```powershell
$headers = @{ Accept = 'application/json, text/event-stream'; Authorization = "Bearer $env:AUTOPOSTCODE_AGENT_KEY" }
$body = '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_connection_status","arguments":{}}}'
Invoke-RestMethod -Method Post -Uri 'https://autopostcode.com/mcp' -Headers $headers -ContentType 'application/json' -Body $body
```

## Client setup and verification

Choose a dedicated client guide for setup steps, credential requirements and the exact result of the live test for that client.

VS Code — configure a remote HTTP server with secure input for the Bearer header. Target get_connection_status. A real connection is unverified.

- [Claude and Claude Code MCP setup](https://autopostcode.com/claude-mcp)

- [ChatGPT MCP setup](https://autopostcode.com/chatgpt-mcp)

- [Codex MCP setup](https://autopostcode.com/codex-mcp)

- [Gemini CLI and Antigravity MCP setup](https://autopostcode.com/gemini-mcp)

- [VS Code MCP guide](https://code.visualstudio.com/docs/copilot/customization/mcp-servers)

VS Code .vscode/mcp.json

```json
{
  "inputs": [
    {
      "id": "autopostcode-key",
      "type": "promptString",
      "description": "AutoPostcode agent key",
      "password": true
    }
  ],
  "servers": {
    "autopostcode": {
      "type": "http",
      "url": "https://autopostcode.com/mcp",
      "headers": {
        "Authorization": "Bearer ${input:autopostcode-key}"
      }
    }
  }
}
```

## MCP tools

tools/list returns current tool names and schemas without exposing account data.

- [get_product_facts](https://autopostcode.com/mcp-docs#get_product_facts)

- [get_connection_status](https://autopostcode.com/mcp-docs#get_connection_status)

- [lookup_postcode](https://autopostcode.com/mcp-docs#lookup_postcode)

## Read public product facts

get_product_facts

Get public UK data coverage, published pricing and AutoPostcode integration links.

Access — Anonymous. Free

Returns public JSON without workspace data. Repeat freely under normal use.

- [MCP error recovery](https://autopostcode.com/api-error-handling#mcp-errors)

MCP request

```bash
curl -i 'https://autopostcode.com/mcp' \
  -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
  --data '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"get_product_facts","arguments":{}}}'
```

Arguments schema

```json
{
  "type": "object",
  "properties": {},
  "required": [],
  "additionalProperties": false
}
```

Structured result schema

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "url": {
      "type": "string"
    },
    "summary": {
      "type": "string"
    },
    "data_source": {
      "type": "string"
    },
    "response_time": {
      "type": "string"
    },
    "coverage": {
      "type": "object",
      "properties": {
        "addresses": {
          "type": "string"
        },
        "postcodes": {
          "type": "string"
        },
        "region": {
          "type": "string"
        }
      },
      "required": [
        "addresses",
        "postcodes",
        "region"
      ]
    },
    "products": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "endpoint": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "name",
          "description",
          "endpoint"
        ]
      }
    },
    "billing": {
      "type": "object",
      "properties": {
        "unit": {
          "type": "string"
        },
        "autocomplete_rule": {
          "type": "string"
        },
        "trial_days": {
          "type": "integer",
          "minimum": 0
        },
        "annual_discount_pct": {
          "type": "integer",
          "minimum": 0
        },
        "currency": {
          "type": "string"
        },
        "vat": {
          "type": "string"
        },
        "plans": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "monthly_price_gbp": {
                "type": "number"
              },
              "monthly_lookups": {
                "type": "integer",
                "minimum": 0
              },
              "per_lookup_gbp": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "name",
              "monthly_price_gbp",
              "monthly_lookups",
              "per_lookup_gbp"
            ]
          }
        },
        "credit_packs": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "price_gbp": {
                "type": "number"
              },
              "credits": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "name",
              "price_gbp",
              "credits"
            ]
          }
        }
      },
      "required": [
        "unit",
        "autocomplete_rule",
        "trial_days",
        "annual_discount_pct",
        "currency",
        "vat",
        "plans",
        "credit_packs"
      ]
    },
    "price_beat_guarantee": {
      "type": "string"
    },
    "wordpress_plugin": {
      "type": "object",
      "properties": {
        "version": {
          "type": "string"
        },
        "download": {
          "type": "string"
        },
        "platforms": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "download",
        "platforms"
      ]
    },
    "developer": {
      "type": "object",
      "properties": {
        "openapi": {
          "type": "string"
        },
        "docs": {
          "type": "string"
        },
        "markdown": {
          "type": "string"
        },
        "mcp": {
          "type": "string"
        },
        "auth": {
          "type": "string"
        }
      },
      "required": [
        "openapi",
        "docs",
        "markdown",
        "mcp",
        "auth"
      ]
    },
    "contact": {
      "type": "string"
    }
  },
  "required": [
    "name",
    "url",
    "summary",
    "data_source",
    "response_time",
    "coverage",
    "products",
    "billing",
    "price_beat_guarantee",
    "wordpress_plugin",
    "developer",
    "contact"
  ]
}
```

## Check a workspace connection

get_connection_status

Check that an AutoPostcode agent key is active and read its scopes and expiry.

Access — connection:read. Free

Returns connected=true, current scopes and UTC expiry. Billing readiness is evaluated separately for a lookup.

- [MCP error recovery](https://autopostcode.com/api-error-handling#mcp-errors)

MCP request

```bash
curl -i 'https://autopostcode.com/mcp' \
  -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
  -H "Authorization: Bearer $AUTOPOSTCODE_AGENT_KEY" \
  --data '{"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"get_connection_status","arguments":{}}}'
```

Arguments schema

```json
{
  "type": "object",
  "properties": {},
  "required": [],
  "additionalProperties": false
}
```

Structured result schema

```json
{
  "type": "object",
  "properties": {
    "connected": {
      "type": "boolean"
    },
    "scopes": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "connection:read",
          "postcode:read"
        ]
      }
    },
    "expires_at": {
      "type": "string"
    }
  },
  "required": [
    "connected",
    "scopes",
    "expires_at"
  ]
}
```

## Look up a UK postcode

lookup_postcode

Return address candidates for one full UK postcode. A matched lookup consumes one credit. Use the same UUID only when retrying the same lookup.

Access — postcode:read. 1 credit for a match, zero for a miss or a replay within 24 hours.

200 JSON-RPC success can contain an empty address array. No pagination. The fallback source can return up to 100 results. Offer manual entry on a miss. Reuse the retry UUID only for the same postcode and credential. Addresses are resolved again on retries. Application failures set isError=true.

- [MCP error recovery](https://autopostcode.com/api-error-handling#mcp-errors)

MCP request

```bash
curl -i 'https://autopostcode.com/mcp' \
  -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
  -H "Authorization: Bearer $AUTOPOSTCODE_AGENT_KEY" \
  --data '{"jsonrpc":"2.0","id":6,"method":"tools/call","params":{"name":"lookup_postcode","arguments":{"postcode":"SW1A 1AA","retry_id":"02aafd5f-8909-49cb-ad09-0fd6b57d5325"}}}'
```

Arguments schema

```json
{
  "type": "object",
  "properties": {
    "postcode": {
      "type": "string",
      "minLength": 5,
      "maxLength": 12
    },
    "retry_id": {
      "type": "string",
      "format": "uuid"
    }
  },
  "required": [
    "postcode",
    "retry_id"
  ],
  "additionalProperties": false
}
```

Structured result schema

```json
{
  "type": "object",
  "properties": {
    "count": {
      "type": "integer",
      "minimum": 0
    },
    "addresses": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "postcode": {
            "type": "string"
          },
          "company": {
            "type": "string"
          },
          "line1": {
            "type": "string"
          },
          "line2": {
            "type": "string"
          },
          "line3": {
            "type": "string"
          },
          "dependent_locality": {
            "type": "string"
          },
          "town": {
            "type": "string"
          },
          "county": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "line1_full": {
            "type": "string"
          },
          "formatted_address": {
            "type": "string"
          }
        },
        "required": [
          "postcode",
          "company",
          "line1",
          "line2",
          "line3",
          "dependent_locality",
          "town",
          "county",
          "country",
          "line1_full",
          "formatted_address"
        ]
      }
    },
    "credits_charged": {
      "type": "integer",
      "minimum": 0
    },
    "replayed": {
      "type": "boolean"
    }
  },
  "required": [
    "count",
    "addresses",
    "credits_charged",
    "replayed"
  ]
}
```

---

# AutoPostcode API authentication and keys

Create, store and rotate AutoPostcode website API keys and scoped MCP agent keys.

Canonical page · https://autopostcode.com/api-authentication-and-keys

## Website keys

Use Dashboard → API Keys for existing website and plugin integrations. Website keys are tied to a single website and inherit its workspace credit pool. Store them in server configuration. Mint a replacement, update the integration and verify it before disabling the previous key.

- [Manage website keys](https://autopostcode.com/dashboard/api-keys)

## MCP agent keys

The workspace owner creates a dedicated ap_agent_ key bound to the MCP audience and a website. Choose the shortest available lifetime and the least privilege needed. The secret is shown once. Dashboard shows the masked identifier, scopes, expiry and last use. Create a replacement, verify get_connection_status and revoke the old key.

- [Manage agent keys](https://autopostcode.com/dashboard/developer)

- [Client setup](https://autopostcode.com/mcp-docs#clients)

---

# AutoPostcode API pricing and limits

Understand AutoPostcode credit rates, plan allowances, autocomplete windows, retries and credit exhaustion.

Canonical page · https://autopostcode.com/api-rate-limits

## Credit rules

Postcode lookup — A matched lookup costs 1 credit. A no-match lookup records an attempt and consumes no credit when billing access permits the request.

Address autocomplete — 1 credit for the first matched search in a session, with a rolling one-hour deduplication window. Short inputs and group expansion are free. An empty match set consumes no credit.

Record address selection — No credit charge. Billing access still applies.

Email validation — 1 credit for a local syntax rejection or provider verdict. Provider errors and unconfigured outcomes are free.

Phone validation — 1 credit for format, 2 total when live HLR is performed and the provider reports no error.

UK bank account validation — 1 credit for modulus, 10 total when CoP returns an available match outcome.

Product and pricing facts — Free. No key required.

- [Full pricing](https://autopostcode.com/pricing)

- [Workspace billing](https://autopostcode.com/dashboard/billing)

## Published plan allowances

Free Trial — 100 trial credits in the published offer.

Starter — 500 included lookups per month at £19, excluding VAT.

Growth — 1,600 included lookups per month at £59, excluding VAT.

Pro — 5,000 included lookups per month at £179, excluding VAT.

Scale — 15,000 included lookups per month at £449, excluding VAT.

Enterprise — 50,000 included lookups per month at £1299, excluding VAT.

## Rate limits and retries

The developer API does not publish a universal requests-per-minute limit. If infrastructure returns HTTP 429, honour Retry-After where present. Defer when you cannot tell whether a retry will duplicate a charge or side effect.

Debounce autocomplete and keep one session ID per search. For MCP postcode lookup, reuse the same credential and retry UUID for the same input for up to 24 hours. Other repeated calls can create new charges or events.

HTTP 402 can indicate insufficient credits, billing suspension or a required plan. Check Billing or ask the owner. Allowances and renewals depend on your plan, including any agency-managed allowance.

---

# AutoPostcode API troubleshooting

Resolve REST and MCP authentication, input, provider, billing and retry errors with targeted recovery steps.

Canonical page · https://autopostcode.com/api-error-handling

## HTTP status codes

400 — Correct the input shown in the error. Review required fields, aliases and method.

401 — Check that the full key is configured on the server sending the request. Rotate it if exposed.

402 — Check credits, plan status or unpaid invoices in Dashboard Billing before retrying.

403 — Check the website and key status. For MCP, also check expiry, workspace and permission.

404 — Confirm the full postcode and offer manual address entry if there is still no match.

429 — Slow down and honour Retry-After when supplied.

500 — Record the request ID for support. A retry on the REST API may charge or write again.

503 — Check service and billing availability. Use capped backoff only when replay is safe.

## MCP application errors

Inspect result.isError even after HTTP 200. JSON-RPC protocol errors are in the top-level error property. Tool errors include a stable code at the start of their text content.

agent_key_required or agent_key_unknown — set the correct secret on the client host. agent_key_inactive — check the key expiry, revocation, website and issuing owner.

missing_scope — ask the owner for a key with the minimum required permission. invalid_input — match the tool schema and check the postcode or retry UUID.

billing_blocked or insufficient_credits — review Billing. billing_unavailable or service_unavailable — retry later with the same retry UUID. retry_conflict — create a new UUID for a different postcode.

## Contact developer support

Include X-Request-Id if available, UTC time, method, operation and error code. Remove keys, full requests, addresses, contact data and bank details.

- [Contact support](https://autopostcode.com/contact-us)

- [Open your developer centre](https://autopostcode.com/dashboard/developer)

---

# AutoPostcode request logs and webhooks

Find attributable API and MCP activity by request ID, read settled credit charges and check webhook availability.

Canonical page · https://autopostcode.com/webhooks-and-logs

## Request log coverage

Dashboard → API & MCP shows attributable REST and MCP attempts. Match X-Request-Id from the response. Entries show UTC time, operation, transport, masked key, outcome, elapsed milliseconds and known settled credits.

An attempt may have zero credits or an unknown charge. HTTP 200 can contain an MCP application error. Anonymous traffic, unknown credentials and historical usage are outside this log. Older usage remains in Search Logs. Logs are retained for 30 days.

- [Open request logs](https://autopostcode.com/dashboard/developer#requests)

- [Troubleshooting](https://autopostcode.com/api-error-handling)

## Outbound low-credit webhooks

Where outbound webhooks are enabled, workspace owners can register up to five verified HTTPS endpoints in Dashboard → API & MCP. Use a public IPv4 DNS record and port 443. URL credentials, query parameters, fragments, private destinations and redirects are rejected. Agent keys have no subscription-management permission.

Copy the one-time signing secret to the receiving server. When you verify the endpoint, AutoPostcode sends a signed webhook.test with a challenge. After verifying the signature, respond with HTTP 2xx and echo data.challenge in the X-AutoPostcode-Challenge response header.

AutoPostcode emits credits.low when the balance crosses from at or above the workspace threshold to below it. The payload contains the observed balance, threshold, UTC time and delivery ID. The event describes the balance at capture time. Check current Billing before taking action. Email delivery and third-party billing operations use their existing flows.

Verify X-AutoPostcode-Signature over the original request bytes. The signed message is X-AutoPostcode-Timestamp + a dot + the unmodified JSON body, with HMAC-SHA256 and a v1= prefix. Compare signatures in constant time, check timestamp freshness and process each X-AutoPostcode-Delivery ID once.

The worker checks due deliveries every minute. Transient network errors, 408, 429 and 5xx can retry after approximately 1, 5, 30 and 120 minutes. At most five attempts are made. The same delivery ID is reused and each attempt is signed again. Other HTTP errors and blocked destinations are terminal.

Check delivery history for status, response code and next eligible attempt. A failed delivery stays in history for 30 days. Fix or replace the endpoint before the next crossing and reconcile the missed alert in Billing. To rotate the signing secret, disable the old endpoint and register and verify a replacement.

- [Manage endpoints](https://autopostcode.com/dashboard/developer#webhooks)

- [Contact support](https://autopostcode.com/contact-us)

- [Open your developer centre](https://autopostcode.com/dashboard/developer)

Verification event

```json
{
  "id": "a4be14af-5419-474d-8bfe-b26f09179f68",
  "type": "webhook.test",
  "created_at": "2026-11-22T10:00:00Z",
  "data": {
    "challenge": "f9a07bca-89b6-43e9-bc9b-67e081e266a4"
  }
}
```

Low-credit event

```json
{
  "id": "bb4d78a8-48cf-4d61-867a-fd745061e5db",
  "type": "credits.low",
  "created_at": "2026-11-22T10:04:00Z",
  "data": {
    "balance": 99,
    "threshold": 100
  }
}
```

---

# AutoPostcode API and MCP changelog

Dated developer changes and compatibility guidance for AutoPostcode REST and MCP.

Canonical page · https://autopostcode.com/api-changelog

## 22 November 2026 · Developer centre

Prepared searchable REST and MCP contracts, Markdown documentation, scoped agent credentials, request diagnostics and signed low-credit webhooks.

- [Explore the developer centre](https://autopostcode.com/developers)

## Compatibility policy

Existing website keys and endpoint paths remain supported. Accept additive fields, unknown provider outcomes and nullable fields. Changes requiring a client migration are documented here.

- [REST reference](https://autopostcode.com/rest-api-reference)

- [MCP compatibility](https://autopostcode.com/mcp-docs#clients)

---

# AutoPostcode address API documentation

Build UK postcode lookup and address autocomplete with Royal Mail PAF. Use secure server-side examples, session billing and checkout fallbacks.

Canonical page · https://autopostcode.com/address-api-documentation

## Return addresses for a full postcode

Use GET /api/public/lookup when a user clicks Find my address. The response is an array of candidate delivery points. Let the user choose the address. Offer manual entry when no address matches.

- [Postcode lookup contract](https://autopostcode.com/rest-api-reference#lookup)

Unix shell

```bash
curl -sS --get 'https://autopostcode.com/api/public/lookup' --data-urlencode 'postcode=SW1A 1AA' -H "x-api-key: $AUTOPOSTCODE_API_KEY"
```

PowerShell

```powershell
Invoke-RestMethod -Uri 'https://autopostcode.com/api/public/lookup?postcode=SW1A%201AA' -Headers @{ 'x-api-key' = $env:AUTOPOSTCODE_API_KEY }
```

JavaScript (Node.js)

```js
const key = process.env.AUTOPOSTCODE_API_KEY;
if (!key) throw new Error('Configure AUTOPOSTCODE_API_KEY on this server');
const url = new URL('https://autopostcode.com/api/public/lookup');
url.searchParams.set('postcode', 'SW1A 1AA');
const response = await fetch(url, { headers: { 'x-api-key': key } });
const requestId = response.headers.get('x-request-id');
if (response.status === 404) console.log('Offer manual address entry');
else if (!response.ok) throw new Error('HTTP ' + response.status + ' (' + requestId + ')');
else console.log(await response.json());
```

Python

```python
import json, os
from urllib.error import HTTPError
from urllib.request import Request, urlopen

request = Request('https://autopostcode.com/api/public/lookup?postcode=SW1A%201AA',
                  headers={'x-api-key': os.environ['AUTOPOSTCODE_API_KEY']})
try:
    with urlopen(request, timeout=15) as response:
        print(json.load(response))
except HTTPError as error:
    if error.code == 404:
        print('Offer manual address entry')
    else:
        print(error.code, error.headers.get('X-Request-Id'))
```

## Suggest addresses as the user types

Use GET /api/public/autocomplete with at least three meaningful characters for type-ahead. Display suggestions and groups, and expand an opaque group token when a user chooses a group.

Keep a random session ID for one address selection journey. Debounce requests and generate a new ID when the user selects an address or clears the field. The first matched request in a rolling one-hour session window consumes a credit.

Call from your server with the secured website key. Connect browser widgets to your own authenticated or rate-limited proxy and forward the session ID. Keep the website key out of all browser bundles.

- [Autocomplete and group contract](https://autopostcode.com/rest-api-reference#autocomplete)

- [Integration examples](https://autopostcode.com/address-api-integration-examples)

Server-side autocomplete (Node.js)

```js
async function searchAddresses(query, session) {
  const url = new URL('https://autopostcode.com/api/public/autocomplete');
  url.search = new URLSearchParams({ q: query, session });
  const response = await fetch(url, { headers: { 'x-api-key': process.env.AUTOPOSTCODE_API_KEY } });
  if (!response.ok) throw new Error('Autocomplete HTTP ' + response.status);
  return response.json();
}
```

---

# Test an AutoPostcode integration

Test response shapes without using customer data. Use example postcodes, mock REST results and check an authenticated MCP connection for free.

Canonical page · https://autopostcode.com/testing-and-sandbox

## Choose a testing path

Try the example address widget or call public product facts without a key. The example widget contains fixed sample data. For CI, use synthetic fixtures for a match, a 404 and each error your integration handles.

For an authenticated REST test, use a dedicated website key and a workspace permitted to spend test credits. An ap_live_ key uses that workspace’s real balance. The MCP get_connection_status tool authenticates with zero credits.

Verify manual entry for empty matches and provider problems. When you go live, configure the deployment host’s own key and check request history for an authorised test call.

- [Example address widget](https://autopostcode.com/address-api-sandbox-demo)

- [REST quickstart](https://autopostcode.com/api-quickstart)

- [MCP connection check](https://autopostcode.com/mcp-docs#get_connection_status)

---

# AutoPostcode MCP for Claude and Claude Code

Connect Claude Code to AutoPostcode’s UK postcode lookup MCP server. Get a tested connection check, a free public tool prompt and secure agent key setup.

Canonical page · https://autopostcode.com/claude-mcp

## What was verified in Claude Code

On 22 November 2026, Claude Code 2.1.330 reported Connected to AutoPostcode over Streamable HTTP after adding the public endpoint. The model-driven tool call reached Claude’s sign-in requirement. The authenticated AutoPostcode key and the Claude web and desktop connector flows remain unverified.

Start with public product facts. That tool returns AutoPostcode’s Royal Mail PAF coverage, published pricing and integration links with zero credits. UK postcode lookup is a separate tool that requires an appropriately scoped AutoPostcode agent key.

- [AutoPostcode MCP tool reference](https://autopostcode.com/mcp-docs#tools)

## Add AutoPostcode to Claude Code

Use Claude Code’s HTTP transport. Local scope keeps this connection specific to your current project and user.

1. Open a terminal in the project where you want to use AutoPostcode and run the setup commands.
2. Confirm the output shows autopostcode and Connected, or open Claude Code and enter /mcp to inspect the server.
3. Sign in to Claude Code when prompted, then use the free test prompt. Check the result shows United Kingdom and that Claude used get_product_facts.

- [Anthropic’s Claude Code MCP guide](https://code.claude.com/docs/en/mcp)

Add server and check health

```bash
claude mcp add --scope local --transport http autopostcode https://autopostcode.com/mcp
claude mcp list
```

Free test prompt

```text
Use the AutoPostcode MCP tool get_product_facts with no arguments. Tell me the coverage region from the tool result. Do not use web search or run a postcode lookup.
```

## Configure a scoped key in Claude Code

For authenticated tools, Claude Code documents environment variable expansion in .mcp.json. Keep AUTOPOSTCODE_AGENT_KEY in the environment of the process running Claude Code. The example contains a reference to the secret. A live keyed Claude Code call remains unverified.

1. Create a connection:read agent key in AutoPostcode. Add postcode:read only if you intend to permit credit-consuming lookups.
2. Set AUTOPOSTCODE_AGENT_KEY with your local secret manager. For a remote session, provision it where Claude Code runs.
3. Use this project entry instead of the public local entry if you need authentication. Merge it into your existing .mcp.json, approve the project connection if prompted and restart Claude Code.
4. Use the authenticated test prompt. A successful connection check costs zero credits.

- [Create a connection-only agent key](https://autopostcode.com/dashboard/developer)

- [AutoPostcode MCP errors](https://autopostcode.com/api-error-handling#mcp-errors)

Claude Code .mcp.json

```json
{
  "mcpServers": {
    "autopostcode": {
      "type": "http",
      "url": "https://autopostcode.com/mcp",
      "headers": {
        "Authorization": "Bearer ${AUTOPOSTCODE_AGENT_KEY}"
      }
    }
  }
}
```

Authenticated test prompt

```text
Call AutoPostcode get_connection_status with no arguments. Report whether it returns connected=true and the scopes shown. Do not run lookup_postcode or reveal a credential.
```

## Add a custom connector in Claude or Claude Desktop

Anthropic documents remote MCP connectors in Claude web and desktop. These steps are based on Anthropic’s connector guide. The Claude web and desktop flows have not been tested against AutoPostcode.

1. In a personal account, open Customize → Connectors and select the plus button. For Team or Enterprise, ask the workspace owner to add a custom web connector in Organization settings → Connectors.
2. Choose a custom web connector, name it AutoPostcode, and enter the full server URL shown below.
3. Review the authentication settings and choose No sign in for public facts. Enable the connector in the conversation and use the free test prompt.

- [Anthropic’s custom connector guide](https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp)

Claude custom connector URL

```text
https://autopostcode.com/mcp
```

---

# AutoPostcode MCP for ChatGPT

Set up the public AutoPostcode MCP tool as a custom ChatGPT plugin, check workspace requirements and understand which UK postcode tools need authentication.

Canonical page · https://autopostcode.com/chatgpt-mcp

## ChatGPT web verification status

On 22 November 2026, we reached the ChatGPT Plugins page in a signed-out browser. Adding a custom plugin and running get_product_facts require a signed-in workspace that permits custom MCP servers. A live ChatGPT plugin connection and tool call remain unverified.

OpenAI documents a No authentication option for remote Streamable HTTP servers. AutoPostcode’s public facts tool requires no key. The current AutoPostcode server requires a scoped Bearer key for private tools, and ChatGPT’s custom plugin setup offers OAuth or anonymous access. Authenticated AutoPostcode lookup is unavailable through this setup.

- [OpenAI’s custom MCP setup guide](https://help.openai.com/en/articles/12584461-connecting-custom-mcp-servers-in-chatgpt)

- [AutoPostcode MCP tool reference](https://autopostcode.com/mcp-docs#tools)

## Add the public AutoPostcode plugin in ChatGPT

The steps apply to ChatGPT on the web. Workspace permissions and Lockdown can limit which custom plugins you can add or invoke.

1. Sign in to ChatGPT on the web using a workspace that allows custom MCP servers.
2. Open Plugins, select the plus button and choose Add custom MCP server. Name the plugin AutoPostcode.
3. Under Connection, paste the AutoPostcode server URL and choose No authentication.
4. Review the connection warning and use Scan Tools if the form offers it. Look for get_product_facts. Create and install the plugin for your use.
5. In a conversation, type @ and select the installed AutoPostcode plugin. Use the free test prompt and check whether the tool call appears in the conversation.

- [ChatGPT Plugins](https://chatgpt.com/plugins)

Server URL

```text
https://autopostcode.com/mcp
```

Free test prompt

```text
Use the AutoPostcode MCP tool get_product_facts with no arguments. Tell me the coverage region from the tool result. Do not use web search or run a postcode lookup.
```

## Which AutoPostcode tools can ChatGPT use?

The public test targets get_product_facts for Royal Mail PAF coverage, pricing and integration links. If a tool listing also contains get_connection_status or lookup_postcode, those operations still require a scoped AutoPostcode agent key.

Keep AutoPostcode keys out of ChatGPT messages and plugin URLs. For a coded integration that needs authenticated postcode lookup, use the AutoPostcode REST quickstart or a client that can send an Authorization header.

- [REST API quickstart](https://autopostcode.com/api-quickstart)

- [Codex setup](https://autopostcode.com/codex-mcp)

---

# AutoPostcode MCP for Codex

Connect Codex to the AutoPostcode MCP server. Follow a live-tested public tool call, then configure scoped Bearer authentication for UK postcode lookup.

Canonical page · https://autopostcode.com/codex-mcp

## What was verified in Codex

On 22 November 2026, Codex CLI 0.171.0-alpha.13 called get_product_facts over Streamable HTTP against the live AutoPostcode server. The MCP tool returned United Kingdom as the coverage region. No AutoPostcode key was used and the call cost zero AutoPostcode credits.

An authenticated AutoPostcode agent-key call and the desktop and IDE plugin flows remain unverified. This guide’s tested surface is the Codex CLI.

- [AutoPostcode MCP tool reference](https://autopostcode.com/mcp-docs#tools)

## Add AutoPostcode to Codex CLI

Use the public connection for coverage, pricing and integration questions while developing a checkout or CRM feature.

1. Open a terminal with Codex installed and run codex login status to check your Codex session.
2. Add the remote MCP server, then start a new Codex session. In the terminal UI enter /mcp to inspect the connection.
3. Use the free test prompt. Verify Codex shows an AutoPostcode MCP tool call and returns United Kingdom.

- [OpenAI’s Codex MCP reference](https://developers.openai.com/codex/mcp)

Add and list the server

```bash
codex mcp add autopostcode --url https://autopostcode.com/mcp
codex mcp list
```

Free test prompt

```text
Use the AutoPostcode MCP tool get_product_facts with no arguments. Tell me the coverage region from the tool result. Do not use web search or run a postcode lookup.
```

## Configure a Codex Bearer token

Codex documents bearer_token_env_var for Streamable HTTP servers. Set the secret on the host that starts the Codex client. The authenticated example is based on the vendor configuration reference and remains unverified against AutoPostcode.

1. Create a connection:read agent key. Add postcode:read only if the agent may spend lookup credits.
2. Store the key as AUTOPOSTCODE_AGENT_KEY in the Codex process environment using your secret manager.
3. Add bearer_token_env_var to your existing mcp_servers.autopostcode entry in ~/.codex/config.toml. Restart Codex.
4. Run get_connection_status before trying a lookup. A successful connection check costs zero credits.

- [Create a connection-only agent key](https://autopostcode.com/dashboard/developer)

- [AutoPostcode MCP errors](https://autopostcode.com/api-error-handling#mcp-errors)

Codex config.toml

```toml
[mcp_servers.autopostcode]
url = "https://autopostcode.com/mcp"
bearer_token_env_var = "AUTOPOSTCODE_AGENT_KEY"
```

Authenticated test prompt

```text
Call AutoPostcode get_connection_status with no arguments. Report whether it returns connected=true and the scopes shown. Do not run lookup_postcode or reveal a credential.
```

---

# AutoPostcode MCP for Gemini CLI and Antigravity

Configure Google Gemini CLI or Antigravity for AutoPostcode’s UK address MCP server. See the verified steps for Gemini CLI and the limits of each Google client.

Canonical page · https://autopostcode.com/gemini-mcp

## Which Gemini client should I use?

This guide covers Google’s developer clients. The consumer Gemini app connection was not tested here. Google moved free individual and Google AI Pro and Ultra command-line access to Antigravity CLI in June 2026. Check Google’s current eligibility guidance if you use Gemini CLI with a business or enterprise account.

On 22 November 2026, Gemini CLI 0.70.0 reported Connected to the live AutoPostcode endpoint from a trusted test folder. Its model-driven call stopped at Google authentication setup, so no Gemini tool invocation or authenticated AutoPostcode call was confirmed. Antigravity remains unverified.

- [Google’s Gemini CLI project and transition guidance](https://github.com/google-gemini/gemini-cli)

- [Google Antigravity MCP guide](https://antigravity.google/docs/mcp?tab=cli)

## Connect in Gemini CLI

Gemini CLI’s http transport selects Streamable HTTP. User scope saves the server in your user settings. Gemini CLI disables both project and user MCP connections in an untrusted workspace, and requires a configured Google authentication method for model turns.

1. Open a workspace you trust. Run the add command with --scope user, then check that gemini mcp list reports Connected.
2. Start a Gemini CLI session with your eligible Google account. Use /mcp to see server and tool discovery in the session.
3. Use the free test prompt. Verify the client invoked get_product_facts and that the result shows United Kingdom.

- [Google’s Gemini CLI MCP reference](https://google-gemini.github.io/gemini-cli/docs/tools/mcp-server.html)

- [AutoPostcode MCP tool reference](https://autopostcode.com/mcp-docs#tools)

Add and list the server in Gemini CLI

```bash
gemini mcp add --scope user --transport http autopostcode https://autopostcode.com/mcp
gemini mcp list
```

Free test prompt

```text
Use the AutoPostcode MCP tool get_product_facts with no arguments. Tell me the coverage region from the tool result. Do not use web search or run a postcode lookup.
```

## Configure Google Antigravity CLI

Google documents Streamable HTTP servers in the Antigravity CLI MCP manager and workspace configuration. A live Antigravity connection and tool call remain unverified.

1. Open the Antigravity CLI MCP manager with /mcp. You can also use the workspace configuration file .agents/mcp_config.json.
2. Add AutoPostcode as a remote server using the serverUrl entry below. Leave authentication empty for the public facts check.
3. Check the server and tools in the MCP manager, then use the public test prompt. Confirm a visible tool result before relying on the connection.

- [Antigravity CLI configuration](https://antigravity.google/docs/mcp?tab=cli)

Antigravity CLI .agents/mcp_config.json

```json
{
  "mcpServers": {
    "autopostcode": {
      "serverUrl": "https://autopostcode.com/mcp"
    }
  }
}
```

## Authentication and UK postcode lookup

AutoPostcode private tools require an Authorization Bearer header containing an owner-issued agent key. Check your Google client’s header and secret configuration before attempting to connect. Authenticated AutoPostcode calls from these Google clients remain unverified.

Keep keys out of chat and checked-in settings. With a client that can securely send the header, use a connection:read key and get_connection_status as the first zero-credit authentication check. A matched postcode lookup can consume a credit.

- [Create a connection-only agent key](https://autopostcode.com/dashboard/developer)

- [AutoPostcode MCP errors](https://autopostcode.com/api-error-handling#mcp-errors)
