# Get a media asset by ID

_NgCms / Media Assets_

`GET /ng-cms/media/{projectId}/{mediaId}`

## Parameters

- `projectId` (string, required) — The unique identifier of the project (bucket)
- `mediaId` (string, required) — The unique identifier of the media asset

## Responses

### `200` — The requested media asset.

Type: `CmsMediaAssetDto`

- `id` (string) — Unique identifier of the media asset
- `projectId` (string) — Project (bucket) this asset belongs to
- `fileName` (string) — Original filename as uploaded
- `title` (string) — Human-readable title
- `description` (string) — Optional description of the asset
- `mimeType` (string) — MIME type of the file (e.g. image/jpeg)
- `sizeBytes` (number) — File size in bytes
- `storageProvider` (string) — Storage backend used (e.g. s3)
- `storageKey` (string) — Key used to identify the file in storage
- `publicUrl` (string) — Publicly accessible URL for the asset
- `metadata` (object) — Additional key-value metadata attached to the asset
- `createdBy` (number) — ID of the user who uploaded the asset
- `createdAt` (string) — ISO 8601 timestamp of upload
- `updatedAt` (string) — ISO 8601 timestamp of last update, or null
- `updatedBy` (number) — ID of the user who last updated the asset
- `updatedByName` (string) — Name of the user who last updated the asset
- `publishedAt` (string) — ISO 8601 timestamp of publication, or null
- `publishedBy` (number) — ID of the user who published the asset, or null

### `401` — Unauthorized. A valid bearer token is required.


### `404` — Not Found. No media asset exists with the given ID.


### `412` — Precondition Failed. The project's current plan does not allow access to this resource, or payment is required to proceed.


### `500` — Unexpected server error.

Type: `ApiResponse<T>`

- `success` (boolean) — Always false
- `errors` (ErrorDetail[]) — List of server-side errors
  - `correlationId` (string) — Unique ID for tracing the error
  - `message` (string) — Error message
  - `stack` (string) — Stack trace (non-production only)


## Code Examples

### curl

```curl
curl --request GET \
  --url https://apis-spb.konso.io/ng-cms/media/{projectId}/{mediaId} \
  --header 'Authorization: Bearer <token>'
```

### javascript

```js
const options = {
  method: 'GET',
  headers: { Authorization: 'Bearer <token>' }
};

fetch('https://apis-spb.konso.io/ng-cms/media/{projectId}/{mediaId}', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
```

### dotnet

```dotnet
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", "<token>");

var response = await client.GetAsync("https://apis-spb.konso.io/ng-cms/media/{projectId}/{mediaId}");
var result = await response.Content
    .ReadFromJsonAsync<CmsMediaAssetDto>();
```

### python

```python
import requests

url = "https://apis-spb.konso.io/ng-cms/media/{projectId}/{mediaId}"
headers = { "Authorization": "Bearer <token>" }

response = requests.get(url, headers=headers)
print(response.json())
```

### Response Example (200)

```json
{
  "id": "ma_f1e2d3c4b5a6",
  "projectId": "my-project-id",
  "fileName": "hero.jpg",
  "title": "Hero Image",
  "description": "Main banner image",
  "mimeType": "image/jpeg",
  "sizeBytes": 204800,
  "storageProvider": "s3",
  "storageKey": "hero.jpg",
  "publicUrl": "https://cdn.example.com/my-project-id/hero.jpg",
  "metadata": {},
  "createdBy": 42,
  "createdAt": "2025-05-01T09:00:00Z",
  "updatedAt": null,
  "updatedBy": null,
  "updatedByName": null,
  "publishedAt": null,
  "publishedBy": null
}
```

## Repositories

- [konso-cms-nodejs](https://gitverse.ru/konso/konso-cms-nodejs)
- [konso-cms-dotnet](https://gitverse.ru/konso/konso-cms-dotnet)

## Packages

- `dotnet add package Konso.Clients.Cms` — [Konso.Clients.Cms](https://nugetprodusnc-northcentralus-01.regional.azure-api.net/packages/Konso.Clients.Cms)
- `npm install @konso/cms-client` — [@konso/cms-client](https://www.npmjs.com/package/@konso/cms-client)
