# Preservation API

Source: https://frameleaf.app/docs/api/reference/preservation/

Use your own server and its scoped API keys.

## Remove a preservation package

DELETE /api/preservation/packages/{id}

Deletes the package’s own copy on this server. Your library’s originals are never touched, and a package named on the server by an administrator is only forgotten.

```json
{
  "description": "Deletes the package’s own copy on this server. Your library’s originals are never touched, and a package named on the server by an administrator is only forgotten.",
  "operationId": "removePreservationPackage",
  "parameters": [
    {
      "name": "id",
      "required": true,
      "in": "path",
      "schema": {
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$",
        "type": "string"
      }
    }
  ],
  "responses": {
    "204": {
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "Remove a preservation package",
  "tags": [
    "Preservation"
  ],
  "x-frameleaf-permission": "asset.download"
}
```

## Download a preservation package

GET /api/preservation/packages/{id}/download

The package this server wrote, as one ZIP. A package holding Locked items needs an unlocked session. Verify the downloaded copy before relying on it.

```json
{
  "description": "The package this server wrote, as one ZIP. A package holding Locked items needs an unlocked session. Verify the downloaded copy before relying on it.",
  "operationId": "downloadPreservationPackage",
  "parameters": [
    {
      "name": "id",
      "required": true,
      "in": "path",
      "schema": {
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$",
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "content": {
        "application/octet-stream": {
          "schema": {
            "format": "binary",
            "type": "string"
          }
        }
      },
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "Download a preservation package",
  "tags": [
    "Preservation"
  ],
  "x-frameleaf-permission": "asset.download"
}
```

## Get a preservation package item report

GET /api/preservation/packages/{id}/items

Each item of the package with its state, last verification and checksum. Locked items are counted but not named until the session is unlocked.

```json
{
  "description": "Each item of the package with its state, last verification and checksum. Locked items are counted but not named until the session is unlocked.",
  "operationId": "getPreservationPackageItems",
  "parameters": [
    {
      "name": "id",
      "required": true,
      "in": "path",
      "schema": {
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$",
        "type": "string"
      }
    },
    {
      "name": "skip",
      "required": false,
      "in": "query",
      "schema": {
        "minimum": 0,
        "maximum": 9007199254740991,
        "type": "integer"
      }
    },
    {
      "name": "state",
      "required": false,
      "in": "query",
      "schema": {
        "$ref": "#/components/schemas/PreservationItemState"
      }
    },
    {
      "name": "take",
      "required": false,
      "in": "query",
      "schema": {
        "minimum": 1,
        "maximum": 200,
        "type": "integer"
      }
    },
    {
      "name": "verifyState",
      "required": false,
      "in": "query",
      "schema": {
        "$ref": "#/components/schemas/PreservationVerifyState"
      }
    }
  ],
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/PreservationItemsResponseDto"
          }
        }
      },
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "Get a preservation package item report",
  "tags": [
    "Preservation"
  ],
  "x-frameleaf-permission": "asset.download"
}
```

## Download a preservation manifest

GET /api/preservation/packages/{id}/manifest

The manifest of a package this server wrote.

```json
{
  "description": "The manifest of a package this server wrote.",
  "operationId": "downloadPreservationManifest",
  "parameters": [
    {
      "name": "id",
      "required": true,
      "in": "path",
      "schema": {
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$",
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "content": {
        "application/octet-stream": {
          "schema": {
            "format": "binary",
            "type": "string"
          }
        }
      },
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "Download a preservation manifest",
  "tags": [
    "Preservation"
  ],
  "x-frameleaf-permission": "asset.download"
}
```

## Preview a preservation export

POST /api/preservation/preview

How many of your items a selection holds, how large they are, whether they fit in one package and what a restoration brings back. Writes nothing.

```json
{
  "description": "How many of your items a selection holds, how large they are, whether they fit in one package and what a restoration brings back. Writes nothing.",
  "operationId": "previewPreservationExport",
  "parameters": [],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/PreservationPreviewDto"
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/PreservationPreviewResponseDto"
          }
        }
      },
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "Preview a preservation export",
  "tags": [
    "Preservation"
  ],
  "x-frameleaf-permission": "asset.download"
}
```

## Get restoration items

GET /api/preservation/restores/{id}/items

What the review found for each item — new, already in your library, or in the trash — the fields that disagree, your choices and what the restore left for you to look at.

```json
{
  "description": "What the review found for each item — new, already in your library, or in the trash — the fields that disagree, your choices and what the restore left for you to look at.",
  "operationId": "getPreservationRestoreItems",
  "parameters": [
    {
      "name": "filter",
      "required": false,
      "in": "query",
      "schema": {
        "$ref": "#/components/schemas/PreservationRestoreItemFilter"
      }
    },
    {
      "name": "id",
      "required": true,
      "in": "path",
      "schema": {
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$",
        "type": "string"
      }
    },
    {
      "name": "skip",
      "required": false,
      "in": "query",
      "schema": {
        "minimum": 0,
        "maximum": 9007199254740991,
        "type": "integer"
      }
    },
    {
      "name": "take",
      "required": false,
      "in": "query",
      "schema": {
        "minimum": 1,
        "maximum": 200,
        "type": "integer"
      }
    }
  ],
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/PreservationRestoreItemsResponseDto"
          }
        }
      },
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "Get restoration items",
  "tags": [
    "Preservation"
  ],
  "x-frameleaf-permission": "asset.upload"
}
```
