# Identity: import

> Review an export zip sent as base64url in JSON (up to 6,000,000 bytes): validated whole and its contacts shown, nothing written; the import names the digest this answers; Review an export zip sent as the raw body (application/zip, up to the host's import ceiling): the same review as the JSON door; A

## Review an export zip sent as base64url in JSON (up to 6,000,000 bytes): validated whole and its contacts shown, nothing written; the import names the digest this answers

`POST /v1/identities/{slug}/import/review` · operation `reviewImportArchive`

Requires the `batondeck:identities:manage` permission (action `identity:import`).

Requires a step-up: MFA enrolled and re-authenticated within 15 minutes. **Not reachable with an API key** — a key has no session and so can never step up.

Refused while the workspace is suspended or on deletion hold.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `slug` | path | string | yes |  |

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

| Field | Type | Required | Notes |
|---|---|---|---|
| `archive` | string | yes | ≥ 1 chars |

<details>
<summary>Request schema</summary>

```json
{
  "type": "object",
  "properties": {
    "archive": {
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "archive"
  ],
  "additionalProperties": false
}
```

</details>

**Responses**

| Status | Meaning |
|---|---|
| 200 | Review an export zip sent as base64url in JSON (up to 6,000,000 bytes): validated whole and its contacts shown, nothing written; the import names the digest this answers |
| 400 | The arguments did not validate. |
| 401 | No portal session, and no live API key. |
| 403 | The policy refused, or the request was cross-site. |
| 404 | No such resource, or none this session may see. |

<details>
<summary>200 response schema</summary>

```json
{
  "type": "object",
  "properties": {
    "digest": {
      "type": "string"
    },
    "root_fingerprint": {
      "type": "string"
    },
    "contacts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "root": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "endpoint": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "leaf": {
            "type": "boolean"
          },
          "action": {
            "type": "string",
            "enum": [
              "add",
              "pin",
              "keep",
              "skip"
            ]
          },
          "conflicts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string"
                },
                "held": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "row": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "field",
                "held",
                "row"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "root",
          "name",
          "display_name",
          "endpoint",
          "status",
          "leaf",
          "action",
          "conflicts"
        ],
        "additionalProperties": false
      }
    },
    "counts": {
      "type": "object",
      "properties": {
        "contacts": {
          "type": "number"
        },
        "threads": {
          "type": "number"
        },
        "messages": {
          "type": "number"
        },
        "media": {
          "type": "number"
        },
        "media_bytes": {
          "type": "number"
        }
      },
      "required": [
        "contacts",
        "threads",
        "messages",
        "media",
        "media_bytes"
      ],
      "additionalProperties": false
    },
    "expires_at": {
      "type": "number"
    }
  },
  "required": [
    "digest",
    "root_fingerprint",
    "contacts",
    "counts",
    "expires_at"
  ],
  "additionalProperties": false
}
```

</details>

```sh
curl -X POST 'https://api.batondeck.com/v1/identities/:slug/import/review' \
  -H "Authorization: Bearer $BATONDECK_API_KEY" \
  -H 'content-type: application/json' \
  -d @body.json
```


## Review an export zip sent as the raw body (application/zip, up to the host's import ceiling): the same review as the JSON door

`PUT /v1/identities/{slug}/import/review` · operation `uploadImportReview`

Requires the `batondeck:identities:manage` permission (action `identity:import`).

Requires a step-up: MFA enrolled and re-authenticated within 15 minutes. **Not reachable with an API key** — a key has no session and so can never step up.

Refused while the workspace is suspended or on deletion hold.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `slug` | path | string | yes |  |

**Request body** (`application/zip`): The file itself, with its Content-Length, up to 99614720 bytes.

**Responses**

| Status | Meaning |
|---|---|
| 200 | Review an export zip sent as the raw body (application/zip, up to the host's import ceiling): the same review as the JSON door |
| 401 | No portal session, and no live API key. |
| 403 | The policy refused, or the request was cross-site. |
| 404 | No such resource, or none this session may see. |

<details>
<summary>200 response schema</summary>

```json
{
  "type": "object",
  "properties": {
    "digest": {
      "type": "string"
    },
    "root_fingerprint": {
      "type": "string"
    },
    "contacts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "root": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "endpoint": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "leaf": {
            "type": "boolean"
          },
          "action": {
            "type": "string",
            "enum": [
              "add",
              "pin",
              "keep",
              "skip"
            ]
          },
          "conflicts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string"
                },
                "held": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "row": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "field",
                "held",
                "row"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "root",
          "name",
          "display_name",
          "endpoint",
          "status",
          "leaf",
          "action",
          "conflicts"
        ],
        "additionalProperties": false
      }
    },
    "counts": {
      "type": "object",
      "properties": {
        "contacts": {
          "type": "number"
        },
        "threads": {
          "type": "number"
        },
        "messages": {
          "type": "number"
        },
        "media": {
          "type": "number"
        },
        "media_bytes": {
          "type": "number"
        }
      },
      "required": [
        "contacts",
        "threads",
        "messages",
        "media",
        "media_bytes"
      ],
      "additionalProperties": false
    },
    "expires_at": {
      "type": "number"
    }
  },
  "required": [
    "digest",
    "root_fingerprint",
    "contacts",
    "counts",
    "expires_at"
  ],
  "additionalProperties": false
}
```

</details>

```sh
curl -X PUT 'https://api.batondeck.com/v1/identities/:slug/import/review' \
  -H "Authorization: Bearer $BATONDECK_API_KEY" \
  -H 'content-type: application/zip' \
  --data-binary @file
```


## An open review of an import: the contacts shown for that file, until it closes

`GET /v1/identities/{slug}/import/review/{digest}` · operation `getImportReview`

Requires the `batondeck:identities:read` permission (action `identity:read`).

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `slug` | path | string | yes |  |
| `digest` | path | string | yes |  |

**Responses**

| Status | Meaning |
|---|---|
| 200 | An open review of an import: the contacts shown for that file, until it closes |
| 401 | No portal session, and no live API key. |
| 403 | The policy refused, or the request was cross-site. |
| 404 | No such resource, or none this session may see. |

<details>
<summary>200 response schema</summary>

```json
{
  "type": "object",
  "properties": {
    "digest": {
      "type": "string"
    },
    "root_fingerprint": {
      "type": "string"
    },
    "contacts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "root": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "endpoint": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "leaf": {
            "type": "boolean"
          },
          "action": {
            "type": "string",
            "enum": [
              "add",
              "pin",
              "keep",
              "skip"
            ]
          },
          "conflicts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string"
                },
                "held": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "row": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "field",
                "held",
                "row"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "root",
          "name",
          "display_name",
          "endpoint",
          "status",
          "leaf",
          "action",
          "conflicts"
        ],
        "additionalProperties": false
      }
    },
    "counts": {
      "type": "object",
      "properties": {
        "contacts": {
          "type": "number"
        },
        "threads": {
          "type": "number"
        },
        "messages": {
          "type": "number"
        },
        "media": {
          "type": "number"
        },
        "media_bytes": {
          "type": "number"
        }
      },
      "required": [
        "contacts",
        "threads",
        "messages",
        "media",
        "media_bytes"
      ],
      "additionalProperties": false
    },
    "expires_at": {
      "type": "number"
    }
  },
  "required": [
    "digest",
    "root_fingerprint",
    "contacts",
    "counts",
    "expires_at"
  ],
  "additionalProperties": false
}
```

</details>

```sh
curl -X GET 'https://api.batondeck.com/v1/identities/:slug/import/review/:digest' \
  -H "Authorization: Bearer $BATONDECK_API_KEY"
```


## Close an open review of an import before its time: the review and the uploaded file it holds go, and nothing else changes

`DELETE /v1/identities/{slug}/import/review/{digest}` · operation `cancelImportReview`

Requires the `batondeck:identities:manage` permission (action `identity:import`).

Requires a step-up: MFA enrolled and re-authenticated within 15 minutes. **Not reachable with an API key** — a key has no session and so can never step up.

Refused while the workspace is suspended or on deletion hold.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `slug` | path | string | yes |  |
| `digest` | path | string | yes |  |

**Responses**

| Status | Meaning |
|---|---|
| 204 | Done. No body. |
| 401 | No portal session, and no live API key. |
| 403 | The policy refused, or the request was cross-site. |
| 404 | No such resource, or none this session may see. |

```sh
curl -X DELETE 'https://api.batondeck.com/v1/identities/:slug/import/review/:digest' \
  -H "Authorization: Bearer $BATONDECK_API_KEY"
```


## Take in a reviewed export zip, named by its review's digest: the file the review holds is read again and written, refused unless it reads as reviewed; answers the renew request the wallet signs next

`POST /v1/identities/{slug}/import` · operation `importArchive`

Requires the `batondeck:identities:manage` permission (action `identity:import`).

Requires a step-up: MFA enrolled and re-authenticated within 15 minutes. **Not reachable with an API key** — a key has no session and so can never step up.

Refused while the workspace is suspended or on deletion hold.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `slug` | path | string | yes |  |

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

| Field | Type | Required | Notes |
|---|---|---|---|
| `digest` | string | yes |  |

<details>
<summary>Request schema</summary>

```json
{
  "type": "object",
  "properties": {
    "digest": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    }
  },
  "required": [
    "digest"
  ],
  "additionalProperties": false
}
```

</details>

**Responses**

| Status | Meaning |
|---|---|
| 200 | Take in a reviewed export zip, named by its review's digest: the file the review holds is read again and written, refused unless it reads as reviewed; answers the renew request the wallet signs next |
| 400 | The arguments did not validate. |
| 401 | No portal session, and no live API key. |
| 403 | The policy refused, or the request was cross-site. |
| 404 | No such resource, or none this session may see. |

<details>
<summary>200 response schema</summary>

```json
{
  "type": "object",
  "properties": {
    "root_fingerprint": {
      "type": "string"
    },
    "contacts": {
      "type": "object",
      "properties": {
        "written": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "kept": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "leafless": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "conflicts": {
          "type": "number"
        }
      },
      "required": [
        "written",
        "kept",
        "leafless",
        "conflicts"
      ],
      "additionalProperties": false
    },
    "threads": {
      "type": "number"
    },
    "messages": {
      "type": "number"
    },
    "media": {
      "type": "number"
    },
    "renewal": {
      "type": "object",
      "properties": {
        "csr": {
          "type": "string"
        },
        "endpoint": {
          "type": "string"
        },
        "purpose": {
          "type": "string"
        },
        "suggested_not_after": {
          "type": "string"
        },
        "previous_not_before": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "key_fingerprint": {
          "type": "string"
        }
      },
      "required": [
        "csr",
        "endpoint",
        "purpose",
        "suggested_not_after",
        "previous_not_before",
        "key_fingerprint"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "root_fingerprint",
    "contacts",
    "threads",
    "messages",
    "media",
    "renewal"
  ],
  "additionalProperties": false
}
```

</details>

```sh
curl -X POST 'https://api.batondeck.com/v1/identities/:slug/import' \
  -H "Authorization: Bearer $BATONDECK_API_KEY" \
  -H 'content-type: application/json' \
  -d @body.json
```
