# List Assets

> Media API · Assets

```http
GET https://app.mk.io/api/v1/projects/{project_name}/media/assets
```

## Listing, Sorting and Filtering Assets

This endpoint returns the list of assets in the specified project.

### Sorting

The results from this endpoint can be ordered using the `$orderby` query parameter. Specify a list of field names, separated by commas
where each one can optionally specify `asc` or `desc`.

Sorting is valid on the following fields: `created`, `createdBy`, `id`, `labels`, `name`, `properties/alternateId`, `properties/assetId`, `properties/container`, `properties/containerDeletionPolicy`, `properties/created`, `properties/lastModified`, `properties/storageAccountName`, `properties/subPath`, `updated`, `updatedBy`

### Filtering

There are two ways to filter the set of returned assets from this endpoint - the first is to use the `$filter` query parameter, the second is to use the
`$label_key` and `$label` query parameters.

The `$filter` query parameter allows for assets to be filtered on the basis of fields in the schema using OData query syntax.
See [this document](https://learn.microsoft.com/en-us/odata/concepts/queryoptions-overview#filter) for more details on the syntax used.

Filters are valid on the following fields: `created`, `createdBy`, `createdByEmail`, `createdByName`, `id`, `labels`, `name`, `properties/alternateId`, `properties/assetId`, `properties/container`, `properties/containerDeletionPolicy`, `properties/created`, `properties/lastModified`, `properties/storageAccountName`, `properties/subPath`, `updated`, `updatedBy`, `updatedByEmail`, `updatedByName`

`$label_key` and `$label` are specific to querying assets based on their labels. Labels are a set of key-value pairs that can be used to identify assets with
any arbitrary metadata you want, specifically for the purpose of retrieving relevant subsets of assets.

### Examples:

`?$top=10` - Returns only the first 10 assets from the list.

`?$orderby=name desc` - Sorts assets by name in descending order.

`?$filter=name eq 'descriptive name'` - Returns assets that match the provided name.

`?$orderby=created desc` - Sorts assets by creation date in descending order.

`?$filter=created ge 2021-01-01T00:00:00Z` - Returns assets created after January 1, 2021.

`?$label=studio=paravalley` - Returns assets with the label `studio` set to `paravalley`.

`?$label=release-date~2023` - Returns assets with the label `release-date` set to a value that contains `2023`.

`?$label_key=studio&label_key=release-date` - Returns assets with any value set for the `studio` label and the `release-date` label.

RBAC Capability Required: `ams.asset.get`

## Authentication

- `Authorization` header — Bearer authentication of the form `Bearer <token>`.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `project_name` | string | Yes | — |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `$orderby` | string | No | Specifies the key by which the result collection should be ordered. |
| `$filter` | string | No | Restricts the set of items returned. |
| `$top` | string | No | Specifies a non-negative integer `n` that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value `n`. |
| `$skiptoken` | string | No | Specifies a start offset to support paginated results. Use `@odata.nextLink` in the result object to enumerate the collection - it will be present only if there's more than one page of entities. |
| `$label_key` | string | No | Filters the set to the specified label key. If multiple $label_keys are specified, matching items must have all labels. |
| `$label` | string | No | Filters the set to the specified label key/value pair. Supports equality, inequality, and inexact matching. If multiple values are provided for the same key, items matching either value will be returned. |

## Example request

```bash
curl -X GET "https://app.mk.io/api/v1/projects/{project_name}/media/assets" \
  -H "Authorization: Bearer <token>"
```

## Responses

### 200 — A list of assets

- `@odata.nextLink` · string · Optional — @odata.nextLink URL if the page length and number of items match.
- `supplemental` · object · **Required** — Supplemental info
  - `count` · integer · **Required** — Number of items returned
  - `kind` · string · **Required** — Type of items in the list
  - `operation` · string · **Required** — Operation type. Should always say 'list'
  - `pagination` · object · **Required** — Pagination info
    - `end` · integer · **Required** — Position of the last item in the list
    - `records` · integer · **Required** — Total number of items returned in the list
    - `start` · integer · **Required** — Position of the first item in the list
    - `total` · integer · **Required** — Total number of items in the project
  - `subscription` · object · Optional — Project info
    - `id` · string · **Required** — Project ID
    - `name` · string · **Required** — Project name
- `value` · list of objects · **Required** — A list of assets.
  - Array items (object):
    - `id` · string · Optional — Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
    - `labels` · map from strings to string · Optional — A dictionary of labels associated with the resource. - Maximum number of labels: 32. - Maximum length of a label or value: 256 characters. - Label: alphanumeric, hyphens and underscores. - Value: alphanumeric, hyphens, underscores and spaces.
      - `[any key]` · string — map of additional properties
    - `name` · string · Optional · _1-260 characters_ · _pattern: ^[^\^\'<>%&:\\?/*+]+$_ — The name of the resource
    - `properties` · object · **Required** — The properties of the asset.
      - `alternateId` · string · Optional · _0-64 characters_ — An alternate ID of the asset.
      - `assetId` · string · Optional · _format: uuid_ — The Asset ID.
      - `container` · string · Optional · _3-63 characters_ · _pattern: ^(?!.*--)(?=[a-z0-9-]{3,63}$)(?!-)[a-z0-9]+(?:-[a-z0-9]+)*$_ — The name of the container if this asset is stored in an Azure storage account.
      - `containerDeletionPolicy` · enum · Optional — This field defines the deletion policy for the underlying storage. This determines the behavior when an asset record is deleted. There are two options, 'Delete', and 'Retain'. A deletion policy of 'Delete' will result in the associated storage container or folder and all its contents being removed. A deletion policy of 'Retain' will leave the content in place. If left blank, the default behavior of the system will be to retain content. Once set by the user, this value can be modified, but not un-set.
        - Allowed values: `Delete`, `Retain`
      - `created` · string · Optional · _format: date-time_ — The creation date of the Asset.
      - `description` · string · Optional · _0-4096 characters_ — The Asset description.
      - `encryptionScope` · string or null · Optional — Accepted, not supported. The name of the encryption scope to use within your storage container. Errors may be cryptic.
      - `lastModified` · string · Optional · _format: date-time_ — The last modified date of the Asset.
      - `storageAccountName` · string · **Required** · _0-255 characters_ — The name of the storage in MK.IO.
      - `storageEncryptionFormat` · enum · Optional — This field was deprecated in the v3 API. Accepted, not supported. Use an encryption scope instead.
        - Allowed values: `None`, `MediaStorageClientEncryption`
      - `subPath` · string · Optional · _1-256 characters_ · _pattern: ^(?!/)(?!.*(//|\?|%|&)).*[^/]$_ — Optional subpath for instances where your asset is not in the root of the container. This needs to be an absolute directory path and can't be an empty string or start with '.', './' or '/' or end with '/'. Valid examples: 'path', 'path2', 'path/to/asset'
    - `systemData` · object · Optional — Metadata pertaining to creation and last modification of the resource.
      - `createdAt` · string · **Required** · _format: date-time_ — The timestamp of resource creation (UTC).
      - `createdBy` · string · **Required** — The identity that created the resource.
      - `createdByType` · enum · **Required** — The type of identity that created the resource.
        - Allowed values: `User`, `Application`, `ManagedIdentity`, `Key`
      - `internalId` · string · **Required** · _format: uuid_ — The internal ID of the resource.
      - `lastModifiedAt` · string · **Required** · _format: date-time_ — The timestamp of resource last modification (UTC).
      - `lastModifiedBy` · string · **Required** — The identity that last modified the resource.
      - `lastModifiedByType` · enum · **Required** — The type of identity that last modified the resource.
        - Allowed values: `User`, `Application`, `ManagedIdentity`, `Key`
    - `type` · string · Optional — The type of the resource. E.g. "Microsoft.Media/mediaservices/assets"

Example:

```json
{
  "@odata.nextLink": "string",
  "supplemental": {
    "count": 0,
    "kind": "string",
    "operation": "string",
    "pagination": {
      "end": 0,
      "records": 0,
      "start": 0,
      "total": 0
    },
    "subscription": {
      "id": "string",
      "name": "string"
    }
  },
  "value": [
    {
      "id": "string",
      "labels": {
        "label1": "value1",
        "label2": ""
      },
      "name": "name",
      "properties": {
        "alternateId": "string",
        "assetId": "00000000-0000-0000-0000-000000000000",
        "container": "ContainerName",
        "containerDeletionPolicy": "Delete",
        "created": "2024-01-01T00:00:00Z",
        "description": "string",
        "encryptionScope": "string",
        "lastModified": "2024-01-01T00:00:00Z",
        "storageAccountName": "string",
        "storageEncryptionFormat": "None",
        "subPath": "path/to/asset"
      },
      "systemData": {
        "createdAt": "2024-01-01T00:00:00Z",
        "createdBy": "string",
        "createdByType": "User",
        "internalId": "00000000-0000-0000-0000-000000000000",
        "lastModifiedAt": "2024-01-01T00:00:00Z",
        "lastModifiedBy": "string",
        "lastModifiedByType": "User"
      },
      "type": "string"
    }
  ]
}
```

### 400 — Bad Request

- `error` · object · **Required** — Pertinent information about the error
  - `code` · string · **Required** — The error code.
  - `detail` · string · **Required** — The error message.
  - `extraDetail` · map from strings to any · Optional — Extra information regarding this error.
    - `[any key]` · any — map of additional properties
- `ref` · string · **Required** — A reference to the request that caused the error.
- `status` · integer · **Required** — The HTTP status code

Example:

```json
{
  "error": {
    "code": "string",
    "detail": "string",
    "extraDetail": {
      "key": null
    }
  },
  "ref": "string",
  "status": 0
}
```

### 401 — Unauthorized

- `error` · object · **Required** — Pertinent information about the error
  - `code` · string · **Required** — The error code.
  - `detail` · string · **Required** — The error message.
  - `extraDetail` · map from strings to any · Optional — Extra information regarding this error.
    - `[any key]` · any — map of additional properties
- `ref` · string · **Required** — A reference to the request that caused the error.
- `status` · integer · **Required** — The HTTP status code

Example:

```json
{
  "error": {
    "code": "string",
    "detail": "string",
    "extraDetail": {
      "key": null
    }
  },
  "ref": "string",
  "status": 0
}
```

### 403 — Forbidden

- `error` · object · **Required** — Pertinent information about the error
  - `code` · string · **Required** — The error code.
  - `detail` · string · **Required** — The error message.
  - `extraDetail` · map from strings to any · Optional — Extra information regarding this error.
    - `[any key]` · any — map of additional properties
- `ref` · string · **Required** — A reference to the request that caused the error.
- `status` · integer · **Required** — The HTTP status code

Example:

```json
{
  "error": {
    "code": "string",
    "detail": "string",
    "extraDetail": {
      "key": null
    }
  },
  "ref": "string",
  "status": 0
}
```

### 404 — Not Found

- `error` · object · **Required** — Pertinent information about the error
  - `code` · string · **Required** — The error code.
  - `detail` · string · **Required** — The error message.
  - `extraDetail` · map from strings to any · Optional — Extra information regarding this error.
    - `[any key]` · any — map of additional properties
- `ref` · string · **Required** — A reference to the request that caused the error.
- `status` · integer · **Required** — The HTTP status code

Example:

```json
{
  "error": {
    "code": "string",
    "detail": "string",
    "extraDetail": {
      "key": null
    }
  },
  "ref": "string",
  "status": 0
}
```

### 429 — Too Many Requests

- `error` · object · **Required** — Pertinent information about the error
  - `code` · string · **Required** — The error code.
  - `detail` · string · **Required** — The error message.
  - `extraDetail` · map from strings to any · Optional — Extra information regarding this error.
    - `[any key]` · any — map of additional properties
- `ref` · string · **Required** — A reference to the request that caused the error.
- `status` · integer · **Required** — The HTTP status code

Example:

```json
{
  "error": {
    "code": "string",
    "detail": "string",
    "extraDetail": {
      "key": null
    }
  },
  "ref": "string",
  "status": 0
}
```

### 500 — Internal Server Error

- `error` · object · **Required** — Pertinent information about the error
  - `code` · string · **Required** — The error code.
  - `detail` · string · **Required** — The error message.
  - `extraDetail` · map from strings to any · Optional — Extra information regarding this error.
    - `[any key]` · any — map of additional properties
- `ref` · string · **Required** — A reference to the request that caused the error.
- `status` · integer · **Required** — The HTTP status code

Example:

```json
{
  "error": {
    "code": "string",
    "detail": "string",
    "extraDetail": {
      "key": null
    }
  },
  "ref": "string",
  "status": 0
}
```

---

Source spec: `media-api` · operationId: `[get]_/api/v1/projects/{project_name}/media/assets`
