Skip to main content

Assign Products to Brand

Assigns one or more products to a brand and updates the brand's product count. A product can belong to only one brand, so this replaces any brand the product had before.

HTTP Request​

  • URL: /brands/assign-products
  • Method: POST
  • Headers:
    • accessToken: Required. Your API access token.
    • Content-Type: application/json
  • Required scope: None. Any valid access token can call this endpoint.

Request Body​

Send a JSON object with the following fields.

FieldTypeRequiredDescription
idStringYesID of the brand.
productIdsArrayYesIDs of the products to assign to the brand.

cURL Example​

curl --location '<BASE_URL>/brands/assign-products' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"id": "663a0f1e4587085935a4fa21",
"productIds": [
"65f1c9a2b7e4d3a1c2f00a11",
"65f1c9a2b7e4d3a1c2f00a12"
]
}'

Response​

  • 200 OK: The products were assigned successfully.
  • 400 Bad Request: The access token is missing or invalid, or the request body is not valid.
  • 404 Not Found: No brand matches the given id.

Sample JSON Response​

{
"success": true,
"message": "Products assigned to brand successfully"
}

Response Details​

FieldTypeDescription
successBooleantrue when the products were assigned.
messageStringConfirmation message.

Notes​

  • Products that are already assigned to this brand are skipped.
  • Product IDs that do not match a product are skipped.