# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.altura.com/altura-documentation/api-reference/smart-nft-endpoints/switch-an-items-primary-image.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
