> ## Documentation Index
> Fetch the complete documentation index at: https://docs.appcharge.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Product

> Updates a product.

```bash Update Product with Asset ID theme={"system"}
curl -X PUT \
  'https://api.appcharge.com/components/v1/product/gold_coins_100' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-publisher-token: <x-publisher-token>' \
  --data '{
    "name": "Premium Gold Coins Pack",
    "displayName": "Premium Gold Coins",
    "publisherProductId": "gold_coins_100",
    "type": "Quantity",
    "textFontColorHex": "#d4af37",
    "productImageId": "507f1f77bcf86cd799439011"
  }'
```

```bash Update Product with Image URL theme={"system"}
curl -X PUT \
  'https://api.appcharge.com/components/v1/product/gold_coins_100' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-publisher-token: <x-publisher-token>' \
  --data '{
    "name": "Premium Gold Coins Pack",
    "displayName": "Premium Gold Coins",
    "publisherProductId": "gold_coins_100",
    "type": "Quantity",
    "textFontColorHex": "#d4af37",
    "productImageUrl": "https://media.appcharge.com/media/69133d595af23405d8e843a5"
  }'
```

```json Update Product with Asset ID theme={"system"}
{
  "id": "507f1f77bcf86cd799439015",
  "name": "Premium Gold Coins Pack",
  "displayName": "Premium Gold Coins",
  "publisherProductId": "gold_coins_100",
  "type": "Quantity",
  "description": "A pack of 100 gold coins.",
  "prefix": "Get",
  "suffix": "coins",
  "textFontColorHex": "#d4af37",
  "productImageId": "507f1f77bcf86cd799439011",
  "productImageUrl": "https://media.appcharge.com/media/69133d595af23405d8e843a5",
  "productPrefixImageUrl": "https://media.appcharge.com/product-prefix1.png"
}
```

```json Update Product with Image URL theme={"system"}
{
  "id": "507f1f77bcf86cd799439015",
  "name": "Premium Gold Coins Pack",
  "displayName": "Premium Gold Coins",
  "publisherProductId": "gold_coins_100",
  "type": "Quantity",
  "description": "A pack of 100 gold coins.",
  "prefix": "Get",
  "suffix": "coins",
  "textFontColorHex": "#d4af37",
  "productImageId": "507f1f77bcf86cd799439023",
  "productImageUrl": "https://media.appcharge.com/media/69133d595af23405d8e843a5",
  "productPrefixImageUrl": "https://media.appcharge.com/product-prefix1.png"
}
```


## OpenAPI

````yaml openapi-products-api.json PUT /components/v1/product/{externalId}
openapi: 3.0.3
info:
  title: Products API
  version: 1.0.0
servers:
  - url: https://api-sandbox.appcharge.com
security:
  - PublisherTokenAuth: []
tags:
  - name: Products
paths:
  /components/v1/product/{externalId}:
    parameters:
      - in: path
        name: externalId
        required: true
        schema:
          type: string
          example: gold_coins_pack
        description: External ID that you defined.
    put:
      tags:
        - Products
      description: >-
        Updates a product.


        To change the product image, provide `productImageId` or
        `productImageUrl`. If both are provided, `productImageId` takes
        precedence and no new asset is created.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductUpdate'
            examples:
              reuseViaAssetId:
                summary: Reuse existing asset
                value:
                  name: Premium Gold Coins Pack
                  displayName: Premium Gold Coins
                  publisherProductId: gold_coins_100
                  type: Quantity
                  textFontColorHex: '#d4af37'
                  productImageId: 507f1f77bcf86cd799439011
              createViaUrl:
                summary: Create asset from URL
                value:
                  name: Premium Gold Coins Pack
                  displayName: Premium Gold Coins
                  publisherProductId: gold_coins_100
                  type: Quantity
                  textFontColorHex: '#d4af37'
                  productImageUrl: https://media.appcharge.com/media/69133d595af23405d8e843a5
      responses:
        '200':
          description: Product updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductResponse'
        '400':
          description: >-
            Bad request. Invalid input or validation failure. Returned when the
            asset ID isn't found or isn't of type `product`.
        '404':
          description: Product not found.
components:
  schemas:
    ProductUpdate:
      type: object
      properties:
        name:
          type: string
          description: Product name.
          example: Premium Gold Coins Pack
        displayName:
          type: string
          description: Product display name.
          example: Premium Gold Coins
        publisherProductId:
          type: string
          description: Product ID that you define
          example: gold_coins_100
        type:
          type: string
          enum:
            - Quantity
            - Time
          description: Product unit type.
          example: Quantity
        prefix:
          type: string
          description: Product prefix text.
          example: Get
        suffix:
          type: string
          description: Product suffix text.
          example: premium coins
        textFontColorHex:
          type: string
          pattern: ^#[0-9a-fA-F]{6}$
          description: Product text font color in hex format.
          example: '#d4af37'
        productImageId:
          type: string
          description: >-
            Asset ID of an existing product image in the [Assets
            Library](/../../api-reference/media/assets-library/introduction).
            Must reference an asset of type `product`. Reuses the existing asset
            without creating a duplicate.
          example: 507f1f77bcf86cd799439011
        productImageUrl:
          type: string
          format: url
          description: >-
            Product image URL in PNG or JPEG format. Creates a new asset from
            the URL.


            For uploaded files, this is the Appcharge-hosted CDN URL. For
            external image URLs, this is the original image URL served from the
            provided URL. External image URLs are saved and used as-is, and
            Appcharge doesn't download, copy, upload, or host them. Images must
            remain available at the provided URLs.


            We recommend uploading image files instead of using external URLs
            when possible.
          example: https://media.appcharge.com/media/69133d595af23405d8e843a5
        productPrefixImageUrl:
          type: string
          format: url
          description: >-
            Product prefix image URL in PNG or JPEG format.


            For uploaded files, this is the Appcharge-hosted CDN URL. For
            external image URLs, this is the original image URL served from the
            provided URL. External image URLs are saved and used as-is, and
            Appcharge doesn't download, copy, upload, or host them. Images must
            remain available at the provided URLs.


            We recommend uploading image files instead of using external URLs
            when possible.
          example: https://media.appcharge.com/media/69133d595af23405d8e843a5
    ProductResponse:
      type: object
      properties:
        id:
          type: string
          description: Product ID.
          example: 507f1f77bcf86cd799439015
        name:
          type: string
          description: Product name.
          example: Gold Coins Pack
        displayName:
          type: string
          description: Product display name.
          example: Gold Coins
        publisherProductId:
          type: string
          description: Product ID that you defined.
          example: gold_coins_100
        type:
          type: string
          enum:
            - Quantity
            - Time
          description: Product unit type.
          example: Quantity
        description:
          type: string
          description: Product description.
          example: A pack of 100 gold coins.
        prefix:
          type: string
          description: Product prefix text.
          example: Get
        suffix:
          type: string
          description: Product suffix text.
          example: coins
        textFontColorHex:
          type: string
          pattern: ^#[0-9a-fA-F]{6}$
          description: Product text font color in hex format.
          example: '#f5c518'
        productImageId:
          type: string
          description: >-
            Asset ID of the product image. Save this value to reuse the same
            asset in future create or update requests.
          example: 507f1f77bcf86cd799439011
        productImageUrl:
          type: string
          format: url
          description: >-
            Product image URL. For uploaded files, this is the Appcharge-hosted
            CDN URL. For external image URLs, this is the original image URL
            served from the provided URL.
          example: https://media.appcharge.com/media/69133d595af23405d8e843a5
        productPrefixImageUrl:
          type: string
          format: url
          description: >-
            Product prefix image URL. For uploaded files, this is the
            Appcharge-hosted CDN URL. For external image URLs, this is the
            original image URL served from the provided URL.
          example: https://media.appcharge.com/media/69133d595af23405d8e843a5
        productImageExternalUrl:
          type: string
          format: url
          description: >-
            Original product image URL when the product uses an external image
            URL. This URL is used as provided to serve the image.
          example: https://images.pexels.com/photos/35406321/pexels-photo-35406321.jpeg
  securitySchemes:
    PublisherTokenAuth:
      type: apiKey
      in: header
      name: x-publisher-token
      description: Publisher token, as displayed in the Publisher Dashboard.

````