# Cancel Check Deposit

> `DELETE /pieces/{piece_id}/check-deposit-requests/{check_deposit_request_id}`

Web page: https://reference.earthclassmail.com/v1/rest-api/spec/operations/cancelcheckdeposit/

URL: `DELETE https://api.earthclassmail.com/v1/pieces/{piece_id}/check-deposit-requests/{check_deposit_request_id}`

Cancels a check deposit request that the mailroom hasn't acted on yet. Once the checks have been extracted from the piece, the deposit can't be cancelled. A pending scan for the piece is cancelled too. The piece goes back to the state it was in before the request.

Returns the cancelled request, with `status` set to `Cancelled`, and `400` if the piece has no deposit request to cancel or the checks have already been extracted.

## Authorization

Send your API key in the `x-api-key` header.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `piece_id` | path | yes | string |  |
| `check_deposit_request_id` | path | yes | string | The `id` of the deposit request, from [Get Requested Check Deposits for Piece](https://reference.earthclassmail.com/_llms_txt/v1/rest-api/spec/operations/listpiececheckdepositrequests.md). |

## Responses

### 200

Success

Content type: `application/json`

Type: `PieceCheckDepositRequest`

Example:

```json
{
  "id": 100001,
  "created_at": "2020-05-10T09:41:00Z",
  "updated_at": "2020-05-10T10:02:00Z",
  "operation_action": "check-deposit",
  "operation_status": "problem",
  "status": "Cancelled",
  "check_deposit_bank_account_id": 500,
  "piece_id": 100002,
  "inbox_id": 100003,
  "expedited": false,
  "post_operation_action": null,
  "checks": [],
  "piece": {
    "id": 100002
  }
}
```

### 400

The piece has no deposit request to cancel, or its checks have already been extracted.

Content type: `application/json`

Type: `Error`

Example:

```json
{
  "error": {
    "code": 400,
    "message": "inbox_id: Unable to cancel Check Deposit for PieceID: 100002",
    "type": "REST"
  }
}
```

### 401

The `x-api-key` header is missing or the key is not valid, or the caller can't access an ID in the request. IDs that don't exist return the same response as IDs the caller can't access.

Content type: `application/json`

Type: `Error`

Example — Missing API key:

```json
{
  "error": {
    "code": 401,
    "message": "The request does not include a valid access token. Please provide a valid access token.",
    "type": "Authorization"
  }
}
```

Example — Invalid API key:

```json
{
  "error": {
    "code": 401,
    "message": "x-api-key: x-api-key is invalid",
    "type": "REST"
  }
}
```

Example — No access to resource:

```json
{
  "error": {
    "code": 401,
    "message": "User does not have access to requested resource.",
    "type": "Authorization"
  }
}
```

### 403

Actions are blocked for a piece in the request. When an account's mail actions are blocked, for example because the account wasn't reverified or an identity document expired, pieces received after that can't be changed. These pieces have `actions-blocked-no-reverification` or `actions-blocked-document-expired` in their `attributes`.

Content type: `application/json`

Type: `Error`

Example — Piece actions blocked:

```json
{
  "error": {
    "code": 403,
    "message": "piece: Mail actions for piece with ID 123456 has been blocked.",
    "type": "REST"
  }
}
```

## Schemas

### Error

Error envelope returned with 4xx and 5xx responses.

- `error` (object)
  - `code` (integer): Usually the HTTP status code. It can differ; a request to an unknown path returns HTTP 400 with code 500.
  - `message` (string): Human-readable description of the error.
  - `type` (string): The kind of error, for example `Authorization` or `REST`.
  - `fields` (object): Returned only with `422` responses. It may give more details about what failed validation, as lists of messages keyed by the name of the input.

### PieceCheckDepositRequest

- `id` (integer)
- `created_at` (string<date-time>)
- `updated_at` (string<date-time>)
- `operation_action` (string)
- `operation_status` (string)
- `tags` (array of string)
- `check_deposit_bank_account_id` (integer or null)
- `status` (string): `Opened` while the request is in progress, then `Shipped` once the checks are on their way to the bank. `Cancelled` and `Error` end a request without a deposit.
- `expedited` (boolean): Whether overnight delivery to the bank was requested. See `expedited` in Request Check Deposit.
- `bank_account` (`InboxCheckDepositBankAccount`)
- `resubmittable` (boolean)
- `checks` (array of `DepositCheck`)
- `shipment` (`PieceCheckDepositShipment` or null)
- `inbox_id` (integer or null)
- `post_operation_action` (`PostDepositOperationAction` or null)
- `piece_id` (integer)
- `deposit_slips` (array of `Media`)
- `requested_at` (string<date-time>)
- `extracted_at` (string<date-time>)
- `check_processing_system_type` (integer)
- `validate_only` (boolean)
- `scan_page_number` (integer)
- `piece` (`Piece` or null)
- `date_arrived_at` (string<date-time>)
- `deposit_slip_ids` (array of integer)

### DepositCheck

- `id` (integer)
- `amount_in_cents` (integer)
- `check_number` (string)
- `piece_id` (integer)
- `media` (array of `Media`)

### InboxCheckDepositBankAccount

- `id` (integer)
- `created_at` (string<date-time>)
- `updated_at` (string<date-time>)
- `inbox_id` (integer or null)
- `routing_number` (string)
- `check_processing_system_type` (integer)
- `account_number` (string)
- `account_display_name` (string)
- `account_type` (string)
- `financial_institution` (`BankingInstitution`)
- `contact_name` (string)
- `contact_business` (string)
- `contact_address` (string)
- `contact_phone` (string)
- `rdc` (boolean)

### Media

- `id` (string)
- `url` (string)
- `content_type` (string)
- `tags` (array of string)
- `url_valid_until` (string<date-time>)
- `file_size_in_bytes` (integer)

### Piece

- `id` (integer)
- `created_at` (string<date-time>)
- `updated_at` (string<date-time>)
- `inbox_id` (integer)
- `barcode` (string)
- `license_plate` (integer)
- `recipient` (`PieceRecipient`)
- `mailbox_folder_id` (integer)
- `tags` (array of string)
- `attributes` (array of string)
- `sender` (`PieceSender` or null)
- `received_at` (string<date-time>)
- `date_arrived_in_mailbox` (string<date-time>)
- `weight_in_ounces` (number)
- `facility_name` (string)
- `page_count_estimate` (integer)
- `page_count_actual` (integer or null)
- `height_in_inches` (number)
- `depth_in_inches` (number)
- `length_in_inches` (number)
- `carrier` (`PieceCarrier`)
- `media` (array of `PieceMedia`)
- `ocr_data` (string)
- `envelope_ocr_data` (string)
- `piece_type` (string)
- `piece_sub_type` (string)
- `insights` (array of `PieceInsight`)
- `user_defined_tags` (array of `Tag`)
- `matched_by` (array of string)
- `operation_action` (string or null)
- `end_user_operation_status` (string or null)
- `storage_fee_amount_in_cents` (integer)
- `can_delete_scan_only` (boolean)
- `available_actions` (array of string)
- `name` (string)
- `detected_checks_count` (integer or null)
- `recipient_type` (string)

### PieceCheckDepositShipment

- `id` (integer or null)
- `carrier` (string)
- `carrier_service` (string)
- `tracking_number` (string)
- `external_id` (string or null)
- `shipped_at` (string<date-time>)
- `expected_delivery_at` (string<date-time>)
- `delivered_at` (string<date-time>)

### PostDepositOperationAction

- `type` (string, required): `store` keeps the piece, `shred` shreds it. One of: `store`, `shred`.

### BankingInstitution

- `id` (integer)
- `name` (string)
- `routing_number` (string)
- `has_shipping_address` (boolean)
- `shipping_banking_institution_id` (integer or null)
- `expedited` (boolean): When `true`, every deposit to this bank ships overnight at no extra cost, so there's no need to request `expedited`.
- `shipping_addresses` (array of `ShippingAddress`)
- `rdc` (boolean)
- `rdcVerified` (boolean)

### PieceCarrier

- `name` (string)
- `class` (string)

### PieceInsight

- `type` (string)
- `confidence` (number)

### PieceMedia

- `id` (string)
- `url` (string)
- `content_type` (string)
- `tags` (array of string)
- `url_valid_until` (string<date-time>)
- `file_size_in_bytes` (integer)
- `piece_id` (integer or null)
- `scan_id` (integer or null)
- `page_count` (integer or null)
- `sequence_number` (integer or null)

### PieceRecipient

- `id` (integer)
- `name` (string)
- `inbox_id` (integer or null)
- `type` (string)

### PieceSender

- `name` (string)
- `address` (string)

### Tag

- `id` (integer)
- `created_at` (string<date-time>)
- `updated_at` (string<date-time>)
- `label` (string)
- `parent_tag_id` (integer or null)
- `piece_counts` (integer or null)

### ShippingAddress

- `id` (integer)
- `created_at` (string<date-time>)
- `updated_at` (string<date-time>)
- `addressee` (string)
- `address_line_1` (string)
- `address_line_2` (string)
- `locality` (string)
- `region_abbreviation` (string)
- `region` (string)
- `country_abbreviation` (string)
- `country` (string)
- `postal_code` (string)
- `phone` (string)
- `tags` (array of string)
- `delivery_confidence_percent` (number or null)
- `inbox_id` (integer or null)
- `company` (string or null)
- `is_authorized` (boolean or null)
- `requires_hs_tariff_codes` (boolean or null)
- `requires_itn` (boolean or null)
