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

# Portal buyer data

> Read and update the signed-in buyer, favorites, and reservation links.

Every operation on this page requires a [Portal buyer token](https://viewerdocs.planpoint.io/api-documentation/portal/overview.md#base-url-and-credentials). The session determines the buyer; do not send another buyer's ID.

## Get current buyer

`GET /api/portal/user`

No query or body fields are required.

```json Response (200) theme={null}
{
  "message": "User info retrieved",
  "user": {
    "_id": "000000000000000000000003",
    "email": "buyer@example.com",
    "data": { "firstName": "Example", "lastName": "Buyer" },
    "favoriteUnits": ["000000000000000000000002"],
    "reservations": []
  }
}
```

`favoriteUnits` and `reservations` contain IDs, not populated documents. Password and reset-token fields are excluded. A missing buyer returns `404`; invalid sessions return `401`.

## Delete current buyer

`DELETE /api/portal/user`

No body is required. Deletes the buyer in the session's project or group.

```json Response (200) theme={null}
{ "message": "User deleted successfully" }
```

A missing buyer returns `404`. Clear the application's local session after deletion.

> [!WARNING]
>
> This is not a refund, reservation cancellation, or complete financial-data erasure operation. It deletes the Portal account, not the separate payment and reservation records.

## Update profile

`PUT /api/portal/profile`

Optional `email` must be a valid email address. Send other profile fields at the top level: they are sanitized and merged into the existing `data` object.

```json Request theme={null}
{
  "email": "updated-buyer@example.com",
  "firstName": "Updated"
}
```

```json Response (200) theme={null}
{
  "_id": "000000000000000000000003",
  "email": "updated-buyer@example.com",
  "data": { "firstName": "Updated", "lastName": "Buyer" },
  "favoriteUnits": ["000000000000000000000002"],
  "reservations": []
}
```

Unlike GET user, the response is the buyer object **without** a `user` wrapper. Email is normalized to lowercase. A collision with another buyer in the same scope returns `409` with `"That email is already in use."` Invalid input returns `400`; a missing buyer returns `404`. Updating a profile is not a password change or email-verification flow.

## List favorites

`GET /api/portal/favorite-unit`

For project sessions, optional query `projectId` defaults to the token's project. Group sessions return that group buyer's complete favorites list rather than filtering it by project.

```json Response (200) theme={null}
{ "favoriteUnits": ["000000000000000000000002"] }
```

## Update favorites

`POST /api/portal/favorite-unit`

| JSON field | Required | Description |
| - | - | - |
| `unitId` | Yes | Inventory ID to add or remove. |
| `action` | Yes | `add` or `remove`. |
| `projectId` | Project sessions | Must match the token's project. Not required for group sessions. |

```json Request theme={null}
{
  "projectId": "000000000000000000000001",
  "unitId": "000000000000000000000002",
  "action": "add"
}
```

```json Response (200) theme={null}
{
  "message": "Favorite units updated successfully",
  "favoriteUnits": ["000000000000000000000002"]
}
```

Adding an existing favorite does not duplicate it. Missing fields or an invalid action return `400`; a project mismatch returns `403`; a missing buyer returns `404`. Favorites do not put inventory on hold.

## List reservations

`GET /api/portal/reservations`

No request fields are required. Returns reservations linked to and owned by the current buyer, with `unit` populated when its referenced record is available.

```json Response (200, no reservations) theme={null}
{ "reservations": [] }
```

Reservation records include `_id`, `project`, `unit`, `unitModel`, `portalUserId`, `reservationDate`, and `status`. Depending on the payment, they can also contain `reference`, `customerName`, `customerEmail`, `paymentAmount`, `paymentCurrency`, `paymentProvider`, `notes`, `buyNow`, and `buyNowFee`.

`status` is `succeeded`, `pending`, or `cancelled`. `unitModel` is `Unit` or `CommercialSpace`; `paymentProvider` can be `stripe` or `paystack`. Treat an unresolved `unit` as nullable and payment fields as optional. These statuses are separate from inventory availability.

## Update reservation links

`POST /api/portal/reservations`

All three fields are required, including `projectId` for group sessions.

```json Request theme={null}
{
  "projectId": "000000000000000000000001",
  "reservationId": "000000000000000000000004",
  "action": "add"
}
```

```json Response (200) theme={null}
{
  "message": "Reservations updated successfully",
  "reservations": ["000000000000000000000004"]
}
```

`action` must be `add` or `remove`. Adding requires an existing reservation owned by this buyer and belonging to the supplied project. A missing, other-buyer, or wrong-project reservation returns the same `404` `"Reservation not found"` response. Project sessions also require a matching token project (`403` on mismatch). Invalid input returns `400`.

The POST response contains reservation **IDs**, whereas GET returns populated reservation records. Removing a link only removes it from the buyer's list; it does not cancel the reservation, release inventory, or refund a charge.


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