API Key (Bearer Token)
Include your API key in theAuthorization header:
BOROUGH-<uuid> and are provisioned automatically when you subscribe to a plan.
OAuth 2.1 (PKCE)
Borough implements OAuth 2.1 with PKCE for secure delegated access. This is the recommended method for MCP clients and third-party apps.Endpoints
| Endpoint | Method | Description |
|---|---|---|
/oauth/register | POST | Dynamic client registration (RFC 7591) |
/oauth/authorize | GET | Consent page (redirects user) |
/oauth/authorize | POST | Submit API key, receive auth code |
/oauth/token | POST | Exchange code for tokens |
/.well-known/oauth-authorization-server | GET | Server metadata (RFC 8414) |
/.well-known/oauth-protected-resource | GET | Resource metadata (RFC 9728) |
Flow
-
Register your client (optional for localhost apps):
Unregistered clients may only use
localhostredirect URIs. -
Redirect user to authorize:
The user enters their Borough API key (or continues with Free tier) and is redirected back with an authorization code.
-
Exchange code for tokens:
-
Use the access token:
Token lifetimes
| Token | Lifetime |
|---|---|
| Access token | 1 hour |
| Refresh token | 30 days |
| Auth code | 5 minutes |
| Client registration | 30 days |
Free-tier access
Search endpoints (/v1/search/rentals, /v1/search/sales), areas (/v1/areas), and market endpoints work without authentication. Unauthenticated requests are subject to:
- 10 requests/minute rate limit (IP-based)
- 100 requests/month quota
- Maximum 10 results per page
Error responses
| Code | Status | Description |
|---|---|---|
MISSING_API_KEY | 401 | No Authorization header provided on a protected endpoint |
INVALID_API_KEY | 401 | Key doesn’t match any active subscription |
EXPIRED_API_KEY | 401 | Subscription has ended |
TIER_RESTRICTED | 403 | Endpoint requires a higher tier |
WWW-Authenticate header includes a link to the protected-resource metadata for automatic OAuth discovery.
Security best practices
- Store keys in environment variables, never in client-side code
- Rotate keys by creating a new subscription if compromised
- Use the minimum tier needed for your use case
- For OAuth, always use PKCE with S256 code challenges
- Register your client to restrict allowed redirect URIs