---
search:
  tags:
    - Tenants
    - POST
seo:
  description: >-
    Makes a new luna that starts from another luna's data, as it is now or as
    it… Reference for the POST /_luna/tenants/{tenant}/fork endpoint in the Luna
    API.
sidebar:
  label: Fork a luna
  badge: POST
title: Fork a luna
type: openapi-operation
---
Makes a new luna that starts from another luna's data, as it is now or as it was at an earlier moment. The new luna has its own key, in the same tenant or in another one. Reading the source needs `data:read` on its tenant, and writing the copy needs `data:write` on the tenant it goes to.

`POST /_luna/tenants/{tenant}/fork`

**Request body** (`application/json`, required)

- `type` (string, required) — The luna type.
- `key` (object, required) — The key of the luna to fork, such as \`{"id": "a"}\`.
- `toKey` (object, required) — The key of the new luna.
- `at` (integer<int64> | null) — The moment to fork the luna as of, in milliseconds since the Unix epoch. Now when left out.
- `toTenant` (string | null) — The tenant the new luna goes to, by its full name. The same tenant when left out.
- `schedules` (boolean) — Whether the new luna keeps the schedules its source has.

Request body example:

```json
{
  "type": "string",
  "key": {},
  "toKey": {},
  "at": 0,
  "toTenant": "string",
  "schedules": true
}
```

**Responses**

- `200` — The luna is forked.
- `default` — The request failed. The status says how and \`error.message\` says why.

Response example, 200:

```json
{
  "sandboxes": 0,
  "sandboxError": "string"
}
```
