---
title: "Acquire the edit lease"
method: POST
path: "/websiteSourceCode/lease/acquire"
tags: ["Source code"]
---

# Acquire the edit lease

`POST /websiteSourceCode/lease/acquire`

## Request

- Base URL: `https://api.cactal.ai/v1`
- URL: `https://api.cactal.ai/v1/websiteSourceCode/lease/acquire`
- Auth: HTTP bearer

Acquires and replaces the website's single edit lease, taking over from any other editor. Writes that pass the returned principal-bound `leaseToken` keep working until someone else takes the lease; writes without a token take the lease automatically unless another editor is still working: the Cactal agent while it runs, or another caller that wrote in the last 5 minutes.

## Request body

- object
  - `websiteId` string, required

## Response `200`

The new lease token and current head version.

- object
  - `leaseToken` string, required: Token to send with every source mutation. Valid until another lease is acquired for this website.
  - `headVersion` integer, required: Draft source version at acquisition.

## Other responses

- `400`: Validation failed. The response `message` names the first invalid field.
- `401`: Missing, invalid, expired, or revoked API key.
- `403`: The authenticated principal lacks the required capability.
- `404`: The resource does not exist or is outside the principal’s access scope.
- `429`: Rate limit exceeded. Retry after the number of seconds in the `Retry-After` header.

---

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