---
title: "Replace the whole portfolio"
method: PUT
path: "/api/v1/portfolio"
tags: ["Portfolio"]
---

# Replace the whole portfolio

`PUT /api/v1/portfolio`

## Request

- Base URL: `http://localhost:5180`
- URL: `http://localhost:5180/api/v1/portfolio`
- Auth: API key in cookie `better-auth.session_token`

Clears the signed-in owner’s rows and writes the body in their place, in one transaction. This is here for the worked example, putting it away, resetting it or loading it into a team that holds nothing yet, and nothing else: a normal edit is POST /portfolio/changes. Only an owner of the team may call it, and a portfolio that holds the owner’s own records is never replaced. Every collection has to be named, and one you send empty is emptied: a replace is a replace, but an omission is a mistake and is refused rather than acted on. The body names the schema it was built against for the same reason. Every row is written at `rev` 1, whatever revision it arrived carrying, so the next GET /portfolio hands back rows a client can edit from.

## Request body

- object
  - `bankAccounts` object, required
  - `bankFeeds` object, required
  - `statementImports` object, required
  - `buildings` object, required
  - `units` object, required
  - `meters` object, required
  - `meterReadings` object, required
  - `keySets` object, required
  - `inventoryItems` object, required
  - `contacts` object, required
  - `contractors` object, required
  - `leases` object, required
  - `leaseTemplates` object, required
  - `leaseClauses` object, required
  - `deposits` object, required
  - `inspections` object, required
  - `applications` object, required
  - `viewings` object, required
  - `listings` object, required
  - `invoices` object, required
  - `payments` object, required
  - `bankTransactions` object, required
  - `reconciliationMatches` object, required
  - `arrearsCases` object, required
  - `paymentPlans` object, required
  - `expenses` object, required
  - `supplierInvoices` object, required
  - `mortgages` object, required
  - `serviceChargePeriods` object, required
  - `budgets` object, required
  - `issues` object, required
  - `workOrders` object, required
  - `quotes` object, required
  - `maintenancePlans` object, required
  - `certificates` object, required
  - `mailboxes` object, required
  - `mailAliases` object, required
  - `threads` object, required
  - `messages` object, required
  - `calls` object, required
  - `templates` object, required
  - `workflows` object, required
  - `workflowRuns` object, required
  - `approvalRequests` object, required
  - `auditEvents` object, required
  - `tasks` object, required
  - `notifications` object, required
  - `channelConnections` object, required
  - `bookings` object, required
  - `cleaningTasks` object, required
  - `pricingRules` object, required
  - `reviews` object, required
  - `documents` object, required
  - `documentFolders` object, required
  - `equipment` object, required
  - `insurancePolicies` object, required
  - `reports` object, required
  - `savedViews` object, required
  - `customSections` object, required
  - `jurisdictions` object, required
  - `jurisdictionOverrides` object, required
  - `schemaVersion` integer, required: The schema the client was built against, as GET /portfolio reports it (currently 10). Required, and any other value is refused: a collection this build does not know about is one a replace would empty.
  - `settings` object, required: The whole settings block, in the AppSettings shape GET /settings documents. A field the spec does not list yet is kept.
  - `team` object, required
    - `id` string, required: Stable record id, e.g. `lse_012`.
    - `name` string, required
    - `legalForm` 'individual' | 'company' | 'partnership' | 'trust', required: The legal owning entity that holds title: a personal name, an SPV, an SCI, a BV.
    - `taxId` string
    - `registrationNumber` string
    - `contactEmail` string
    - `address` object, required
      - `line1` string, required
      - `line2` string
      - `postcode` string, required: Empty where the country has no postcodes, as in the United Arab Emirates. Left out of a change, it is written empty.
      - `city` string, required
      - `region` string
      - `country` string, required
      - `countryCode` string, required: ISO 3166-1 alpha-2. It decides which jurisdiction pack applies.
      - `lat` number
      - `lng` number
    - `shares` object[], required: Who owns the entity and in what proportion.
      - `userId` string, required: Stable record id, e.g. `lse_012`.
      - `bps` number, required: Share in basis points. 10000 is 100%.
    - `vatRegistered` boolean, required
    - `createdAt` string, required: ISO 8601 timestamp.
    - `updatedAt` string, required: ISO 8601 timestamp.

## Response `200`

The portfolio was replaced.

- object
  - `ok` unknown, required
  - `data` object, required
    - `records` integer, required: How many records were written across every collection.
  - `meta` object, required
    - `requestId` string, required: Echoed in the x-request-id header. Quote it in a bug report.

## Other responses

- `400`: The body is not a portfolio, a row in it is missing a field its collection requires, the body is larger than the request limit, or the schemaVersion is not the current one (then the message is "This page is running an older version of Dardaris. Reload it to keep saving." and details carry the current schemaVersion). Nothing is written in any of those cases.
- `403`: You are on this team but not as an owner. Nothing is written.
- `409`: The portfolio is not the worked example and already holds the owner’s own records (details.reason is `own_records`), or a bank still holds access to this team, so nothing is replaced until it is disconnected. Where the body drops a bank account still connected to its bank, details.reason is `bank_linked` and details.bankAccountIds names it.
- `429`: Writing faster than the limit allows.

---

[API](https://skmtc.dev/dardaris/apis/dardaris-api.md) · [All operations](https://skmtc.dev/dardaris/apis/dardaris-api/llms.txt) · [OpenAPI document](https://skmtc.dev/dardaris/apis/dardaris-api/revisions/4aff33835c73?raw)
