> ## Documentation Index
> Fetch the complete documentation index at: https://docs.waffo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# ストアの作成

> 認証済みマーチャント用の新しいストアを作成する

認証済みマーチャント用の新しいストアを作成します。ストアスラッグは名前から自動生成され、JSONB 設定フィールド（`notificationSettings`、`checkoutSettings`）はデフォルト値で初期化されます。Webhook は [`add-webhook`](/ja/api-reference/endpoints/webhooks/add-webhook) で個別に管理されます -- 新規作成されたストアには Webhook レコードが存在しません。

```
POST /v1/actions/store/create-store
```

**認証：** API Key

## リクエストボディ

| フィールド  | 型      | 必須  | 説明                  |
| ------ | ------ | --- | ------------------- |
| `name` | string | Yes | ストア名（1-48 文字、自動トリム） |

## リクエスト例

<CodeGroup>
  ```typescript SDK theme={"system"}
  import { WaffoPancake } from "@waffo/pancake-ts";

  const client = new WaffoPancake({
    merchantId: process.env.WAFFO_MERCHANT_ID!,
    privateKey: process.env.WAFFO_PRIVATE_KEY!,
  });

  const { store } = await client.stores.create({ name: "My Digital Store" });
  console.log(store.id);   // => "STO_2aUyqjCzEIiEcYMKj7TZtw"
  console.log(store.slug); // => "my-digital-store-a1b2c3"
  ```

  ```typescript TypeScript (fetch) theme={"system"}
  // Uses callApi() helper from authentication.mdx
  const result = await callApi("POST", "/v1/actions/store/create-store", {
    name: "My Digital Store",
  });
  console.log(result.data.store.id);   // => "STO_2aUyqjCzEIiEcYMKj7TZtw"
  console.log(result.data.store.slug); // => "my-digital-store-a1b2c3"
  ```

  ```java Java theme={"system"}
  // Uses callApi() helper from authentication.mdx
  String body = """
      {"name":"My Digital Store"}""";

  String response = callApi("POST", "/v1/actions/store/create-store", body);
  System.out.println(response);
  // => {"data":{"store":{"id":"STO_2aUyqjCzEIiEcYMKj7TZtw","slug":"my-digital-store-a1b2c3",...}}}
  ```

  ```python Python theme={"system"}
  # Uses call_api() helper from authentication.mdx
  result = call_api("POST", "/v1/actions/store/create-store", {
      "name": "My Digital Store",
  })
  store = result["data"]["store"]
  print(store["id"])    # => "STO_2aUyqjCzEIiEcYMKj7TZtw"
  print(store["slug"])  # => "my-digital-store-a1b2c3"
  ```

  ```go Go theme={"system"}
  // Uses callAPI() helper from authentication.mdx
  body := map[string]interface{}{
      "name": "My Digital Store",
  }
  result, err := callAPI("POST", "/v1/actions/store/create-store", body)
  if err != nil {
      log.Fatal(err)
  }
  fmt.Println(string(result))
  // => {"data":{"store":{"id":"STO_2aUyqjCzEIiEcYMKj7TZtw","slug":"my-digital-store-a1b2c3",...}}}
  ```

  ```rust Rust theme={"system"}
  // Uses call_api() helper from authentication.mdx
  let body = serde_json::json!({
      "name": "My Digital Store"
  });
  let result = call_api("POST", "/v1/actions/store/create-store", &body).await?;
  println!("{}", result);
  // => {"data":{"store":{"id":"STO_2aUyqjCzEIiEcYMKj7TZtw","slug":"my-digital-store-a1b2c3",...}}}
  ```

  ```c C theme={"system"}
  /* Uses call_api() helper from authentication.mdx */
  const char *body = "{\"name\":\"My Digital Store\"}";
  char *response = call_api("POST", "/v1/actions/store/create-store", body);
  printf("%s\n", response);
  free(response);
  ```

  ```cpp C++ theme={"system"}
  // Uses callApi() helper from authentication.mdx
  std::string body = R"({"name":"My Digital Store"})";
  std::string response = callApi("POST", "/v1/actions/store/create-store", body);
  std::cout << response << std::endl;
  // => {"data":{"store":{"id":"STO_2aUyqjCzEIiEcYMKj7TZtw","slug":"my-digital-store-a1b2c3",...}}}
  ```

  ```bash cURL theme={"system"}
  MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
  TIMESTAMP=$(date +%s)
  BODY='{"name":"My Digital Store"}'
  BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
  CANONICAL_REQUEST="POST
  /v1/actions/store/create-store
  $TIMESTAMP
  $BODY_HASH"

  SIGNATURE=$(echo -n "$CANONICAL_REQUEST" | openssl dgst -sha256 -sign private_key.pem | base64 -w 0)

  curl -X POST "https://api.waffo.ai/v1/actions/store/create-store" \
    -H "Content-Type: application/json" \
    -H "X-Merchant-Id: $MERCHANT_ID" \
    -H "X-Timestamp: $TIMESTAMP" \
    -H "X-Signature: $SIGNATURE" \
    -d "$BODY"
  ```

  ```bash wget theme={"system"}
  MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
  TIMESTAMP=$(date +%s)
  BODY='{"name":"My Digital Store"}'
  BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
  CANONICAL_REQUEST="POST
  /v1/actions/store/create-store
  $TIMESTAMP
  $BODY_HASH"

  SIGNATURE=$(echo -n "$CANONICAL_REQUEST" | openssl dgst -sha256 -sign private_key.pem | base64 -w 0)

  wget -qO- "https://api.waffo.ai/v1/actions/store/create-store" \
    --header="Content-Type: application/json" \
    --header="X-Merchant-Id: $MERCHANT_ID" \
    --header="X-Timestamp: $TIMESTAMP" \
    --header="X-Signature: $SIGNATURE" \
    --post-data="$BODY"
  ```
</CodeGroup>

## 成功レスポンス (200)

```json theme={"system"}
{
  "data": {
    "store": {
      "id": "STO_2aUyqjCzEIiEcYMKj7TZtw",
      "name": "My Digital Store",
      "status": "active",
      "logo": null,
      "supportEmail": null,
      "website": null,
      "slug": "my-digital-store-a1b2c3",
      "prodEnabled": false,
      "notificationSettings": {
        "emailOrderConfirmation": true,
        "emailSubscriptionConfirmation": true,
        "emailSubscriptionCycled": true,
        "emailSubscriptionCanceled": true,
        "emailSubscriptionRevoked": true,
        "emailSubscriptionPastDue": true,
        "notifyNewOrders": true,
        "notifyNewSubscriptions": true
      },
      "checkoutSettings": {
        "defaultDarkMode": false,
        "light": {
          "checkoutLogo": null,
          "checkoutColorPrimary": "#000000",
          "checkoutColorBackground": "#FFFFFF",
          "checkoutColorCard": "#F5F5F5",
          "checkoutColorText": "#1A1A1A",
          "checkoutBorderRadius": "8px"
        },
        "dark": {
          "checkoutLogo": null,
          "checkoutColorPrimary": "#FFFFFF",
          "checkoutColorBackground": "#1A1A1A",
          "checkoutColorCard": "#2A2A2A",
          "checkoutColorText": "#F5F5F5",
          "checkoutBorderRadius": "8px"
        }
      },
      "deletedAt": null,
      "createdAt": "2026-01-15T10:30:00.000Z",
      "updatedAt": "2026-01-15T10:30:00.000Z"
    }
  }
}
```

## レスポンスフィールド

| フィールド                  | 型              | 説明                                                                                               |
| ---------------------- | -------------- | ------------------------------------------------------------------------------------------------ |
| `id`                   | string         | Store ID（Short ID フォーマット `STO_xxx`）                                                              |
| `name`                 | string         | ストア表示名                                                                                           |
| `status`               | string         | ストアステータス（`active`、`inactive`、または `suspended`）                                                    |
| `logo`                 | string \| null | ストアロゴ URL                                                                                        |
| `supportEmail`         | string \| null | サポートメールアドレス                                                                                      |
| `website`              | string \| null | ストアウェブサイト URL                                                                                    |
| `slug`                 | string \| null | 自動生成された URL スラッグ                                                                                 |
| `prodEnabled`          | boolean        | 本番モードが有効かどうか                                                                                     |
| `notificationSettings` | object \| null | 通知設定（[通知設定](/ja/api-reference/endpoints/stores/update-store#notification-settings)を参照）           |
| `checkoutSettings`     | object \| null | チェックアウトページテーマ（[チェックアウト設定](/ja/api-reference/endpoints/stores/update-store#checkout-settings)を参照） |
| `deletedAt`            | string \| null | 論理削除タイムスタンプ（ISO 8601）、アクティブの場合 `null`                                                            |
| `createdAt`            | string         | 作成タイムスタンプ（ISO 8601）                                                                              |
| `updatedAt`            | string         | 最終更新タイムスタンプ（ISO 8601）                                                                            |

## エラー

> **リトライポリシー**：4xx は一切リトライしない — リクエストを修正してから再送信。5xx は指数バックオフでリトライ（5s 開始、最大 3 回）。

| ステータス | `errors[0].message`                                                                    | 意味                             | 推奨処理                                  |
| ----- | -------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------- |
| 400   | `Missing merchantId in request context`                                                | API Key がマーチャントコンテキストを解決できなかった | **リトライしない**。API Key 設定を確認。            |
| 400   | `Missing required field: name`                                                         | リクエストボディに `name` が含まれていない      | 入力を修正して再送信。                           |
| 400   | `Store name cannot be empty or contain only whitespace`                                | `trim()` 後の `name` が空          | 入力を修正して再送信。                           |
| 400   | `Store name cannot exceed 48 characters`                                               | `name` が 48 文字を超える             | 名前を短縮して再送信。                           |
| 400   | `Cannot create more stores. Maximum limit of 20 stores per merchant has been reached.` | マーチャントが既に 20 ストアを所有            | **リトライしない**。既存ストアを削除するか、上限緩和をサポートに依頼。 |

<Note>
  各マーチャントは最大 **20 ストア**まで作成できます。ストア作成者には自動的に `owner` ロールが割り当てられます。
</Note>
