# Store a backup's file index

`POST /api/v1/backup-runs/{backupRun}/manifest`

Adds file and folder entries to the file list of a backup this run stored, up to 10000 per request, and answers 201 with the whole list. 422 when the backup is not this run's, or when its file list is kept as a manifest file, which takes no entries.

## Path Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| backupRun | integer | yes | The ID of the backup run. Example: `1873`. |

## Body Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| artifact_id | integer | yes | The backup the entries belong to; it must come from this run. Example: `2291`. |
| entries | object[] | yes | The files and folders of the backup, up to 10000 per request. Each entry has `path` (required), `parent_path`, `is_directory`, `size_bytes`, `mtime`, `change_type` (`added`, `modified`, `deleted`, `touched` or `copied`), `copied_from` (required for `copied`), `owner`, `group`, `uid`, `gid`, `mode` (an integer, for example 420 for 0644) and `checksum`. Example: `[{"path":"httpdocs/wp-config.php","parent_path":"httpdocs","is_directory":false,"size_bytes":3412,"mtime":1795122930,"change_type":"added","owner":"example","group":"example","uid":10001,"gid":1001,"mode":420,"checksum":"3b7e1c9a5d2f48e6a0c1b93d7f5e2a84c6d0b1f9e3a7524c8d6b0e1f9a3c5d72","copied_from":null}]`. |
| entries.path | string | yes |  |
| entries.parent_path | string | no | Nullable. |
| entries.is_directory | boolean | no |  |
| entries.size_bytes | integer | no | Nullable. |
| entries.mtime | integer | no | Nullable. |
| entries.change_type | string | no | Nullable. One of: `added`, `modified`, `deleted`, `touched`, `copied`, `null`. |
| entries.copied_from | string | no | Nullable. |
| entries.owner | string | no | Nullable. |
| entries.group | string | no | Nullable. |
| entries.uid | integer | no | Nullable. |
| entries.gid | integer | no | Nullable. |
| entries.mode | integer | no | Nullable. |
| entries.checksum | string | no | Nullable. |

## Response

### 201

The entries are stored; the answer lists the backup's whole file index.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes |  |
| artifact_id | integer | yes |  |
| entries_count | integer | yes | How many entries the backup's file list now holds. |
| entries | object[] | yes |  |
| entries.path | string | yes | The entry's path inside the backup. |
| entries.parent_path | string | yes | The folder that holds the entry. Nullable. |
| entries.is_directory | boolean | yes |  |
| entries.size_bytes | integer | yes | The file's size in bytes. |
| entries.mtime | integer | yes | When the file was last modified, as a Unix timestamp in seconds. Nullable. |
| entries.change_type | string | yes | What the backup recorded for the entry: `added`, `modified` or `deleted` since the earlier backup, `touched` (same content, new modification time) or `copied` (same content as another path of the earlier backup). Null when the backup does not say. Nullable. One of: `added`, `modified`, `deleted`, `touched`, `copied`, `null`. |
| entries.owner | string | yes | The file's owner on the server, when the agent recorded it. Nullable. |
| entries.group | string | yes | The file's group on the server, when the agent recorded it. Nullable. |
| entries.uid | integer | yes | Nullable. |
| entries.gid | integer | yes | Nullable. |
| entries.mode | string | yes | The file's permissions as four octal digits. Nullable. |

### 401

The request carries no valid token: the `Authorization: Bearer` header is missing, or its token is unknown, revoked or past its expiry date. Send a current personal access token.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | Always `Unauthenticated.`. |

### 403

The token may not do this. The `message` says why: `This token lacks the required ability.` (a `read` token), `Your role does not permit this action.` (its owner is not an Admin or Operator in the client), `This account is disabled.`, `This token is not bound to a client you belong to.`, or `Client suspended`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

### 404

Not found

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

### 422

The body or the query is invalid. `message` names the first problem and `errors` lists every problem by field. A backup this run did not store, or one whose file index is kept as a manifest file, is refused with a `message` only.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | The first problem, and how many more there are. |
| errors | object | yes | Every problem, by field. |

### 429

More than 120 requests a minute for this user. Wait the seconds in `Retry-After`, then retry.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

## Request example

```bash
curl -X POST 'https://app.clokeep.com/api/v1/backup-runs/1873/manifest' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
    "artifact_id": 2291,
    "entries": [
      {
        "path": "httpdocs/wp-config.php",
        "parent_path": "httpdocs",
        "is_directory": false,
        "size_bytes": 3412,
        "mtime": 1795122930,
        "change_type": "added",
        "owner": "example",
        "group": "example",
        "uid": 10001,
        "gid": 1001,
        "mode": 420,
        "checksum": "3b7e1c9a5d2f48e6a0c1b93d7f5e2a84c6d0b1f9e3a7524c8d6b0e1f9a3c5d72",
        "copied_from": null
      }
    ]
  }'
```

## Response example (201)

```json
{
  "message": "Manifest stored successfully.",
  "artifact_id": 2291,
  "entries_count": 18432,
  "entries": [
    {
      "path": "httpdocs/wp-config.php",
      "parent_path": "httpdocs",
      "is_directory": false,
      "size_bytes": 3412,
      "mtime": 1795122930,
      "change_type": "added",
      "owner": "example",
      "group": "example",
      "uid": 10001,
      "gid": 1001,
      "mode": "0644"
    }
  ]
}
```

## Response example (401)

```json
{
  "message": "Unauthenticated."
}
```

## Response example (403)

```json
{
  "message": "This token lacks the required ability."
}
```

## Response example (404)

```json
{
  "message": "No query results for model [App\\Models\\BackupRun] 1873"
}
```

## Response example (422)

```json
{
  "message": "The artifact id field is required.",
  "errors": {
    "artifact_id": [
      "The artifact id field is required."
    ]
  }
}
```

## Response example (429)

```json
{
  "message": "Too Many Attempts."
}
```
