# Update a media asset

_NgCms / Media Assets_

`PUT /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 to update

## Request Body

### `UpdateMediaRequest`

- `title` (string, optional) — Human-readable title for the asset
- `description` (string, optional) — Optional description of the asset

## Responses

### `200` — Media asset updated successfully.

Type: `ApiResponse<boolean>`

- `success` (boolean) — Indicates whether the request was successful
- `result` (boolean) — Always true on success
- `errors` (ErrorDetail[]) — List of errors (empty on success)

### `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 PUT \
  --url https://apis-spb.konso.io/ng-cms/media/{projectId}/{mediaId} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "title": "Updated Hero Image",
  "description": "Refreshed banner for the homepage"
}'
```

### javascript

```js
const options = {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    title: 'Updated Hero Image',
    description: 'Refreshed banner for the homepage'
  })
};

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 request = new UpdateMediaRequest
{
    Title       = "Updated Hero Image",
    Description = "Refreshed banner for the homepage"
};

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

### python

```python
import requests

url = "https://apis-spb.konso.io/ng-cms/media/{projectId}/{mediaId}"
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}
payload = {
    "title": "Updated Hero Image",
    "description": "Refreshed banner for the homepage"
}

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

### Request Body Example

```json
{
  "projectId": "example-string",
  "mediaId": "example-string"
}
```

### Response Example (200)

```json
{
  "success": true,
  "result": true,
  "errors": []
}
```

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