> For the complete documentation index, see [llms.txt](https://docs.altura.com/altura-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.altura.com/altura-documentation/api-reference/smart-nft-endpoints/switch-an-items-primary-image.md).

# Switch an Item's Primary Image

This endpoint allows you to change an item's image to one of the other images provided upon mint. This feature may be used to update an item's state (i.e., the image can reflect an item's wear, evolution, type, etc.)

Every item has an `imageIndex` property. This property represents the index of the selected image amongst all the provided images. Every item also has a`imageCount` property that represents the total number of uploaded images.&#x20;

### Update an item's primary image&#x20;

## Updates an item's primary image

<mark style="color:green;">`POST`</mark> `https://api.alturanft.com/api/v2/item/update_primary_image`

Takes an item's collection address, tokenId, the `imageIndex` you want to change to and your API key and updates the item's primary image

#### Query Parameters

| Name                                     | Type   | Description  |
| ---------------------------------------- | ------ | ------------ |
| apiKey<mark style="color:red;">\*</mark> | String | Your API key |

#### Request Body

| Name                                         | Type    | Description                                                                           |
| -------------------------------------------- | ------- | ------------------------------------------------------------------------------------- |
| address<mark style="color:red;">\*</mark>    | String  | The item's collection address                                                         |
| tokenId<mark style="color:red;">\*</mark>    | Integer | The item's tokenId                                                                    |
| imageIndex<mark style="color:red;">\*</mark> | Integer | <p>The index of the image you wish to change to </p><p></p><p>(index starts at 0)</p> |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="500: Internal Server Error " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
`Remember, imageIndex` starts at 0 and **not** 1. Therefore the highest `imageIndex` is `imageCount - 1`
{% endhint %}
