# Spell Versions endpoints (Admin API)

> 10 FeatherPanel Admin API endpoints from admin/spell-versions.php: methods, paths, auth, permissions, rate limits, parameters and responses.

Source: https://featherpanel.com/docs/api/reference/admin/spell-versions/

Defined in [`backend/app/routes/admin/spell-versions.php`](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/routes/admin/spell-versions.php). Authentication used here: **Admin**. Read [Authentication](https://featherpanel.com/docs/api/authentication/) for how to send credentials and [Rate limits and errors](https://featherpanel.com/docs/api/rate-limits-and-errors/) for the response envelope.

Paths, methods, permissions and rate limits come from the route file. Summaries, parameters and response codes come from the OpenAPI annotations on the controllers; endpoints without annotations show only what the route file declares.

## Endpoints

### GET `/api/admin/spells/{id}/versions`

- Auth: Admin
- Permission: `admin.spells.view`
- Route name: `admin-spell-versions`
- Controller: [`SpellVersionsController::index`](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/Controllers/Admin/SpellVersionsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/routes/admin/spell-versions.php#L26)

**Spell version state and revision history**

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | integer | yes |  |

```bash
curl -X GET "$PANEL_URL/api/admin/spells/$ID/versions" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

Responses: `200` Version state and revisions · `404` Spell not found

### POST `/api/admin/spells/{id}/versions/check`

- Auth: Admin
- Permission: `admin.spells.edit`
- Route name: `admin-spell-versions-check`
- Controller: [`SpellVersionsController::check`](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/Controllers/Admin/SpellVersionsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/routes/admin/spell-versions.php#L41)

**Check FeatherCloud or the update URL for a newer version**

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | integer | yes |  |

```bash
curl -X POST "$PANEL_URL/api/admin/spells/$ID/versions/check" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

Responses: `200` Version state

### GET `/api/admin/spells/{id}/versions/update/preview`

- Auth: Admin
- Permission: `admin.spells.edit`
- Route name: `admin-spell-versions-update-preview`
- Controller: [`SpellVersionsController::previewUpdate`](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/Controllers/Admin/SpellVersionsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/routes/admin/spell-versions.php#L56)

**Preview the update: changed fields, variables and the effect on every server**

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | integer | yes |  |

```bash
curl -X GET "$PANEL_URL/api/admin/spells/$ID/versions/update/preview" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

Responses: `200` Update preview

### POST `/api/admin/spells/{id}/versions/update`

- Auth: Admin
- Permission: `admin.spells.edit`
- Route name: `admin-spell-versions-update`
- Controller: [`SpellVersionsController::applyUpdate`](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/Controllers/Admin/SpellVersionsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/routes/admin/spell-versions.php#L71)

**Apply the previewed update**

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | integer | yes |  |

| Body field | Type | Required | Description |
| --- | --- | --- | --- |
| `hash` | string | no | Hash returned by the preview |
| `removed_variables` | string | no |  |
| `notify_servers` | boolean | no |  |
| `changelog` | string | no |  |

```bash
curl -X POST "$PANEL_URL/api/admin/spells/$ID/versions/update" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"hash":"","removed_variables":"","notify_servers":false,"changelog":""}'
```

Responses: `200` Updated · `409` Pinned, or a newer version appeared since the preview

### PATCH `/api/admin/spells/{id}/versions/settings`

- Auth: Admin
- Permission: `admin.spells.edit`
- Route name: `admin-spell-versions-settings`
- Controller: [`SpellVersionsController::settings`](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/Controllers/Admin/SpellVersionsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/routes/admin/spell-versions.php#L86)

**Pin a spell to its version or link it to a FeatherCloud egg**

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | integer | yes |  |

| Body field | Type | Required | Description |
| --- | --- | --- | --- |
| `pinned` | boolean | no |  |
| `upstream_identifier` | string | no | FeatherCloud egg id, null to unlink |

```bash
curl -X PATCH "$PANEL_URL/api/admin/spells/$ID/versions/settings" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"pinned":false,"upstream_identifier":""}'
```

Responses: `200` Saved

### GET `/api/admin/spells/{id}/versions/{revision}`

- Auth: Admin
- Permission: `admin.spells.view`
- Route name: `admin-spell-versions-show`
- Controller: [`SpellVersionsController::show`](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/Controllers/Admin/SpellVersionsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/routes/admin/spell-versions.php#L101)

**One spell revision with its changes**

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | integer | yes |  |
| `revision` | path | integer | yes |  |

```bash
curl -X GET "$PANEL_URL/api/admin/spells/$ID/versions/$REVISION" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

Responses: `200` Revision · `404` Not found

### GET `/api/admin/spells/{id}/versions/{revision}/rollback/preview`

- Auth: Admin
- Permission: `admin.spells.edit`
- Route name: `admin-spell-versions-rollback-preview`
- Controller: [`SpellVersionsController::previewRollback`](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/Controllers/Admin/SpellVersionsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/routes/admin/spell-versions.php#L117)

**Preview a rollback to an older revision**

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | integer | yes |  |
| `revision` | path | integer | yes |  |

```bash
curl -X GET "$PANEL_URL/api/admin/spells/$ID/versions/$REVISION/rollback/preview" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

Responses: `200` Rollback preview

### POST `/api/admin/spells/{id}/versions/{revision}/rollback`

- Auth: Admin
- Permission: `admin.spells.edit`
- Route name: `admin-spell-versions-rollback`
- Controller: [`SpellVersionsController::rollback`](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/Controllers/Admin/SpellVersionsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/routes/admin/spell-versions.php#L133)

**Roll the spell back to an older revision**

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | integer | yes |  |
| `revision` | path | integer | yes |  |

| Body field | Type | Required | Description |
| --- | --- | --- | --- |
| `removed_variables` | string | no |  |
| `notify_servers` | boolean | no |  |

```bash
curl -X POST "$PANEL_URL/api/admin/spells/$ID/versions/$REVISION/rollback" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"removed_variables":"","notify_servers":false}'
```

Responses: `200` Rolled back

### GET `/api/admin/spell-versions/status`

- Auth: Admin
- Permission: `admin.spells.view`
- Route name: `admin-spell-versions-status`
- Controller: [`SpellVersionsController::statusAll`](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/Controllers/Admin/SpellVersionsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/routes/admin/spell-versions.php#L149)

**Last known update state of every spell**

```bash
curl -X GET "$PANEL_URL/api/admin/spell-versions/status" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

Responses: `200` Update states keyed by spell id

### POST `/api/admin/spell-versions/check`

- Auth: Admin
- Permission: `admin.spells.edit`
- Route name: `admin-spell-versions-check-all`
- Controller: [`SpellVersionsController::checkAll`](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/Controllers/Admin/SpellVersionsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/8318da2dee6f7facc161af39e305be7d97407929/backend/app/routes/admin/spell-versions.php#L158)

**Check every spell that has an update source (oldest check first)**

```bash
curl -X POST "$PANEL_URL/api/admin/spell-versions/check" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

Responses: `200` Results per spell
