# Get Piece Scans

> `GET /pieces/{piece_id}/scans`

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

URL: `GET https://api.earthclassmail.com/v1/pieces/{piece_id}/scans`

Retrieves all scans associated with a given piece. Returns a paged list of scan operations, including status, page counts, and completion timestamps.

## Authorization

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

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `piece_id` | path | yes | string |  |
| `page` | query | no | integer | The desired page from the result set. Defaults to 1. |
| `per_page` | query | no | integer | The number of items per page. Defaults to 100. |

## Responses

### 200

Success

Content type: `application/json`

- `total` (integer): Total number of items across all pages.
- `per_page` (integer): Number of items per page.
- `current_page` (integer): The current page number (1-based).
- `last_page` (integer): The last available page number.
- `from` (integer): The index of the first item on this page (1-based).
- `to` (integer): The index of the last item on this page (1-based).
- `data` (array of `Scan`)

Example:

```json
{
  "total": 1,
  "per_page": 100,
  "current_page": 1,
  "last_page": 1,
  "from": 1,
  "to": 1,
  "data": [
    {
      "id": 8042156,
      "piece_id": 15998793,
      "scan_type": "color",
      "page_count_estimate": 4,
      "page_count_actual": 3,
      "status": "complete",
      "operation_action": "scan",
      "operation_status": "complete",
      "post_operation_action": "store",
      "comments": null,
      "completed_at": "2026-05-20T14:32:10Z",
      "estimated_completed_at": "2026-05-20T15:00:00Z",
      "tags": [],
      "created_at": "2026-05-20T13:45:00Z",
      "updated_at": "2026-05-20T14:32:10Z"
    }
  ]
}
```

### 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"
  }
}
```

## 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.

### Scan

- `id` (integer)
- `created_at` (string<date-time>)
- `updated_at` (string<date-time>)
- `operation_action` (string)
- `operation_status` (string)
- `tags` (array of string)
- `piece_id` (integer)
- `page_count_estimate` (integer)
- `page_count_actual` (integer or null)
- `completed_at` (string<date-time> or null)
- `estimated_completed_at` (string<date-time> or null)
- `post_operation_action` (string or null)
- `scan_type` (string)
- `comments` (string or null)
- `status` (string)
- `piece` (`Piece` or null)

### 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)

### 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)
