APIで卸売価格を作成する
公開APIで新しい卸売価格ルールを作成する方法です。リクエストボディの全項目リファレンスも掲載しています。
このドキュメントでは、公開APIを使って新しい卸売価格ルールを作成する方法を説明します。
1. エンドポイント
Section titled “1. エンドポイント”新しい卸売価格レコードを作成するには、次のエンドポイントを使用します。
POST - https://wholesale.samita.io/api/v1/wholesale-pricings2. リクエストヘッダー
Section titled “2. リクエストヘッダー”すべてのAPIリクエストに、次の必須ヘッダーを含める必要があります。
| ヘッダー | 説明 | 必須 |
|---|---|---|
X-SAMITA-API-KEY |
Wholesaleアプリで発行されたAPIキー | はい |
X-SAMITA-SHOP-URL |
xxx.myshopify.com形式のShopifyストアドメイン | はい |
CONTENT-TYPE |
application/jsonを指定する必要があります |
はい |
必須ヘッダーが1つでも欠けている場合、リクエストは拒否されます。
3. リクエストボディ
Section titled “3. リクエストボディ”a. 基本フォーマット
Section titled “a. 基本フォーマット”卸売価格の作成に使用するデータは、JSON形式で送信する必要があります。
サンプルのJSON構造は、このドキュメントの末尾に掲載しています。
リクエスト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" }}b. title(必須)
Section titled “b. title(必須)”- 卸売価格レコードを識別するための名前
- 文字列である必要があります
- 最大文字数: 255文字
c. status(必須)
Section titled “c. status(必須)”- レコードが有効かどうかを指定します
- 指定できる値は次のとおりです。
| 値 | 説明 |
|---|---|
true |
価格ルールが有効 |
false |
価格ルールが無効 |
d. apply_customer(必須)
Section titled “d. apply_customer(必須)”この価格ルールの対象となる顧客を指定します。
構造:
"apply_customer": { "type": "all", "tags": []}type
指定できる値(次のいずれか1つのみ):
all– すべての顧客に適用logged– ログイン中の顧客のみに適用non-logged– ゲスト顧客のみに適用customer-tags– 特定のタグを持つ顧客のみに適用
tags
type == customer-tagsの場合にのみ必須- カンマ区切りの配列である必要があります
- 例:
["wholesale","b2b"]
typeがcustomer-tagsでない場合、このフィールドは無視できます。
e. exclude_customer
Section titled “e. exclude_customer”特定の顧客を価格ルールの対象から除外する場合に使用します。
構造:
"exclude_customer": { "type": "none", "tags": []}type
- デフォルト値:
none - 指定できる値:
| 値 | 説明 |
|---|---|
none |
顧客を除外しない |
customer-tags |
タグで顧客を除外する |
tags
type == customer-tagsの場合にのみ必須- カンマ区切りの配列
- 例:
["vip","wholesale"]
f. apply_product(必須)
Section titled “f. apply_product(必須)”価格ルールを適用する商品を指定します。
構造:
"apply_product": { "type": "all", "product_ids": [], "product_tags": [], "collection_ids": [], "apply_for_variants": false}type
指定できる値:
allproductscollectionsproduct-tags
product_ids
type == productsの場合にのみ必須- 商品IDのカンマ区切りリスト
- 例:
[1,2,3]
product_tags
type == product-tagsの場合にのみ必須- 例:
["tag1","tag2"]
collection_ids
type == collectionsの場合にのみ必須- 例:
[1,2,3]
apply_for_variants
- バリエーションごとに割引を設定できるかどうかを指定します
- 指定できる値:
trueまたはfalse - デフォルト値:
false
g. exclude_product
Section titled “g. exclude_product”ルールから除外する商品を指定します。
構造:
"exclude_product": { "type": "none", "product_ids": [], "collection_ids": []}type
- デフォルト:
none - 指定できる値:
| 値 | 説明 |
|---|---|
none |
商品を除外しない |
products |
特定の商品を除外する |
collections |
特定のコレクションを除外する |
その他のフィールドは、選択したtypeに応じて必要な場合にのみ必須となります。
h. discount_for_variants
Section titled “h. discount_for_variants”バリエーションごとに割引を適用する場合に使用します。
apply_product.apply_for_variants == falseの場合は空にする必要がありますapply_product.apply_for_variants == trueの場合は必須
構造の例:
"discount_for_variants": [ { "id": 8516448190631, "variant_pricing": true, "variants": [ { "id": 46747346763943, "discount_groups": [ { "name": "all", "type": "percent", "value": "10" } ] } ] }]構造:
- 商品の配列
- 各商品には次の項目が含まれます。
id– 商品IDvariant_pricing–trueにする必要がありますvariants– バリエーションの配列
各バリエーションには次の項目が含まれます。
id– バリエーションIDdiscount_groups– 割引設定の配列
discount_groupsのルール
apply_customer.typeがall、logged、non-loggedのいずれかの場合:
→ 配列に指定できるのは1件のみですapply_customer.type == customer-tagsの場合:
→ 複数の割引グループを指定できます
discount_groups内のフィールド:
| フィールド | 説明 |
|---|---|
name |
顧客タイプまたは顧客タグと一致する必要があります |
type |
割引タイプ |
value |
割引の値 |
指定できる割引タイプ:
percentamountfixed-amount
値のルール:
- 0より大きい数値である必要があります
- typeが
percentの場合、値は100未満にする必要があります
i. apply_market(必須)
Section titled “i. apply_market(必須)”ルールを適用するShopifyのマーケットを指定します。
構造:
"apply_market": { "type": "all", "handle": []}type
指定できる値:
allspecific-market
handle
type == specific-marketの場合にのみ必須- マーケットハンドルのカンマ区切りリスト
- 例:
["japan","us"]
マーケットハンドルを取得するには、次の手順を行います。
- Shopify管理画面でマーケットセクションに移動し、その他の操作をクリックしてマーケットハンドルを編集を選択し、表示されているハンドルをコピーします。


j. discount_group
Section titled “j. discount_group”バリエーションごとに割引を設定しない場合に使用します。
次の場合に必須です。
apply_product.typeがproductsではない場合、またはapply_product.type == productsで、バリエーションを適用しない場合
構造:
"discount_group": { "type": "percent", "value": "10"}割引タイプと値のルールは、上記と同じです。
k. active_date
Section titled “k. active_date”価格ルールの開始日時と終了日時を設定する場合に使用します。
構造:
"active_date": { "types": ["start_date", "end_date"], "start_at": "2026-01-15 10:00:00", "end_at": "2026-01-15 10:00:00"}types
- 任意
- 指定できる値:
start_date、end_date - 片方または両方をカンマ区切りで指定できます
- 例:
["start_date","end_date"]
start_at
typesにstart_dateが含まれる場合は必須- 形式:
YYYY-MM-DD HH:MM:SS
end_at
typesにend_dateが含まれる場合は必須- 形式:
YYYY-MM-DD HH:MM:SS
4. APIレスポンス
Section titled “4. APIレスポンス”a. エラーレスポンス
Section titled “a. エラーレスポンス”401 – Unauthorized(認証エラー)
考えられる原因:
- ストアURLが指定されていない
- APIキーが指定されていない
- ストアURLが無効
- APIキーが無効
- APIキーがストアと一致しない
403 – This action is unauthorized(この操作は許可されていません)
- APIキーに作成(Create)権限がない
- 各APIキーには、表示(View)、作成(Create)、更新(Update)、削除(Delete)の権限を設定できます
- このAPIにはCreate権限が必要です
- 指定したIDが存在しない場合にも返されます
429 – Too Many Requests(リクエストが多すぎます)
- レート制限を超過しました
- 上限:
| 制限 | 値 |
|---|---|
| リクエスト頻度 | 5分あたり1リクエスト |
| 1日の上限 | 1日あたり50リクエスト |
b. 成功レスポンス
Section titled “b. 成功レスポンス”200 – API Success(成功)
- 卸売価格レコードが正常に作成されました
- レスポンスは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_date", "end_date"], "start_at": "2026-01-15 10:00:00", "end_at": "2026-01-15 10:00:00" }, "created_at": "2026-01-15T10:00:00", "updated_at": "2026-01-15T10:00:00"}