Uppdatera/redigera Wholesale Pricing med API:er
Uppdatera en befintlig Wholesale Pricing-regel via det publika API:et, med fullständig referens för request body.
Det här dokumentet förklarar hur du uppdaterar en befintlig Wholesale Pricing-regel med det publika API:et.
1. Endpoint
Section titled “1. Endpoint”Använd följande endpoint för att uppdatera en befintlig Wholesale Pricing-post:
PUT https://wholesale.samita.io/api/v1/wholesale-pricings/{id}{id}är ID:t för Wholesale Pricing-posten- ID:t finns i appens gränssnitt (utan tecknet ”#”)
- Exempel:

Exempel:
Section titled “Exempel:”PUT https://wholesale.samita.io/api/v1/wholesale-pricings/12. Request headers
Section titled “2. Request headers”Alla API-anrop måste innehålla följande obligatoriska headers:
| Header | Beskrivning | Obligatorisk |
|---|---|---|
X-SAMITA-API-KEY |
API-nyckel från Wholesale-appen | Ja |
X-SAMITA-SHOP-URL |
Shopify-butikens domän i formatet xxx.myshopify.com | Ja |
CONTENT-TYPE |
Måste vara application/json |
Ja |
Om en obligatorisk header saknas avvisas anropet.
3. Request body
Section titled “3. Request body”_ Data för att uppdatera Wholesale Pricing måste skickas i JSON-format. Ett exempel på JSON-struktur finns i slutet av det här dokumentet.
_ Endast de fält som ska uppdateras behöver skickas i anropet. Det är inte obligatoriskt att skicka alla fält, som i Create-API-metoden.
_ Fält som inte anges förblir oförändrade
Exempel på request-JSON:
{ "title": "New Wholesale Pricing", "status": true, "apply_customer": { "type": "all", "tags": [] }, "exclude_customer": { "type": "none", "tags": [] }, "apply_product": { "type": "all", "product_ids": [], "product_tags": [], "collection_ids": [], "apply_for_variants": false }, "exclude_product": { "type": "none", "product_ids": [], "collection_ids": [] }, "discount_for_variants": [ { "id": 8516448190631, "variant_pricing": true, "variants": [ { "id": 46747346763943, "discount_groups": [ { "name": "all", "type": "percent", "value": "10" } ] } ] } ], "apply_market": { "type": "all", "handle": [] }, "discount_group": { "type": "percent", "value": "10" }, "active_date": { "types": ["start_date", "end_date"], "start_at": "2026-01-15 10:00:00", "end_at": "2026-01-15 10:00:00" }}c. title
Section titled “c. title”- Namnet som identifierar Wholesale Pricing-posten
- Valfritt i Update-API:et
- Måste vara en sträng
- Maximal längd: 255 tecken
d. status
Section titled “d. status”- Anger om posten är aktiv eller inte
- Valfritt i Update-API:et
- Accepterar endast följande värden:
| Värde | Beskrivning |
|---|---|
true |
Prissättningsregeln är aktiv |
false |
Prissättningsregeln är inaktiv |
e. apply_customer
Section titled “e. apply_customer”Anger vilka kunder som omfattas av prissättningsregeln.
Struktur:
"apply_customer": { "type": "all", "tags": []}type
Accepterade värden:
allloggednon-loggedcustomer-tags
tags
- Krävs endast när
type == customer-tags - Måste vara en array med kommaseparerade värden
- Exempel:
["wholesale","b2b"]
f. exclude_customer
Section titled “f. exclude_customer”Används för att utesluta vissa kunder från prissättningsregeln.
Struktur:
"exclude_customer": { "type": "none", "tags": []}type
- Standardvärde:
none - Accepterade värden:
| Värde | Beskrivning |
|---|---|
none |
Uteslut inga kunder |
customer-tags |
Uteslut kunder utifrån taggar |
tags
- Krävs endast när
type == customer-tags - Exempel:
["vip","wholesale"]
g. apply_product (obligatoriskt)
Section titled “g. apply_product (obligatoriskt)”Anger vilka produkter prissättningsregeln tillämpas på.
Struktur:
"apply_product": { "type": "all", "product_ids": [], "product_tags": [], "collection_ids": [], "apply_for_variants": false}type
Accepterade värden:
allproductscollectionsproduct-tags
Övriga fält krävs beroende på vald typ:
product_ids→ krävs omtype == productsproduct_tags→ krävs omtype == product-tagscollection_ids→ krävs omtype == collections
apply_for_variants
- Accepterade värden:
trueellerfalse - Standardvärde:
false
h. exclude_product
Section titled “h. exclude_product”Anger produkter som ska uteslutas från regeln.
Struktur:
"exclude_product": { "type": "none", "product_ids": [], "collection_ids": []}Accepterade typer:
noneproductscollections
i. discount_for_variants
Section titled “i. discount_for_variants”Används när rabatter ställs in per variant.
- Måste vara tom om
apply_product.apply_for_variants == false - Krävs när
apply_product.apply_for_variants == true
Exempelstruktur:
"discount_for_variants": [
{
"id": 8516448190631,
"variant_pricing": true,
"variants": [
{
"id": 46747346763943,
"discount_groups": [
{
"name": "all",
"type": "percent",
"value": "10"
}
]
}
]
}
]
Struktur:
- Array med produkter
- Varje produkt innehåller:
id– produkt-IDvariant_pricing– måste varatruevariants– array med varianter
Varje variant innehåller:
id– variant-IDdiscount_groups– array med rabattkonfigurationer
Regler för discount_groups
- Om
apply_customer.typeärall,loggedellernon-logged
→ Endast ett objekt tillåts - Om
apply_customer.type == customer-tags
→ Flera rabattgrupper kan anges
Fält i discount_groups:
| Fält | Beskrivning |
|---|---|
name |
Måste matcha kundtyp eller kundtagg |
type |
Rabattyp |
value |
Rabattvärde |
Accepterade rabattyper:
percentamountfixed-amount
Regler för värdet:
- Måste vara ett tal större än 0
- Om typen är
percentmåste värdet vara lägre än 100
j. apply_market (obligatoriskt)
Section titled “j. apply_market (obligatoriskt)”Anger vilka Shopify-marknader regeln gäller för.
Struktur:
"apply_market": { "type": "all", "handle": []}type
Accepterade värden:
allspecific-market
handle
- Krävs endast när
type == specific-market - Kommaseparerad lista med marknadshandles
- Exempel:
["japan","us"]
k. discount_group
Section titled “k. discount_group”Används när rabatten inte ställs in per variant.
Krävs när:
apply_product.typeinte ärproducts, ELLERapply_product.type == productsOCH varianter inte tillämpas
Struktur:
"discount_group": { "type": "percent", "value": "10"}Regler:
typemåste vara något av:percentamountfixed-amount
value- Måste vara större än 0
- Om typen är
percentmåste värdet vara lägre än 100
l. active_date
Section titled “l. active_date”Används för att ställa in start- och sluttid för prissättningsregeln.
Struktur:
"active_date": { "types": ["start_date", "end_date"], "start_at": "2026-01-15T10:00:00", "end_at": "2026-01-15T10:00:00"}types
- Valfritt
- Accepterade värden:
start_date,end_date - Exempel:
["start_date","end_date"]
start_at
- Krävs om
typesinnehållerstart_date - Format:
YYYY-MM-DD HH:MM:SS
end_at
- Krävs om
typesinnehållerend_date - Format:
YYYY-MM-DD HH:MM:SS
4. API-svar
Section titled “4. API-svar”a. Felsvar
Section titled “a. Felsvar”401 – Unauthorized
Möjliga orsaker:
- Butikens URL saknas
- API-nyckel saknas
- Ogiltig butiks-URL
- Ogiltig API-nyckel
- API-nyckeln matchar inte butiken
403 – This action is unauthorized
- API-nyckeln saknar behörigheten Update
- Varje API-nyckel kan ha behörigheterna View, Create, Update och Delete
- Det här API:et kräver behörigheten Update
- Returneras även när det angivna ID:t inte finns
429 – Too Many Requests
Gränsen för antal anrop har överskridits:
- Högst 1 anrop per 5 minuter
- Högst 50 anrop per dag
b. Lyckat svar
Section titled “b. Lyckat svar”200 – API Success
- Wholesale Pricing-posten uppdaterades
- Svaret returneras i JSON-format
Exempel på svars-JSON:
{ "id": 1, "title": "New Wholesale Pricing", "status": true, "apply_customer": { "type": "all", "tags": [] }, "exclude_customer": { "type": "none", "tags": [] }, "apply_product": { "type": "all", "product_ids": [], "product_tags": [], "collection_ids": [], "apply_for_variants": false }, "exclude_product": { "type": "none", "product_ids": [], "collection_ids": [] }, "discount_for_variants": [ { "id": 8516448190631, "variant_pricing": true, "variants": [ { "id": 46747346763943, "discount_groups": [ { "name": "all", "type": "percent", "value": "10" } ] } ] } ], "apply_market": { "type": "all", "handle": [] }, "discount_group": { "type": "percent", "value": "10" }, "active_date": { "types": [], "start_at": "", "end_at": "" }, "created_at": "2026-01-15T10:00:00", "updated_at": "2026-01-15T10:00:00"}