# Switch an Item's Primary Image

Use this method to update an item's primary image.&#x20;

### Usage in your script

{% tabs %}
{% tab title="First Tab" %}

```javascript
const updatedItem = await alturaItem.updatePrimaryImage(IMAGE_INDEX);
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
const updatedItem IAlturaItem = await alturaItem.updatePrimaryImage(IMAGE_INDEX);
```

{% endtab %}
{% endtabs %}

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

### **Parameters**

<table><thead><tr><th width="141.33333333333331">Parameter</th><th width="88">Type</th><th width="109">Required</th><th>Description</th></tr></thead><tbody><tr><td>imageIndex</td><td>Integer</td><td><strong>Yes</strong></td><td>The index of the image you wish to change to</td></tr></tbody></table>


---

# 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/js-sdk-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.
