API reference · Contracts

Add Products to the Branch Contract

PUThttps://api.sandbox.cws.digital/pricing/contract/{contractId}/items/store/{partnerId}

Description

Allows a parent account to add products to the contract of one of its branches with the price of each one, or to update the price of those already in it.

Each product is processed independently: the result of each one comes in the status field of the response.

The body and the response are identical to those of the submission for your own store — the difference is the branch that owns the contract, which comes in the route and is validated against the links of your parent account.

items[].value is the legacy name of items[].price and is still accepted, with the same effect. When both are sent in the same item, price applies.

How to identify the product

Each product must carry one of the two forms, in this order of precedence:

FormFieldsWhen to use
By partner codepartnerPartCodeYou identify the product by your own code.
By attributeskuAttributeValue with skuAttributeName in the envelopeYou have contracted the product catalog service with your own attribute.

Unlike the stock submission, different forms can coexist in the same submission: each product is resolved by the form it carries.

Parameters

Path parameters

FieldTypeRequiredDescriptionValue
contractIdintegerYes

Contract id, returned in id on creation.

partnerIdintegerYes

Id of the branch that owns the contract. It must be linked to the token's parent account.

Request body

Content-Typeapplication/jsonRequired
Edit the body with
FieldTypeRequiredDescriptionValue
itemsarray of objectYes

From 1 to 100 products.

Fields in items[]

skuAttributeNamestringConditional

Name of the attribute used to resolve items[].skuAttributeValue. Required when you identify the products by attribute. It applies to the whole submission, not per item.

Items of items[]
items[]
FieldTypeRequiredDescriptionValue
partnerPartCodestringNo

By partner code. You identify the product by your own code. Case-sensitive.

skuAttributeValuestringNo

By attribute, with skuAttributeName in the envelope. You have contracted the product catalog service with your own attribute. Case-sensitive.

pricenumberNo

Product price in the contract. Cannot be negative.

targetMarginnumberNo

Target margin of the product in the contract, from 0 to 100.

totalCostnumberNo

Total cost of the product. Cannot be negative.

priceTypeIdintegerNo

Price type to which this product is restricted within the contract.

Business rules

The product must belong to the store

The product is resolved within the catalog of the store that owns the contract. What does not resolve comes back in notFound.items and the others are stored.

A product repeated in the same submission is not processed

Two products of the same submission that resolve to the same SKU — by the repeated code or by the attribute — both go to notFound.items and neither is stored. Send each product only once per request.

A product rejected by value comes back in the list and does not bring down the submission

Negative price, negative cost, margin outside 0 to 100 and a product without any form of identification are rejected item by item: the product comes back in items with status: ERROR and the reason in error, and the others are stored. The response is 200.

Responses

  • 403

    Branch not linked to your parent account.

Try it

Sandbox

Language

Credentials

Access token: saved in this tab and used on every endpoint.

Each token only reaches the partner's own data and that of the branches with an authorized link.

Don't have sandbox credentials yet? See how to request them

Request

cURL
curl --request PUT \
  --url 'https://api.sandbox.cws.digital/pricing/contract/{contractId}/items/store/{partnerId}' \
  --globoff \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "items": [
    {
      "partnerPartCode": "PRODUTO-TESTE-001",
      "price": 149.9,
      "targetMargin": 18.5,
      "totalCost": 120
    },
    {
      "partnerPartCode": "SKU-B-002",
      "price": 89.9
    }
  ]
}'

Response

Click Try it to see the real response here, or pick a documented example: