# Tenancy Takeovers

A tenancy takeover lets a tenant who wants to leave hand their booking, and the liability that comes with it, to a
replacement tenant. The tenant does not cancel or terminate their booking and hope the unit is let again. Instead, a
takeover is raised on the booking, the unit is offered to a replacement from a set date, and the original booking is
released only once a replacement booking has committed. Until then, the original tenant stays liable.

Tenancy takeovers are a per-workspace opt-in. Until they are enabled for a workspace, every booking in it is refused
as not eligible (`BOOKING_NOT_ELIGIBLE`), and the takeover fields on its bookings return empty.

All the operations on this page are under the `bookings` namespace of the GraphQL API.

## Key Concepts

### The flow at a glance

1. A takeover is raised on a confirmed booking with `requestTenancyTakeover`. It starts as `REQUESTED`.
2. Optionally, the tenant who will take over is nominated with `setTenancyTakeoverReplacement`. A nominated tenant
   pays the original booking's rate.
3. A replacement booking is created with `bookings.create` and a `TENANCY_TAKEOVER` relationship to the original. The
   takeover moves to `PENDING`.
4. When the replacement's cooling-off period ends, or the replacement checks in, the takeover moves to `COMPLETED`
   and the original booking is canceled or terminated by the system.

A takeover with no replacement linked can be withdrawn at any time with `withdrawTenancyTakeover`.

### Lifecycle

```mermaid
stateDiagram-v2
    [*] --> REQUESTED: requestTenancyTakeover
    REQUESTED --> PENDING: replacement booking created
    PENDING --> REQUESTED: replacement falls through
    PENDING --> COMPLETED: replacement commits
    REQUESTED --> WITHDRAWN: withdrawTenancyTakeover
    COMPLETED --> [*]
    WITHDRAWN --> [*]
```

| Status | Meaning |
| ------ | ------- |
| `REQUESTED` | Open and waiting for a replacement booking. The unit can be offered to a replacement from `availableFrom` to `mustEndOn`. It can be withdrawn |
| `PENDING` | A replacement booking is linked and has not committed yet. Only one replacement can be linked at a time, and the takeover can no longer be withdrawn |
| `COMPLETED` | The replacement committed and the original booking was canceled or terminated |
| `WITHDRAWN` | Closed while no replacement booking was linked. The original booking is unchanged |

`REQUESTED` and `PENDING` are the open statuses. A booking has at most one open takeover at a time, but it can have
several takeovers over its life: for example, one that was withdrawn and a later one.

A replacement **falls through** when it expires as a tentative booking, is declined, or is canceled inside its
cooling-off period. The takeover then goes back to `REQUESTED` and the unit can be offered again. If the replacement's
lead guest was the nominated replacement tenant, that nomination is removed, so the next replacement is not priced
on it.

### Eligibility

A booking can have a takeover raised on it when **all** of the following hold:

- Tenancy takeovers are enabled for its workspace
- The booking is a product booking (it has a product)
- The booking status is `confirmed`
- The booking has not ended
- The booking is past its own cooling-off period
- The booking has no open takeover, and no pending cancelation or termination request

A booking that fails one of the first five checks is refused with `BOOKING_NOT_ELIGIBLE`. An open takeover or a
pending request is refused with `REQUEST_ALREADY_PENDING`.

### Dates

The takeover records the dates a replacement booking must fit, captured when the takeover is requested:

- `availableFrom`: the date the replacement starts. For a tenancy that has not started, this is the original booking's
  check-in, so the replacement takes the whole booking. For a tenancy that has started, it is the `leaveDate` sent
  with the request.
- `mustEndOn`: the original booking's check-out. The replacement must end on it.

A `leaveDate` is required once the tenancy has started. It must be on or after the booking's check-in and before its
check-out, so at least one night is left for a replacement. Before the tenancy starts, any `leaveDate` is ignored.

### Reasons

Every takeover records why the tenant is leaving, as a `TenancyTakeoverReason` in `reasonCode`. The reasons match
those for canceling or terminating the booking, because a completed takeover ends it in the same way: before
check-in a cancelation reason applies, and from check-in a termination reason.

To show only the reasons a booking accepts now, read `tenancyTakeoverReasons` on the booking. A reason that does not
apply to the booking at the time of the request is refused with `INVALID_REASON`.

| Reason | Value | Before check-in | From check-in |
| ------ | ----- | --------------- | ------------- |
| Absconder | `ABSCONDER` | No | Yes |
| Academic | `ACADEMIC` | Yes | Yes |
| Campus change | `CAMPUS_CHANGE` | Yes | Yes |
| Compassionate | `COMPASSIONATE` | Yes | Yes |
| Complaint | `COMPLAINT` | Yes | Yes |
| Eviction | `EVICTION` | No | Yes |
| Financial | `FINANCIAL` | Yes | Yes |
| Housekeeping issue | `HOUSEKEEPING_ISSUE` | No | Yes |
| Incident | `INCIDENT` | No | Yes |
| Location | `LOCATION` | Yes | Yes |
| Maintenance issue | `MAINTENANCE_ISSUE` | No | Yes |
| Medical | `MEDICAL` | Yes | Yes |
| No place | `NO_PLACE` | Yes | No |
| No show | `NO_SHOW` | Yes | Yes |
| No visa | `NO_VISA` | Yes | No |
| Noise issue | `NOISE_ISSUE` | No | Yes |
| Other | `OTHER` | Yes | Yes |
| Processing error | `PROCESSING_ERROR` | Yes | Yes |
| Property sold | `PROPERTY_SOLD` | Yes | Yes |
| Property transfer | `PROPERTY_TRANSFER` | Yes | Yes |
| Social | `SOCIAL` | No | Yes |
| Wellbeing | `WELLBEING` | No | Yes |

Anything more about why the tenant is leaving goes in the optional `note`, up to 2,000 characters.

> **Note:** The free-text `reason` field, on the request input and on `TenancyTakeover`, is deprecated. Send and read
> `reasonCode` instead. Supply either `reasonCode` or `reason` on a request, not both. A takeover raised with free
> text reads back with `reasonCode: OTHER`.

### Rates and pricing

When a takeover is requested, two rates are captured on it:

- `originalRate`: the original booking's contracted accommodation rate. Null when the booking has no rate history.
- `liveRate`: the product's live rate for the takeover window. Null when no single live rate covers it.

You do not send a rate when you create the replacement booking. If the replacement's lead guest is the nominated
replacement tenant (their email matches, ignoring case), the replacement is charged the `originalRate`. Otherwise,
including when nobody was nominated, it is charged the `liveRate`. If no live rate was captured, the stay is priced
live when the replacement is booked.

### Releasing the original booking

The original booking is released when the replacement **commits**: when its cooling-off period ends or when it checks
in, whichever comes first. A replacement with no cooling-off period commits as soon as it is confirmed. At that point:

- the takeover moves to `COMPLETED`;
- if the replacement starts on the original's check-in (the tenancy had not started), the original booking is
  **canceled**;
- otherwise the original booking is **terminated**, with its check-out moved to the replacement's check-in. The
  original tenant's last night is the night before the replacement arrives.

The system makes this change, with the takeover's reason recorded as the booking's cancelation or termination reason.
The cancelation or termination runs as it would if made by hand, so the usual curtailment, credits, refunds and
`v1.booking.canceled` or `v1.booking.terminated` webhook events follow. On a terminated original, `terminatedAt` and
`terminationReason` are set on the `Booking` once the termination applies.

### Interaction with cancelation and termination requests

A takeover cannot be raised while the booking has a pending
[cancelation request](/bookings/cancelation-requests/) or [termination request](/bookings/termination-requests/):
the request is refused with `REQUEST_ALREADY_PENDING`. Resolve the pending request first.

## GraphQL API

### Types

#### `TenancyTakeover`

| Field | Type | Description |
| ----- | ---- | ----------- |
| `id` | `ID!` | The ID of the takeover |
| `status` | `TenancyTakeoverStatus!` | Where the takeover is in its lifecycle: `REQUESTED`, `PENDING`, `COMPLETED` or `WITHDRAWN` |
| `reasonCode` | `TenancyTakeoverReason!` | Why the tenant is leaving. See [Reasons](#reasons) |
| `note` | `String` | Anything more about why the tenant is leaving. Null when none was recorded, or when the caller cannot view the original booking |
| `reason` | `String!` | Deprecated. Read `reasonCode` instead |
| `availableFrom` | `ISO8601Date!` | The date a replacement booking starts on |
| `mustEndOn` | `ISO8601Date!` | The date a replacement booking must end on: the original booking's check-out |
| `originalRate` | `TenancyTakeoverRate` | The original booking's contracted accommodation rate when the takeover was requested. Null when the booking has no rate history |
| `liveRate` | `TenancyTakeoverRate` | The product's live rate when the takeover was requested. Null when no single live rate covers the takeover window |
| `requestedVia` | `TenancyTakeoverRequestedVia!` | Where the takeover was requested: `API`, `MCP` or `PMS` |
| `requestedAt` | `ISO8601DateTime!` | When the takeover was requested |
| `withdrawnAt` | `ISO8601DateTime` | When the takeover was withdrawn. Null unless the status is `WITHDRAWN` |
| `withdrawalReason` | `String` | Why the takeover was withdrawn, if a reason was given |
| `booking` | `BookingResponse!` | The original booking being taken over |
| `replacementLead` | `Lead` | The CRM lead holding the nominated replacement tenant. Null until one is set, and again once it is removed |

`TenancyTakeoverRate` has two fields: `rate` (`Money!`, with `amountCents`, `amount` and `currency`) and `interval`
(`RateInterval!`: `NIGHTLY`, `WEEKLY` or `MONTHLY`).

#### Fields on `Booking`

| Field | Type | Description |
| ----- | ---- | ----------- |
| `tenancyTakeovers` | `[TenancyTakeover!]` | Every takeover this booking is part of, newest first: those raised on it as the original, in any status, and, on a replacement booking, the takeover it replaces. A takeover whose `booking` is this booking was raised on it; otherwise this booking replaces it. Empty when there are none, or when takeovers are not enabled for the workspace |
| `tenancyTakeoverReasons` | `[TenancyTakeoverReason!]` | The reasons a takeover on this booking accepts today |
| `tenancyTakeover` | `TenancyTakeover` | Deprecated. The booking's open takeover as the original, otherwise its most recent one. Use `tenancyTakeovers` |
| `terminatedAt` | `ISO8601DateTime` | When the booking was terminated. Null until a termination applies |
| `terminationReason` | `String` | Why the booking was terminated, in lowercase (for example `financial`). Null until a termination applies |

### Reading a takeover

Read one takeover by its ID with `bookings.tenancyTakeover`.

```graphql
query TenancyTakeover($id: ID!) {
  bookings {
    tenancyTakeover(id: $id) {
      id
      status
      reasonCode
      note
      availableFrom
      mustEndOn
      originalRate {
        rate { amountCents amount currency }
        interval
      }
      liveRate {
        rate { amountCents amount currency }
        interval
      }
      requestedVia
      requestedAt
      withdrawnAt
      withdrawalReason
      booking { id }
      replacementLead { id }
    }
  }
}
```

```json
{
  "id": "tenancy-takeover-id"
}
```

### Listing a workspace's takeovers

`bookings.tenancyTakeovers` lists a workspace's takeovers, newest request first. It follows the standard
[pagination pattern](/concepts/api-paradigms/connections/), so the connection exposes `nodes`, `edges`,
`pageInfo` and `totalCount`.

```graphql
query TenancyTakeovers($workspaceId: ID!, $filters: TenancyTakeoversFiltersInput, $first: Int, $after: String) {
  bookings {
    tenancyTakeovers(workspaceId: $workspaceId, filters: $filters, first: $first, after: $after) {
      totalCount
      pageInfo {
        hasNextPage
        endCursor
      }
      nodes {
        id
        status
        availableFrom
        mustEndOn
        requestedAt
        booking { id }
      }
    }
  }
}
```

```json
{
  "workspaceId": "workspace-id",
  "filters": {
    "statuses": ["REQUESTED"]
  },
  "first": 25
}
```

All filters are optional and combine with AND:

| Filter | Type | Description |
| ------ | ---- | ----------- |
| `statuses` | `[TenancyTakeoverStatus!]` | Only takeovers in one of these statuses. For example, `[REQUESTED]` lists every unit open to a replacement. An empty list does not filter |
| `unitId` | `ID` | Only takeovers whose original booking is in this unit |
| `bookingId` | `ID` | Only takeovers of this original booking |
| `requestedFrom` | `ISO8601Date` | Only takeovers requested on or after this date, counted as a UK (Europe/London) day |

### Reading the takeovers on a booking

Read `tenancyTakeovers` on a booking to see the takeovers it is part of, and `tenancyTakeoverReasons` for the reasons
a new takeover on it would accept.

```graphql
query BookingTenancyTakeovers($bookingId: ID!) {
  bookings {
    booking(bookingId: $bookingId) {
      id
      tenancyTakeoverReasons
      tenancyTakeovers {
        id
        status
        availableFrom
        mustEndOn
        booking { id }
      }
    }
  }
}
```

```json
{
  "bookingId": "booking-id"
}
```

### Requesting a takeover

`bookings.requestTenancyTakeover` raises a takeover on a booking. It starts as `REQUESTED`.

```graphql
mutation RequestTenancyTakeover($input: RequestTenancyTakeoverMutationInput!) {
  bookings {
    requestTenancyTakeover(input: $input) {
      tenancyTakeover {
        id
        status
        reasonCode
        availableFrom
        mustEndOn
        booking { id }
      }
    }
  }
}
```

A tenancy that has started, with a leave date:

```json
{
  "input": {
    "requestTenancyTakeover": {
      "bookingId": "booking-id",
      "reasonCode": "FINANCIAL",
      "note": "Moving back home at the end of term",
      "leaveDate": "2027-01-10"
    }
  }
}
```

A tenancy that has not started, with the replacement tenant already known:

```json
{
  "input": {
    "requestTenancyTakeover": {
      "bookingId": "booking-id",
      "reasonCode": "ACADEMIC",
      "replacementTenant": {
        "firstName": "Alex",
        "lastName": "Smith",
        "email": "alex.smith@example.com",
        "phone": "+44 7911 123456"
      }
    }
  }
}
```

**Input fields** (inside `requestTenancyTakeover`):

| Field | Type | Description |
| ----- | ---- | ----------- |
| `bookingId` | `ID!` | The booking to be taken over |
| `reasonCode` | `TenancyTakeoverReason` | Why the tenant is leaving. Use a value from the booking's `tenancyTakeoverReasons` |
| `note` | `String` | Anything more about why the tenant is leaving, up to 2,000 characters |
| `leaveDate` | `ISO8601Date` | The date the tenant wants to leave. Required once the tenancy has started, on or after its check-in and before its check-out. Ignored before then |
| `replacementTenant` | `TenancyTakeoverReplacementTenantInput` | Who will take over, if already known. See [Nominating the replacement tenant](#nominating-the-replacement-tenant). If the tenant cannot be recorded, no takeover is created |
| `reason` | `String` | Deprecated. Send `reasonCode` instead |

**Error codes:**

| Code | When |
| ---- | ---- |
| `VALIDATION_ERROR` | The input is missing a required field or breaks a length or format rule |
| `BOOKING_NOT_FOUND` | No booking matches `bookingId` |
| `UNAUTHORIZED` | The caller may not request a takeover on the booking, or, with `replacementTenant`, may not create leads in the workspace's CRM |
| `BOOKING_NOT_ELIGIBLE` | The booking fails one of the [eligibility](#eligibility) checks |
| `INVALID_REASON` | The reason does not apply to the booking now: a termination-only reason before check-in, or a cancelation-only reason from check-in |
| `INVALID_LEAVE_DATE` | The tenancy has started and `leaveDate` is missing or outside the booking's dates |
| `REQUEST_ALREADY_PENDING` | The booking already has an open takeover, or a pending cancelation or termination request |
| `PENDING_REQUEST_CHECK_FAILED` | The check for other open requests could not be completed. Retry |
| `BOOKING_HAS_NO_UNIT_TYPE` | The replacement tenant cannot be recorded as a lead because the booking has no unit type |
| `REPLACEMENT_LEAD_NOT_CREATED` | The CRM refused the replacement tenant. No takeover is created |

### Nominating the replacement tenant

The replacement tenant is the person the original tenant has found to take over. Who they are decides the
replacement booking's rate (see [Rates and pricing](#rates-and-pricing)), so nominate them before the replacement
booking is made: when requesting the takeover (`replacementTenant`), or later with
`bookings.setTenancyTakeoverReplacement`.

The tenant is recorded as a lead in the workspace's CRM, and the takeover's `replacementLead` points at it. If their
email matches an existing contact in the workspace's CRM, that contact is reused: it keeps its stored name, and the
phone number, if given, is added to it. Setting a different tenant points the takeover at a new lead; the previous
lead stays in the CRM. `replacementLead` is the CRM's `Lead`, so its fields can be read in the same query. See
[Leads](/crm/leads/).

Setting or removing the replacement tenant works only while the takeover is `REQUESTED` and no replacement booking is
linked. The caller needs permission to request a takeover on the booking and to create leads in the CRM.

```graphql
mutation SetTenancyTakeoverReplacement($input: SetTenancyTakeoverReplacementMutationInput!) {
  bookings {
    setTenancyTakeoverReplacement(input: $input) {
      tenancyTakeover {
        id
        status
        replacementLead {
          id
          contacts {
            nodes { primaryEmail }
          }
        }
      }
    }
  }
}
```

```json
{
  "input": {
    "setTenancyTakeoverReplacement": {
      "tenancyTakeoverId": "tenancy-takeover-id",
      "replacementTenant": {
        "firstName": "Alex",
        "lastName": "Smith",
        "email": "alex.smith@example.com",
        "phone": "+44 7911 123456"
      }
    }
  }
}
```

**Input fields** (inside `setTenancyTakeoverReplacement`):

| Field | Type | Description |
| ----- | ---- | ----------- |
| `tenancyTakeoverId` | `ID!` | The takeover to set the replacement tenant on |
| `replacementTenant` | `TenancyTakeoverReplacementTenantInput!` | Who will take over the booking |

**`TenancyTakeoverReplacementTenantInput`:**

| Field | Type | Description |
| ----- | ---- | ----------- |
| `firstName` | `String!` | Up to 255 characters |
| `lastName` | `String!` | Up to 255 characters |
| `email` | `String!` | The tenant's email. Matched, ignoring case, against the replacement booking's lead guest to choose the rate |
| `phone` | `String` | In international format, for example `+44 7911 123456` |

To remove the nominated tenant, use `bookings.clearTenancyTakeoverReplacement`. The CRM lead is kept unchanged. It
succeeds without change when no tenant is set.

```graphql
mutation ClearTenancyTakeoverReplacement($input: ClearTenancyTakeoverReplacementMutationInput!) {
  bookings {
    clearTenancyTakeoverReplacement(input: $input) {
      tenancyTakeover {
        id
        status
        replacementLead { id }
      }
    }
  }
}
```

```json
{
  "input": {
    "clearTenancyTakeoverReplacement": {
      "tenancyTakeoverId": "tenancy-takeover-id"
    }
  }
}
```

**Error codes** (set and clear):

| Code | When |
| ---- | ---- |
| `VALIDATION_ERROR` | The input is missing a required field or breaks a length or format rule |
| `TENANCY_TAKEOVER_NOT_FOUND` | No takeover matches `tenancyTakeoverId` |
| `BOOKING_NOT_FOUND` | The takeover's booking no longer exists |
| `UNAUTHORIZED` | The caller may not request a takeover on the booking, or may not create leads in the workspace's CRM |
| `TAKEOVER_NOT_OPEN` | The takeover is completed or withdrawn, or its booking can no longer be taken over |
| `REPLACEMENT_IN_PROGRESS` | A replacement booking is linked, so the replacement tenant can no longer change |
| `BOOKING_HAS_NO_UNIT_TYPE` | Set only. The tenant cannot be recorded as a lead because the booking has no unit type |
| `REPLACEMENT_LEAD_NOT_CREATED` | Set only. The CRM refused the replacement tenant |

### Withdrawing a takeover

`bookings.withdrawTenancyTakeover` closes a takeover the tenant no longer wants. It works only while the takeover is
`REQUESTED`. Once a replacement booking is linked it is refused. The takeover moves to `WITHDRAWN` and the original
booking is unchanged, so a new takeover, cancelation request or termination request can be raised on it.

```graphql
mutation WithdrawTenancyTakeover($input: WithdrawTenancyTakeoverMutationInput!) {
  bookings {
    withdrawTenancyTakeover(input: $input) {
      tenancyTakeover {
        id
        status
        withdrawnAt
        withdrawalReason
      }
    }
  }
}
```

```json
{
  "input": {
    "withdrawTenancyTakeover": {
      "tenancyTakeoverId": "tenancy-takeover-id",
      "reason": "The tenant has decided to stay"
    }
  }
}
```

**Input fields** (inside `withdrawTenancyTakeover`):

| Field | Type | Description |
| ----- | ---- | ----------- |
| `tenancyTakeoverId` | `ID!` | The takeover to withdraw |
| `reason` | `String` | Why it is being withdrawn, up to 2,000 characters |

**Error codes:**

| Code | When |
| ---- | ---- |
| `VALIDATION_ERROR` | The input is missing a required field or breaks a length rule |
| `TENANCY_TAKEOVER_NOT_FOUND` | No takeover matches `tenancyTakeoverId` |
| `BOOKING_NOT_FOUND` | The takeover's booking no longer exists |
| `UNAUTHORIZED` | The caller may not withdraw the takeover |
| `REPLACEMENT_IN_PROGRESS` | A replacement booking is linked, so the takeover can no longer be withdrawn |
| `TAKEOVER_NOT_OPEN` | The takeover is already completed or withdrawn |

### Creating the replacement booking

A replacement is an ordinary booking made with `bookings.create`, plus one `relationships` entry naming the original
booking. It is the only booking allowed to overlap the original booking's nights. See
[Creating a booking](/bookings/bookings/#creating-a-booking) for the rest of the input.

```graphql
mutation CreateReplacementBooking($input: CreateBookingMutationInput!) {
  bookings {
    create(input: $input) {
      booking {
        id
      }
    }
  }
}
```

```json
{
  "input": {
    "booking": {
      "productId": "product-id",
      "checkIn": "2027-01-10",
      "checkOut": "2027-06-30",
      "contacts": [
        {
          "role": "LEAD_GUEST",
          "type": "PROVIDED",
          "providedContact": {
            "firstName": "Alex",
            "lastName": "Smith",
            "email": "alex.smith@example.com"
          }
        }
      ],
      "relationships": [
        {
          "bookingId": "original-booking-id",
          "type": "RELATES_TO",
          "reason": "TENANCY_TAKEOVER"
        }
      ]
    }
  }
}
```

**`BookingRelationshipInput`:**

| Field | Type | Description |
| ----- | ---- | ----------- |
| `bookingId` | `ID!` | The original booking, the one being taken over |
| `type` | `BookingRelationshipType!` | `RELATES_TO` |
| `reason` | `BookingRelationshipReason!` | `TENANCY_TAKEOVER` |

The replacement is accepted only when:

- the original booking has a `REQUESTED` takeover with no replacement linked;
- it books the original booking's product (`productId`);
- it is on the original booking's unit. If `unitId` is left out, the original's unit is used;
- its check-in is the takeover's `availableFrom` and its check-out is the takeover's `mustEndOn`, exactly;
- its lead guest is not the original booking's current tenant;
- it has exactly one relationship.

The usual booking checks still apply, including availability. For student products, check-in must fall within the
product's contract start dates and the product must be inside its publishing window, so a mid-term start can be
refused on some products.

You do not send a rate: the replacement is priced as described in [Rates and pricing](#rates-and-pricing). Once the
replacement is created, the takeover moves to `PENDING`, and the replacement's `tenancyTakeovers` lists the takeover
it replaces.

**Error codes** (in addition to the usual `bookings.create` errors):

| Code | When |
| ---- | ---- |
| `USER_NOT_ALLOWED_ERROR` | The original booking does not exist, or is in a workspace the caller cannot book in |
| `TAKEOVER_NOT_OPEN` | The original booking has no open takeover waiting for a replacement |
| `REPLACEMENT_IN_PROGRESS` | The takeover already has a replacement booking |
| `BOOKING_NOT_ELIGIBLE` | The original booking can no longer be replaced: it is not confirmed or has ended |
| `PRODUCT_MISMATCH` | The replacement books a different product |
| `UNIT_MISMATCH` | The replacement names a different unit |
| `DATES_OUTSIDE_TAKEOVER` | The check-in is not `availableFrom`, or the check-out is not `mustEndOn` |
| `GUEST_IS_CURRENT_TENANT` | The lead guest is the original booking's current tenant |
| `TAKEOVER_RATE_INTERVAL_MISMATCH` | The captured rate's interval no longer matches the product's, so it cannot be charged |
| `UNSUPPORTED_RELATIONSHIP_TYPE` | More than one relationship was sent, or a relationship reason other than `TENANCY_TAKEOVER` |
| `CURRENT_TENANT_LOOKUP_FAILED` | The original booking's current tenant could not be checked. Retry |
| `REPLACEMENT_TENANT_LOOKUP_FAILED` | The nominated replacement tenant could not be read. Retry |

### Errors

Errors come back in the GraphQL `errors` array, with a stable code in `extensions.code`. Codes ending in `_FAILED`
are temporary: retry the call. `UNEXPECTED_ERROR` means something failed on our side: retry, and contact us with the
time of the request if it persists.

The read queries return these codes:

| Code | Returned by | When |
| ---- | ----------- | ---- |
| `VALIDATION_ERROR` | Both | The arguments are malformed |
| `UNAUTHORIZED` | Both | The caller may not view the takeover, or list the workspace's takeovers |
| `TENANCY_TAKEOVER_NOT_FOUND` | `tenancyTakeover` | No takeover matches `id` |
| `WORKSPACE_NOT_FOUND` | `tenancyTakeovers` | No workspace matches `workspaceId` |
| `TENANCY_TAKEOVER_LOOKUP_FAILED` | Both | Loading takeovers failed. Retry |

## Webhooks

Each status change sends one webhook event, named `v1.booking.tenancy_takeover.<status>`:

| Event type | When it fires |
| ---------- | ------------- |
| `v1.booking.tenancy_takeover.requested` | A takeover is requested, or goes back to `REQUESTED` because its replacement fell through |
| `v1.booking.tenancy_takeover.pending` | A replacement booking is linked to the takeover |
| `v1.booking.tenancy_takeover.withdrawn` | A takeover is withdrawn |
| `v1.booking.tenancy_takeover.completed` | The replacement commits. The original booking's `v1.booking.canceled` or `v1.booking.terminated` event follows |

Payloads carry IDs only. Read the takeover with `bookings.tenancyTakeover(id:)` for its details.

> **Warning:** A takeover can send `requested` more than once, because it goes back to `REQUESTED` when a
> replacement falls through, and webhook events can arrive out of order. Key on `tenancy_takeover.id` and act on the
> status you read from the API, not on the event name or the order events arrive in.

`requested` and `withdrawn`:

```json
{
  "type": "v1.booking.tenancy_takeover.requested",
  "id": "booking_363c6cdf-7920-4752-9606-9ea48bb538b7",
  "timestamp": "2026-11-24T10:00:00.000Z",
  "tenancy_takeover": { "id": "tenancy-takeover-id" },
  "booking": { "id": "booking-id" },
  "workspace": { "id": "workspace-id" }
}
```

`pending` and `completed` also carry the replacement booking:

```json
{
  "type": "v1.booking.tenancy_takeover.pending",
  "id": "booking_8f1d2e3a-5b6c-4d7e-8f90-a1b2c3d4e5f6",
  "timestamp": "2026-11-25T09:30:00.000Z",
  "tenancy_takeover": { "id": "tenancy-takeover-id" },
  "booking": { "id": "booking-id" },
  "replacement_booking": { "id": "replacement-booking-id" },
  "workspace": { "id": "workspace-id" }
}
```

| Field | Type | Description |
| ----- | ---- | ----------- |
| `type` | `string` | The event type |
| `id` | `string` | The unique identifier of the event |
| `timestamp` | `string` (ISO 8601) | When the event occurred |
| `tenancy_takeover.id` | `string` | The takeover |
| `booking.id` | `string` | The original booking the takeover is for |
| `replacement_booking.id` | `string` | `pending` and `completed` only. The replacement booking |
| `workspace.id` | `string` | The workspace the booking belongs to |

While a takeover is open, the unit's availability changes too: the
`v1.availability.unit_availability.updated` event shows the original booking as a `TENANCY_TAKEOVER` span and the unit
as `AVAILABLE` from `availableFrom`. See [Availability](/availability/availability/).

See [Webhooks](/concepts/webhooks/) for the general webhook delivery model and signature
verification.

## Relationships

- A takeover belongs to exactly one original **booking** and its **workspace**. A booking can have many takeovers
  over time, but at most one open (`REQUESTED` or `PENDING`)
- A takeover has at most one linked **replacement booking** at a time, on the same product and unit as the original
- The nominated replacement tenant is a **lead** in the workspace's CRM (see [Leads](/crm/leads/))
- A completed takeover ends the original booking as a cancelation or a termination (see
  [Bookings](/bookings/bookings/))
