> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prophia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data model

> How accounts, properties, buildings, spaces, leases, documents, and tags fit together

Everything in the Prophia API is scoped to an **account**, and underneath the account run two parallel spines:

* the **physical spine** — Property → Building → BuildingSpace — describes real estate you own or manage
* the **contractual spine** — Lease → LeaseDoc → DocTag — describes the agreements occupying it

The two spines meet at the **building**: every lease belongs to a building (and through it, a property).

```mermaid theme={null}
flowchart TB
    Account["<b>Account</b><br/>id · accountName"]
    Property["<b>Property</b><br/>id · propertyName"]
    Building["<b>Building</b><br/>id · buildingName<br/>onboardingStatus · activeStatus"]
    Lease["<b>Lease</b><br/>id · dba · leaseStatus<br/>suiteNumber <i>(list of spaces)</i>"]
    LeaseDoc["<b>LeaseDoc</b><br/>id · filename · documentStatus"]
    DocTag["<b>DocTag</b><br/>id · tagName · category<br/>applicableSpaces"]
    BuildingSpace["<b>BuildingSpace</b><br/>id · suiteNumber · floor · archived"]
    Sublease["<b>Sublease</b><br/><i>a Lease with a parent</i>"]

    Account -->|"has many"| Property
    Property -->|"has many"| Building
    Building -->|"houses"| Lease
    Lease -->|"documented by"| LeaseDoc
    LeaseDoc -->|"tagged with"| DocTag

    Building -.->|"is divided into"| BuildingSpace
    Lease -.->|"parent of"| Sublease
    BuildingSpace -. "suiteNumber is matched against<br/>DocTag.applicableSpaces<br/><b>by name, not by id</b>" .-> DocTag
```

The solid path down the middle is the id-linked spine: every resource carries the ids of its ancestors (`accountId`, `propertyId`, `buildingId`, `leaseId`, `leaseDocId`), so you can walk it in either direction. The dashed links are the two side relationships — spaces hanging off the building, and subleases hanging off a lease — plus the one association that is a *name match* rather than a foreign key.

## The entities

| Entity | What it is | Where to get it |
| - | - | - |
| **Account** | Your tenancy in Prophia — the scope for every other resource and every API key | [`GET /rest/v2/accounts`](https://docs.prophia.com/api-reference/v2/accounts/list-account) |
| **Property** | A named holding within an account; groups one or more buildings | [`GET .../properties`](https://docs.prophia.com/api-reference/v2/properties/list-property) |
| **Building** | A physical structure with an address; leases and spaces attach here | [`GET .../buildings`](https://docs.prophia.com/api-reference/v2/buildings/list-building) |
| **BuildingSpace** | A suite, floor, or other discrete unit inside a building | [`GET .../buildings/{buildingId}/spaces`](https://docs.prophia.com/api-reference/v2/building-spaces/list-building-space) |
| **Lease** | An agreement between a landlord and a tenant for space in a building; subleases are full leases with a `parent` | [`GET .../leases/{leaseId}`](https://docs.prophia.com/api-reference/v2/leases/get-lease) |
| **LeaseDoc** | A document — original lease, amendment, exhibit, rent roll — attached to a lease. Documents can also be filed at the **property** or **building** level rather than against a lease; those are reached through [`include=documents`](https://docs.prophia.com/api-reference/v2/concepts/includes) on a property or building | [`GET .../leases/{leaseId}/docs`](https://docs.prophia.com/api-reference/v2/leases/list-document) |
| **DocTag** | One extracted lease term — a value cited to a location in a document | [`GET .../leases/{leaseId}/tags`](https://docs.prophia.com/api-reference/v2/leases/list-tag) |

Most resources also embed a `url` that deep-links into the Prophia web app.

## The soft link: tags to spaces

> [!WARNING]
>
> A tag's `applicableSpaces[].name` refers to a `BuildingSpace` **by suite name, not by id**. There is no foreign key: match `applicableSpaces[].name` against `BuildingSpace.suiteNumber` **within the same `buildingId`**. Renaming a suite silently breaks the association, and the sentinel names `"Entire building"` and `"All spaces"` never correspond to a real space record.

This is the one relationship in the diagram that is a name match rather than an id reference — the dashed line on the right. See [Spaces, applicable spaces, and encumbrances](https://docs.prophia.com/api-reference/v2/concepts/spaces-and-encumbrances.md) for the matching rules and a worked recipe.

## Absent means "not requested"

One convention is worth stating once, because it applies to every response: **the API omits `null` fields entirely.** A field populated by an [include](https://docs.prophia.com/api-reference/v2/concepts/includes.md) you didn't request is simply missing from the JSON.

Branch on *presence*, not on emptiness — a missing `tags` key means "not requested", never "no tags". An empty array means you asked and there were none.

Everything else — which fields exist, what type each one is, what its values mean — is documented per field on the endpoint pages, and those are authoritative.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.