# Thêm ảnh sản phẩm

* API này dùng để thêm ảnh cho sản phẩm từ CDN khác không thuộc Nhanh.vn, thường dùng khi bạn có website riêng và có link ảnh trên website riêng, không upload ảnh lên Nhanh.vn.
* Được thêm tối đa 30 sản phẩm mỗi request, mỗi sản phẩm tối đa 20 ảnh.
* Chú ý:
  * Nhanh.vn sẽ không tải các link ảnh này về Nhanh.vn mà dùng luôn đường dẫn link ảnh bạn bắn sang để hiển thị hoặc đồng bộ đi các chỗ khác.
  * Khi dùng tính năng đồng bộ Facebook Shop, nếu sản phẩm trên Nhanh.vn không có ảnh, nhưng có ảnh (external image) bắn từ API về, Nhanh.vn sẽ dùng external images này để bắn lên Facebook Shop. Facebook yêu cầu ảnh có độ phân giải tối thiếu từ 500 x 500px. Chú ý: Server xử lý ảnh này cần đảm bảo tốc độ ổn định: Tốc độ nhanh, không chặn các tool crawler của Facebook (thường là IP từ United States).

## Request

* Xem các [common request params](/v3/readme.md#request-params)

```curl
curl --location 'https://pos.open.nhanh.vn/v3.0/product/externalimage?appId={{appId}}&businessId={{businessId}}' \
--header 'Authorization: {{accessToken}}' \
--header 'Content-Type: application/json'
--data '[
    {
        "id": 1231278559,
        "mode": "update",
        "images": [
            "https://p16-oec-va.ibyteimg.com/tos-maliva-i-o3syd03w52-us/71e9c892eb054ee6a04594d56aca1055~tplv-o3syd03w52-origin-jpeg.jpeg?dr=15568&from=520841845&idc=maliva&ps=933b5bde&shcp=2c1af732&shp=1f0b6a75&t=555f072d",
            "https://p16-oec-va.ibyteimg.com/tos-maliva-i-o3syd03w52-us/fcc6b45f1ea240f7b52a8c5ec9e902c5~tplv-o3syd03w52-origin-jpeg.jpeg?dr=15568&from=520841845&idc=maliva&ps=933b5bde&shcp=2c1af732&shp=1f0b6a75&t=555f072d"
        ]
    },
    {
        "id": 1231278553,
        "mode": "update",
        "images": [
            "https://p16-oec-va.ibyteimg.com/tos-maliva-i-o3syd03w52-us/71e9c892eb054ee6a04594d56aca1055~tplv-o3syd03w52-origin-jpeg.jpeg?dr=15568&from=520841845&idc=maliva&ps=933b5bde&shcp=2c1af732&shp=1f0b6a75&t=555f072d",
            "https://p16-oec-va.ibyteimg.com/tos-maliva-i-o3syd03w52-us/fcc6b45f1ea240f7b52a8c5ec9e902c5~tplv-o3syd03w52-origin-jpeg.jpeg?dr=15568&from=520841845&idc=maliva&ps=933b5bde&shcp=2c1af732&shp=1f0b6a75&t=555f072d"
        ]
    }
]'
```

* Thông tin sản phẩm

| Key    | Type                         | Description                                                  |
| ------ | ---------------------------- | ------------------------------------------------------------ |
| id     | int $$^{{\color{red}\*}}$$   | ID sản phẩm cẩn thêm ảnh                                     |
| mode   | string                       | update (mặc định), deleteall: Xóa ảnh                        |
| images | array $$^{{\color{red}\*}}$$ | Mảng đường dẫn ảnh (mode = "deleteall" thì không cần truyền) |

## Response

* Xem cấu trúc chung [tại đây](/v3/readme.md#response).

### Failed response

* Xem các mã lỗi chung [tại đây](/v3/readme.md#failed-response).

### Successful response

```json
{
  "code": 1,
  "data": [
    {
      "id": "(int) ID sản phẩm trên Nhanh.vn"
    }
  ]
}
```


---

# 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://apidocs.nhanh.vn/v3/product/externalimage.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.
