---
title: "Attach assets to a listing product"
method: POST
path: "/assets/attachListing"
tags: ["Assets", "Products"]
---

# Attach assets to a listing product

`POST /assets/attachListing`

## Request

- Base URL: `https://api.pics.io`
- URL: `https://api.pics.io/assets/attachListing`
- Auth: HTTP bearer

Attaches one or more assets to a listing product gallery and optionally to multiple listing variants. mode=draft writes DB links only (with validation and draft promotion when needed). mode=publish triggers async Shopify upload via attachProducts flow and requires the listing to already have a live snapshot (listing.live). Accesses MongoDB for products, variants, and assets; publish mode is async.

## Request body

- object
  - `listingId` string, required
  - `assetIds` string[], required
  - `variantIds` string[]
  - `listingGallery` boolean: When true, attaches assets to listing gallery. Defaults to true when variantIds is empty, false otherwise.
  - `mode` 'draft' | 'publish'

## Response `200`

Ok

- object
  - `success` boolean
  - `attachedCount` number
  - `skipped` unknown[]
    - unknown
  - `assetsToProcessCount` number

## Other responses

- `404`: Listing or assets not found
- `409`: mode=publish requires listing.live (listing must already be published)

---

[API](https://skmtc.dev/pics/apis/pics-io-rest-api.md) - [All operations](https://skmtc.dev/pics/apis/pics-io-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/pics/apis/pics-io-rest-api/revisions/ea41cba5ac37?raw)
