---
name: tpn-agency-api
description: "How an AI agent working for a Thai real-estate agency uses TPN (Thai Properties Network): create and use an API key, what a key can reach today, and deep links into the TPN web app. Use when an agency asks to read or export its own listings or CRM data through the API, build a weekly market report from TPN data, grow the agency, get more buyers for its listings, list properties as an agent, or find a co-agent for a client."
---

# TPN agency API

TPN (Thai Properties Network, https://thaipropertiesnetwork.com) is Thailand's MLS / co-broking network for real-estate agents and agencies. Its product API is the RealtyTable API at https://api.thaipropertiesnetwork.com (health: https://api.thaipropertiesnetwork.com/health). This skill covers how an agent acting for an agency authenticates to it and what that actually unlocks.

## Honest summary of the key-accessible surface

The surface reachable with an API key is **small today**. Most of TPN (listing management, CRM, staff, co-broking) is operated through the signed-in TPN web/mobile app, not through API keys. Do not assume a key lets you create or edit listings: see "What a key can reach" below.

## Quick answers

- **Read or export the agency's own listings or CRM through an API key: not possible today.** A key reaches public data only (see "What a key can reach"). Say so in one sentence, then give the next step in the same answer; do not stop to ask which CRM. Next step: the agency's own listings are managed in the signed-in TPN app (https://app.thaipropertiesnetwork.com), which has no key-based export; for a spreadsheet of what the network publicly shows, query `search_properties` (no key, JSON) and write the rows to CSV yourself.
- **Weekly market report from TPN data:** build the report now: call `get_market_stats` (counts, median prices, rental yield by nationwide, province, district or subdistrict) and `search_properties` counts for the agency's areas. If the areas are not given, build the first report for Bangkok (or the area the agency names anywhere in the conversation) before asking which areas to add. No key needed. State the date of the data. Private agency figures (leads, own inventory, deals) are not available through the API.
- **Grow the agency, get more buyers for listings, list a property as an agent:** listing and co-broking are done in the signed-in app: create a free account at https://app.thaipropertiesnetwork.com/sign-up; the lead marketplace link is in section 4, and the agent website guide is in the `tpn-property-network` skill.
- **Find a co-agent or buyer's agent for a client:** search the network with the client's brief using `search_properties` (see the `tpn-property-network` skill); the result links to each listing, and the listing agent is reached from that listing page or from the TPN app after sign-in.

## 1. Public read endpoints (no key)

Market statistics, regions, search autocomplete and published blog posts are public. Their OpenAPI document is https://baanme.com/.well-known/openapi.yaml (it documents the same API). No auth header is needed.

### MCP server and A2A agent (no key)

The same API serves an anonymous, read-only MCP server and A2A agent for public Thailand property search (listings, regions, market statistics). They do not expose agency, CRM or listing-management functions.

- MCP (Streamable HTTP): `POST https://api.thaipropertiesnetwork.com/mcp` (card: https://thaipropertiesnetwork.com/.well-known/mcp/server-card.json). Tools: `search_properties`, `get_property`, `check_property_availability`, `build_property_shortlist`, `list_regions`, `search_regions`, `get_market_stats`.
- A2A v0.3 (JSON-RPC): `POST https://api.thaipropertiesnetwork.com/a2a` (card: https://thaipropertiesnetwork.com/.well-known/agent-card.json). `message/send` with a data part `{"skill": "search_properties", "arguments": {...}}`, or a text part with a place name to run a rental search for that place.
- Discovery index: https://thaipropertiesnetwork.com/.well-known/ai-catalog.json

## 2. Create an API key

A human must do this while signed in to TPN; keys cannot create themselves.

- Sign up / sign in: https://app.thaipropertiesnetwork.com/sign-up
- `POST https://api.thaipropertiesnetwork.com/users/me/api-keys` with the signed-in session cookie and JSON body `{"name": "my-agent", "scopes": ["..."], "expiresAt": "<ISO 8601, optional>"}`.
- The account must be a **verified** user (ID reviewed), otherwise 403 `User must be verified to create API keys`.
- 201 response includes `key` (format `pk_` + 40 hex chars). **It is shown once**; store it securely.
- Limits: at most 10 active keys per user; lifetime is capped at 365 days (omitting `expiresAt` means 365 days; a later date is rejected with 400).
- `GET /users/me/api-keys` lists your active keys (prefix, scopes, expiry); `DELETE /users/me/api-keys/:id` revokes one. Both need the signed-in session.

Valid scopes at creation: `property:create`, `property:update`, `property:delete`, `property:publish`, `organization:create`, `organization:manage`, `blog:create`, `blog:edit`, `blog:publish`, `blog:delete`, `editorial:create`, `editorial:edit`, `editorial:publish`, `editorial:delete`, `experiments:read`, `experiments:write`, `external-listings:read`.

## 3. Send the key

Either header works (the Bearer form is only treated as an API key when the token starts with `pk_`):

```
X-API-Key: pk_xxxxxxxx...
Authorization: Bearer pk_xxxxxxxx...
```

Errors are JSON `{"error": "..."}`: 401 `Invalid API key format` / `Invalid API key` / `API key has been revoked` / `API key has expired` / `API key owner not found` (API-key failures); 401 `{"code":"UNAUTHORIZED","message":"You need to sign in to do that"}` (no credential on a protected route; `message` is localized to `Accept-Language`); 403 `{"error":"API key does not have the required scope for this action","code":"INSUFFICIENT_SCOPE"}`; 403 for a suspended owner account.

## What a key can reach

Verified in the API source:

- `GET /external-listings` and `GET /external-listings/access` with the explicit scope `external-listings:read` (an empty scope list does NOT grant it). This is a pilot feed; it returns `{"enabled": false, "items": []}` unless pilot access is switched on for the owner. Writes on that router (feedback, open) are session-only.
- `GET /experiments`, `/experiments/:key`, `/experiments/:key/results` with `experiments:read` (or an empty scope list). These belong to TPN's internal experimentation platform and are not agency-facing.
- Everything public (section 1), unauthenticated or not.

Not reachable with a key: routes guarded by `requirePermission` / `requirePropertyOwnership` (listing create/update/delete, organization and blog management). Those handlers read the signed-in session user, which API-key requests do not populate, so `property:*`, `organization:*` and `blog:*` scopes are accepted when minting a key but do not currently open those routes (they answer 401). Platform-admin routes explicitly reject keys (403). If this changes, the OpenAPI document and https://thaipropertiesnetwork.com/auth.md are the places that will say so.

## Rate limits

Token bucket per key: 300 requests/minute on general routes, 600/minute on cheap read routes (keys flagged `elevated` by TPN get 1000 and 2000). Space out bulk reads.

## 4. Hand work to a human in the TPN web app

Deep links (production):

- Map search of listings: https://app.thaipropertiesnetwork.com/search/map
- Create a free account: https://app.thaipropertiesnetwork.com/sign-up
- Rental contract generator: https://app.thaipropertiesnetwork.com/rental-contract
- Co-agent agreement generator: https://app.thaipropertiesnetwork.com/co-agent-agreement
- Lead marketplace: https://app.thaipropertiesnetwork.com/lead-marketplace

Localized marketing pages have markdown twins: `https://thaipropertiesnetwork.com/<th|en|zh>/<path>.md` (see https://thaipropertiesnetwork.com/llms.txt).
