> ## Documentation Index
> Fetch the complete documentation index at: https://help.ezyid.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Chain of Custody by APK ID

> Retrieve custody history for an asset using its internal APK ID.

The `apkId` path parameter is the internal asset APK ID used by [Retrieve Asset](https://help.ezyid.io/api-reference/endpoint/get-asset.md). It differs from the asset detail row's `id`.

Authenticate using the API key generated in **Admin → My Preferences → API Key Configuration**. The asset must belong to the subscriber associated with that key. Do not supply `subscriberId` or combine the APK ID with another asset selector.

```bash theme={null}
curl --get 'https://api-external.ezyid.io/api/assets/123/chain-of-custody' \
  --data-urlencode 'apiKey=YOUR_API_KEY' \
  --data-urlencode 'sortColumn=date' \
  --data-urlencode 'sortDesc=true'
```

This route supports the same date, search, performed-by, movement type, and sorting parameters as [Chain of Custody by Identifier](https://help.ezyid.io/api-reference/endpoint/chain-of-custody.md). Both return the same report envelope and have the same 10,000-row limit. Retrieving the report does not perform a transfer or update inventory.


## OpenAPI

````yaml GET /api/assets/{apkId}/chain-of-custody
openapi: 3.0.1
info:
  title: EZYiD API
  version: '1.0'
servers:
  - url: https://api-external.ezyid.io
security: []
tags:
  - name: EZYiD.External.API
paths:
  /api/assets/{apkId}/chain-of-custody:
    get:
      tags:
        - Assets
      summary: Retrieve chain of custody by APK ID
      description: >-
        Authenticates with the My Preferences API key and resolves the asset
        within its subscriber. No subscriberId parameter is required. Supply
        exactly one selector: apkId, ezyid, serialNumber, or customId. Lookup
        uses exact matches under the database collation and returns 409 for
        ambiguous identifiers. Retrieves history only; it does not transfer
        assets or update inventory.
      operationId: GetAssetChainOfCustodyByApkId
      parameters:
        - name: apkId
          in: path
          required: true
          description: >-
            Internal asset APK ID. Do not combine with ezyid, serialNumber or
            customId.
          schema:
            type: integer
            format: int32
            minimum: 1
        - name: apiKey
          in: query
          required: true
          description: >-
            API key generated in Admin > My Preferences > API Key Configuration.
            The subscriber is read from this key; do not supply subscriberId.
          schema:
            type: string
        - name: fromDate
          in: query
          required: false
          description: >-
            Inclusive start date. Must be on or before toDate when both are
            supplied.
          schema:
            type: string
            format: date
        - name: toDate
          in: query
          required: false
          description: Inclusive end date.
          schema:
            type: string
            format: date
        - name: search
          in: query
          required: false
          description: Search text for the chain of custody report.
          schema:
            type: string
        - name: performedBy
          in: query
          required: false
          description: Comma-separated names to filter the report.
          schema:
            type: string
        - name: custodyMovementTypes
          in: query
          required: false
          description: >-
            Comma-separated, case-insensitive substrings of event type names,
            for example transfer,checkout.
          schema:
            type: string
        - name: sortColumn
          in: query
          required: false
          description: >-
            Column to sort by. Defaults to date. Supported canonical keys: date,
            assetname, category, assetid, partnumber, serialnumber, customid,
            site, movementtype, performedby, details, eventid.
          schema:
            type: string
            default: date
        - name: sortDesc
          in: query
          required: false
          description: Use true for descending order.
          schema:
            type: boolean
            default: false
      responses:
        '200':
          description: >-
            Chain of custody report. Returns at most 10,000 rows with page 1 and
            pageSize 10000; these endpoints do not expose paging parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChainOfCustodyReport'
        '400':
          description: >-
            Missing apiKey, invalid input, no asset selector, multiple asset
            selectors, or invalid date range. Input binding errors may use the
            framework validation error format.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '401':
          description: API key is revoked or expired.
        '404':
          description: >-
            API key is unknown, or the selected asset does not exist in the
            key's subscriber. Assets belonging to other subscribers are not
            exposed.
        '409':
          description: >-
            The identifier matches multiple assets in the key's subscriber. Use
            a unique identifier or the APK ID.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '502':
          description: The inventory service could not return the chain of custody report.
          content:
            application/problem+json:
              schema:
                type: object
                properties:
                  title:
                    type: string
                    example: The chain of custody report is unavailable.
                  status:
                    type: integer
                    example: 502
components:
  schemas:
    ChainOfCustodyReport:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/ChainOfCustodyRow'
        totalCount:
          type: integer
          format: int32
          description: Total count reported by the inventory service.
        page:
          type: integer
          example: 1
        pageSize:
          type: integer
          example: 10000
          description: >-
            The internal report row limit. No page or pageSize query parameters
            are exposed.
    ApiError:
      type: object
      properties:
        error:
          type: string
          description: >-
            What was wrong with the request, naming the field or operator at
            fault.
    ChainOfCustodyRow:
      type: object
      description: >-
        A custody history row. Uses the existing inventory movement row shape;
        ledger-specific values can be empty or zero.
      properties:
        id:
          type: integer
          format: int32
        date:
          type: string
          format: date-time
        siteId:
          type: integer
          format: int32
        siteName:
          type: string
        inventoryRegisterId:
          type: integer
          format: int32
        itemName:
          type: string
        category:
          type: string
        assetId:
          type: string
        partNumber:
          type: string
        serialNumber:
          type: string
        customId:
          type: string
        movementType:
          type: string
        eventTypeId:
          type: integer
          format: int32
        eventCode:
          type: string
          description: Display event reference, for example E-6483139.
        jobCardCode:
          type: string
          description: Material order or consignment reference when present.
        direction:
          type: string
        stockIn:
          type: number
        stockOut:
          type: number
        balanceAfter:
          type: number
        contractorEmail:
          type: string
        activityCreatedBy:
          type: string
        checkoutToDisplay:
          type: string
        performedBy:
          type: string
        details:
          type: string
          description: >-
            Custody event details, including transfer from/to information when
            available.
        trackingType:
          type: string
        referenceId:
          type: integer
          format: int32
        adjustmentMode:
          type: integer
          format: int32

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.