---
title: Link variants to a product.
slug: api-documentation/link-variants-to-a-product
docTags: 
createdAt: 2026-08-27T17:00:05.343Z
---

{
  "id": "q6tUfRFG_aOYOsrxHl762",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.upstartcommerce.com/pim/products/{id}/link-variants",
    "servers": [
      {
        "url": "https://api.upstartcommerce.com/pim/products/{id}/link-variants"
      }
    ],
    "name": "Link variants to a product.",
    "description": "<p>This allows admins to link variants to a product using the productId in the path and the variant ids in the payload. The product is read from draft first (product_item_v2) and, when it is not present there, from the published version (product_item_live_v2). The provided variant ids are appended to the product's existing variants and the standard update-product flow is then triggered. If the product is not available in draft or in live an error is returned.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "description": "",
          "schema": [
            {
              "name": "variantIds",
              "kind": "required",
              "type": "array",
              "description": "<p>List of variant ids to be linked (appended) to the product identified by the path productId.</p>",
              "example": "",
              "itemType": "string",
              "customType": "string[]",
              "itemExample": "",
              "itemDefault": ""
            }
          ],
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "NoChannelPortalAccess",
          "name": "NoChannelPortalAccess",
          "kind": "optional",
          "type": "http",
          "description": "<p>(DEPRECATED) This authentication is required for clients to interact with any of the management APIs. Similar to 'LoggedIn', it indicates that the user has actually logged into the system, but in this case with a management role.</p>",
          "scheme": "bearer"
        },
        {
          "id": "ApiKeyAccess",
          "name": "X-Upstart-Api-Key",
          "kind": "optional",
          "type": "apiKey",
          "description": "Api key based authorization.",
          "in": "header"
        },
        {
          "id": "SessionIdAccess",
          "name": "X-Upstart-Session-Id",
          "kind": "optional",
          "type": "apiKey",
          "description": "<p>Session based authorization. This authentication is required for clients to interact with any of the management APIs. Similar to 'LoggedIn', it indicates that the user has actually logged into the system, but in this case with a management role.</p>",
          "in": "header"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "All requested variants were successfully linked to the product.",
        "jsonExample": "",
        "isExpanded": true,
        "headers": [
          {
            "kind": "optional",
            "name": "Allow",
            "description": ""
          },
          {
            "kind": "optional",
            "name": "Cache-Control",
            "description": ""
          },
          {
            "kind": "optional",
            "name": "Content-Type",
            "description": ""
          },
          {
            "kind": "optional",
            "name": "ETag",
            "description": ""
          },
          {
            "kind": "optional",
            "name": "Location",
            "description": ""
          }
        ],
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "schema": [],
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "207",
        "description": "<p>Partial success. Some variants were linked while others failed (for example a variant that is already associated to the product). The response body reports the per-variant status.</p>",
        "jsonExample": "",
        "isExpanded": true,
        "headers": [
          {
            "kind": "optional",
            "name": "Allow",
            "description": ""
          },
          {
            "kind": "optional",
            "name": "Cache-Control",
            "description": ""
          },
          {
            "kind": "optional",
            "name": "Content-Type",
            "description": ""
          },
          {
            "kind": "optional",
            "name": "ETag",
            "description": ""
          }
        ],
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "schema": [],
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "BiDlnb5LtzPBd0PWf_zdA",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.upstartcommerce.com/pim/products/{id}/link-variants \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"variantIds\": []\n     }'"
        },
        {
          "id": "OO4NQHq4hiA787YpaXoBz",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"variantIds\": []\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.upstartcommerce.com/pim/products/{id}/link-variants\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "d-bFlZgRNlUfJ0XI_Rv-b",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.upstartcommerce.com/pim/products/{id}/link-variants\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"variantIds\": []\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "6ugeCWmKquMUyxro_N5OX",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.upstartcommerce.com/pim/products/{id}/link-variants\"\n\npayload = json.dumps({\n   \"variantIds\": []\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "BiDlnb5LtzPBd0PWf_zdA"
    },
    "results": {
      "languages": [
        {
          "id": "_wm4lqmHT9-oDi9FQ_kDs",
          "language": "200",
          "code": "// All requested variants were successfully linked to the product.\n{}"
        },
        {
          "id": "8-X47Z2UqwqfvLnI1C0Qo",
          "language": "207",
          "code": "// Partial success. Some variants were linked while others failed (for example a variant that is already associated to the product). The response body reports the per-variant status.\n{}"
        }
      ],
      "selectedLanguageId": "_wm4lqmHT9-oDi9FQ_kDs"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}