**Version: 202201**

# Create Product Image

**POST** `/openapi/2022-01/products/:product_id/images`

Create a new product image with the provided details.

## Request

**Path Parameters**

- `product_id` string (required)

  Product's ID

**application/json**

**Body | Example**

**Body**

- `image` object

  - `position` int32

    The position of the image. Must be greater than 0 if provided.
  - `src` string (required)

    The relative URL of the image.
  - `alt` string

    The alt text of the image.
  - `width` int32

    The width of the image in pixels. Must be greater than 0 if provided.
  - `height` int32

    The height of the image in pixels. Must be greater than 0 if provided.

```json
{
  "image": {
    "position": 0,
    "src": "string",
    "alt": "string",
    "width": 0,
    "height": 0
  }
}
```

## Responses

**200 | 404 | 422**

200

**application/json**

**Schema | Example | Result**

**Schema**

- `image` object

  - `id` string

    **Example:** `91d032e7-bbc8-47e4-8668-9ba6fe714de6`
  - `product_id` string

    **Example:** `636a07da-39eb-4829-bde9-b65fae1c28b0`
  - `position` integer

    **Default value:** `0`

    **Example:** `1`
  - `src` string

    **Example:** `//cdn.shoplazza.com/efd33b921cacd5311a32dd03a9bc8740.png`
  - `width` integer

    **Default value:** `0`

    **Example:** `1588`
  - `height` integer

    **Default value:** `0`

    **Example:** `2246`
  - `alt` string

    **Example:**
  - `created_at` string

    **Example:** `2024-04-08T07:13:28Z`
  - `updated_at` string

    **Example:** `2024-04-08T07:13:28Z`

```json
{
  "image": {
    "id": "91d032e7-bbc8-47e4-8668-9ba6fe714de6",
    "product_id": "636a07da-39eb-4829-bde9-b65fae1c28b0",
    "position": 1,
    "src": "//cdn.shoplazza.com/efd33b921cacd5311a32dd03a9bc8740.png",
    "width": 1588,
    "height": 2246,
    "alt": "",
    "created_at": "2024-04-08T07:13:28Z",
    "updated_at": "2024-04-08T07:13:28Z"
  }
}
```

```json
{
    "image": {
        "id": "91d032e7-bbc8-47e4-8668-9ba6fe714de6",
        "product_id": "636a07da-39eb-4829-bde9-b65fae1c28b0",
        "position": 1,
        "src": "//cdn.shoplazza.com/efd33b921cacd5311a32dd03a9bc8740.png",
        "width": 1588,
        "height": 2246,
        "alt": "",
        "created_at": "2024-04-08T07:13:28Z",
        "updated_at": "2024-04-08T07:13:28Z"
    }
}
```

404

**application/json**

**Schema | Example | Result**

**Schema**

- `errors` string[]

```json
{
  "errors": [
    "Product not found"
  ]
}
```

```json
{
  "errors": [
    "Product not found"
  ]
}
```

422

**application/json**

**Schema | Example | Result**

**Schema**

- `errors` string[]

```json
{
  "errors": [
    "ProductId must be a valid UUID"
  ]
}
```

```json
{
  "errors": [
    "ProductId must be a valid UUID"
  ]
}
```
