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

# Context & Locations

> Company/org config, property listings, location search, and nearby schools.

Provides company/organization configuration, property listings, and related data. Most endpoints are public (no auth required) and are used to configure the landing page and application forms for a specific organization or property.

## Data Shapes

<AccordionGroup>
  <Accordion title="Company/Context Object">
    Returned by `/context/{contextId}` and embedded in Application objects.

    ```json theme={null}
    {
      "id": "org_abc123",
      "companyId": "org_abc123",

      "companyInfo": {
        "requireBankConnect": false,
        "disableApplicantGuarantors": false,
        "disableBankScreening": false,
        "requireEmergencyContact": true,
        "applicationLock": "onClose",
        "enableSection8": false,
        "enableRegionalScreeningFilters": false,
        "collectPayment": true,
        "taxDocumentCount": 2,
        "bankStatementCount": 3,
        "payStubCount": 2,
        "toggleChatWindow": false
      },

      "applicationConfig": {
        "availableDate": "2026-04-01",
        "marketRent": "$1,500",
        "marketRentValue": 150000,
        "marketingTitle": "Beautiful 2BR near downtown",
        "applicationRequirements": "<p>Min credit score 620...</p>",
        "incomeToRent": 3,
        "coverPhoto": ["https://cdn.example.com/photos/cover.jpg"],
        "marketingImages": ["https://cdn.example.com/photos/img1.jpg"],
        "agent": {
          "name": "Sarah Agent",
          "email": "sarah@example.com",
          "phone": "+15551112222",
          "photo": "https://cdn.example.com/agents/sarah.jpg"
        }
      }
    }
    ```

    **`companyInfo` fields**

    | Field                            | Type    | Description                                                                    |
    | -------------------------------- | ------- | ------------------------------------------------------------------------------ |
    | `requireBankConnect`             | boolean | Require VeriFast bank connect for income verification                          |
    | `disableApplicantGuarantors`     | boolean | Prevent applicants from adding guarantors themselves                           |
    | `disableBankScreening`           | boolean | Disable bank account screening entirely                                        |
    | `requireEmergencyContact`        | boolean | Make emergency contact required                                                |
    | `applicationLock`                | string  | When app locks from editing. `"onClose"` = locks when applicant closes browser |
    | `enableSection8`                 | boolean | Enable Section 8 / housing voucher flow                                        |
    | `enableRegionalScreeningFilters` | boolean | Enable state-specific screening rule exceptions                                |
    | `collectPayment`                 | boolean | Require application fee payment                                                |
    | `taxDocumentCount`               | number  | How many tax documents to require                                              |
    | `bankStatementCount`             | number  | How many bank statements to require                                            |
    | `payStubCount`                   | number  | How many pay stubs to require                                                  |

    **`applicationConfig` fields**

    | Field                     | Type      | Description                                                  |
    | ------------------------- | --------- | ------------------------------------------------------------ |
    | `marketRentValue`         | number    | Monthly rent in **cents** (e.g., `150000` = \$1,500)         |
    | `marketRent`              | string    | Pre-formatted display string (e.g., `"$1,500"`)              |
    | `incomeToRent`            | number    | Income multiplier required (e.g., `3` = must earn 3× rent)   |
    | `applicationRequirements` | string    | HTML string for displaying requirements                      |
    | `petRestrictions`         | string    | HTML string for pet policy                                   |
    | `leaseTerms`              | string    | HTML string for lease terms                                  |
    | `coverPhoto`              | string\[] | Array of cover photo URLs                                    |
    | `marketingImages`         | string\[] | Array of gallery photo URLs                                  |
    | `regionalExceptions`      | string\[] | Features disabled for regulatory reasons in specific regions |
  </Accordion>

  <Accordion title="Location / Listing Object">
    ```json theme={null}
    {
      "_id": "loc_xyz789",
      "name": "The Residences at Oak Creek - Unit 204",
      "companyId": "org_abc123",
      "address": {
        "formattedAddress": "123 Oak St Unit 204, Austin TX 78701",
        "state": "TX",
        "countryName": "United States"
      },
      "bedCount": 2,
      "bathCount": 1,
      "squareFeet": 950,
      "marketRent": "$1,500",
      "marketRentValue": 150000,
      "rentMin": 140000,
      "rentMax": 160000,
      "videoUrl": "https://www.youtube.com/watch?v=example",
      "virtualTourUrl": "https://my.matterport.com/show/?m=example",
      "applicationConfig": { "...": "See above" },
      "companyInfo": { "...": "See above" }
    }
    ```
  </Accordion>

  <Accordion title="School Object">
    ```json theme={null}
    {
      "_id": "sch_001",
      "name": "Austin Elementary School",
      "type": "Elementary",
      "rating": 8,
      "distance": 0.4,
      "address": "456 School Rd, Austin TX 78702",
      "url": "https://www.greatschools.org/..."
    }
    ```
  </Accordion>
</AccordionGroup>

***

## GET `/context/{contextId}`

Load configuration for a property location. Used on landing/listing pages to configure the UI for a specific property.

**Auth required:** No

<ParamField path="contextId" type="string" required>
  Location ID (same as `locationId` in applications).
</ParamField>

<ParamField query="audience" type="string">
  Filter config for audience: `"applicant"`, `"approver"`, or `"showing"`.
</ParamField>

<ParamField query="bp" type="boolean">
  Pass `true` to show property information regardless of publish status. Useful for displaying data for offline or unpublished locations for historical purposes.
</ParamField>

**Response:** Location/Context Object merged with Location/Listing Object.

Called on the application landing page to load property details, branding, and feature flags before displaying the application form.

***

## GET `/company/{contextId}`

Load organization-level configuration (the company overall, not a specific property).

**Auth required:** No

<ParamField path="contextId" type="string" required>
  Organization/company ID.
</ParamField>

<ParamField query="locationContextId" type="string">
  If provided, also load config for this specific location.
</ParamField>

<ParamField query="bp" type="boolean">
  Bypass publish status filter.
</ParamField>

**Response:** Company config object scoped to the organization.

***

## GET `/locations/{orgId}`

List all active property locations for an organization.

**Auth required:** Optional (token enhances results for authenticated users)

<ParamField path="orgId" type="string" required>
  Organization ID.
</ParamField>

**Query params (optional):** Arbitrary key-value filters.

| Param       | Description                             |
| ----------- | --------------------------------------- |
| `available` | `"true"` to return only available units |
| `bedCount`  | Filter by number of bedrooms            |
| `search`    | Text search on location name/address    |

**Response:** Array of Location objects.

***

## GET `/listings/{orgId}/{segmentId}`

List public property listings, optionally filtered by a segment (e.g., a specific building or community).

**Auth required:** No

<ParamField path="orgId" type="string" required>
  Organization ID.
</ParamField>

<ParamField path="segmentId" type="string">
  Optional sub-segment/portfolio ID.
</ParamField>

**Query params:** Same filter params as `/locations/{orgId}`.

**Response:** Array of Listing objects. Powers the public property search portal.

***

## GET `/listing/{locationId}`

Get full details for a single public listing.

**Auth required:** No

<ParamField path="locationId" type="string" required>
  Property location ID.
</ParamField>

**Response:** Single Location/Listing Object with full `applicationConfig`.

Called on the individual listing detail page before a user starts an application.

***

## GET `/schools/{locationId}`

Get nearby schools for a property (powered by GreatSchools API).

**Auth required:** No

<ParamField path="locationId" type="string" required>
  Property location ID.
</ParamField>

<ParamField query="distance" type="number">
  Search radius in miles. Default: `25`.
</ParamField>

<ParamField query="limit" type="number">
  Maximum number of schools to return. Default: `10`.
</ParamField>

**Response**

```json theme={null}
[
  {
    "_id": "sch_001",
    "name": "Austin Elementary School",
    "type": "Elementary",
    "rating": 8,
    "distance": 0.4,
    "address": "456 School Rd, Austin TX 78702",
    "url": "https://www.greatschools.org/..."
  }
]
```

Displayed on the listing detail page as neighborhood information.
