# Undo an import batch

Removes exactly the rows one import run created and nothing else, keeping any that have since been converted into deals and naming each one it kept. Refuses a run that never finished, and refuses a second undo of the same batch. Reach for it after a mis-import instead of deleting rows by hand.

Access class: `def:read`.

## Endpoint

`POST /v1/definitions/{key}/imports/{runId}/undo`

## Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| key | path | string | Yes |
| runId | path | string | Yes |

## Request body

Content type: `application/json`.

```json
{
  "body": {},
  "params": {
    ":key": "string",
    ":runId": ""
  },
  "query": {}
}
```

## Responses

### 201

the action's answer

Content type: `application/json`.

```json
{
  "data": {
    "kept": [
      {
        "dealRowId": "",
        "reason": "string",
        "rowId": ""
      }
    ],
    "removed": 1,
    "run": {
      "actorUserId": 1,
      "createdAt": "string",
      "error": "string",
      "failed": 1,
      "fileName": "string",
      "finishedAt": "string",
      "id": "",
      "imported": 1,
      "keptCount": 1,
      "results": [
        "string"
      ],
      "standing": 1,
      "status": "string",
      "total": 1,
      "undoneAt": "string",
      "undoneBy": 1,
      "undoneCount": 1
    }
  }
}
```

### default

a refusal: `{"error": "<what a person needs to read>"}`. 401 no credential, 402 the plan does not include this, 403 the seat does not, 404 the thing does not exist or is not yours to see.

Content type: `application/json`.

```json
{
  "error": "string"
}
```
