# PropertyOS public API — TypeScript SDK

A typed client for PropertyOS's read-only public API (`X-Api-Key` auth, `/api/v1/public-api/v1/*`).
Not published to npm — copy `client.ts` and `types.ts` into your project, or import them directly
as ES modules (`generated-openapi-types.ts` is the raw request-parameter types generated from the
OpenAPI doc; most consumers only need `client.ts`/`types.ts`).

## Usage

```ts
import { createPropertyOSPublicApiClient } from './client';

const client = createPropertyOSPublicApiClient({
  baseUrl: 'https://app.propertyos.example',
  apiKey: 'YOUR_API_KEY', // Settings -> API Keys in the PropertyOS app
});

const page = await client.listProperties();
const property = await client.getProperty(page.items[0].id);
const tenancies = await client.listTenancies();
```

## Regenerating

Run `npm run generate` from `tools/generate-public-sdk/` after the public API's OpenAPI doc
(`src/PropertyOS.WebApi/OpenApi/PropertyOS.WebApi_public-v1.json`) changes. That only refreshes
`generated-openapi-types.ts` (path/query param types) — `types.ts`'s response shapes are
hand-written to mirror `PropertyOS.Contracts.ApiKeys` and must be updated by hand if those DTOs
change, since the endpoints don't declare response schemas in the OpenAPI doc.

This SDK is also served as a static download from the `/developers` page in the app
(`src/PropertyOS.Client/wwwroot/sdk/`) — the generate script keeps that copy in sync.
