# Updating assets

This API reference document contains information on updating assets

Since assets are a system model, and automatically added to every project, you can extend them with your own custom fields.

These fields can be updated using GraphQL mutations. 

**Webhooks & asset updates:**

Make sure you read our [webhooks documentation](https://hygraph.com/docs/api-reference/basics/webhooks#webhooks-and-assets) to understand how they work with the Hygraph Asset Management System.

## Update metadata

In the following example, we have added `altText` and `caption` fields to our **Assets** model. Here, we are using an `updateAsset` mutation to change the text in them:

  **Mutation**

```graphql
mutation {
  updateAsset(
    where: {id: "<YOUR_ASSET_ID>"}
    data: {caption: "this is a new caption", altText: "this is new alternative text"}
  ) {
    id
  }
}
```

  
  **Response**

```graphql
{
  "data": {
    "updateAsset": {
      "id": "<YOUR_ASSET_ID>"
    }
  }
}
```


After successfully running this mutation, if you access your asset in edit mode, you will see the new `altText` and `caption`.

Learn more about [Mutations](https://hygraph.com/docs/api-reference/content-api/mutations#update-entries).

## Update existing asset

The Hygraph Asset Management System offers a way to update an existing asset entry and reuploading a new file for it.

To do this, there is a route to do a file upload, or a remote URL upload.

### Update via remote URL

Use `reUpload: true` as follows:

```graphql
mutation test {
  updateAsset(
    where: {id: "<YOUR_ASSET_ID>"}
    data: {reUpload: true, uploadUrl: "<NEW_ASSET_URL>"}
  ) {
    id
    upload {
      status
      expiresAt
      error {
        code
        message
      }
    }
  }
}
```

### Update via file upload

To update an asset via file upload you need to follow the [asset upload async process](https://hygraph.com/docs/api-reference/assets/uploading-assets#upload-by-file), with the data you get from `requestPostData` to send the local file to S3.

Use `reUpload: true` as follows:

```graphql
mutation test {
  updateAsset(where: {id: "<YOUR_ASSET_ID>"}, data: {reUpload: true}) {
    id
    upload {
      status
      expiresAt
      error {
        code
        message
      }
      requestPostData {
        url
        date
        key
        signature
        algorithm
        policy
        credential
        securityToken
      }
    }
  }
}
```
