API - 概要

API - Viewer、Configurator、Customizer

製品を取得してツールに関連付け、Viewer、Configurator、Customizerを安全に埋め込むためのセッションを作成します。

エンドポイント一覧

メソッドエンドポイント説明アクセス
GET/public-api/v1/products埋め込みの可否とメディア URL を含む、ストアフロントの商品/デザインを返します。products:read
GET/public-api/v1/products/:idストアフロントの商品/デザインを一件返します。products:read
POST/public-api/v1/embed/sessionモデルジェネレーターを含む埋め込みツール向けに、短時間有効なJWTを発行します。embed:session:create
GET/public-api/v1/runtime/bootstrap埋め込み JWT からランタイムのコンテキストを解決します。Bearer 埋め込みトークン
POST/public-api/v1/runtime-bindings/sync-from-wordpressWordPress の商品マッピングからランタイムバインディングを作成または更新します。任意の認証済み認証情報
PATCH/public-api/v1/runtime-bindings/:idランタイムバインディングを部分更新します。任意の認証済み認証情報
POST/public-api/v1/runtime-bindings/:id/activateランタイムバインディングを有効にします。任意の認証済み認証情報
POST/public-api/v1/runtime-bindings/:id/deactivateランタイムバインディングを無効にします。任意の認証済み認証情報

ストアフロントの商品

商品エンドポイントは、Viewer、Configurator、Customizer として埋め込み可能なストアフロントのデザインを返します。

パラメータ必須詳細
nameいいえ商品/デザイン名を検索します。
customizerいいえtrue または false。
offsetいいえデフォルトは 0。>= 0 である必要があります。
limitいいえデフォルトは 9、最大は 50 です。
order_byいいえid、name、created_at のいずれか。
directionいいえASC または DESC。

リクエスト例(fetch)

const params = new URLSearchParams({
  limit: '20',
  offset: '0',
  name: 't-shirt',
  customizer: 'true',
  order_by: 'created_at',
  direction: 'DESC'
});

const products = await alterFetch(`/products?${params.toString()}`);
const product = await alterFetch('/products/381');

レスポンス例

{
  "products": {
    "items": [
      {
        "id": 381,
        "name": "Men's T-Shirt",
        "createdAt": "2026-01-03T23:55:05.000Z",
        "productId": 4,
        "media": {
          "img": {
            "big": "https://alterproduct.com/public-api/v1/file/public/products/4/big.png",
            "medium": "https://alterproduct.com/public-api/v1/file/public/products/4/medium.png",
            "small": "https://alterproduct.com/public-api/v1/file/public/products/4/small.png"
          },
          "mockups": []
        },
        "storefrontProduct": {
          "id": 89,
          "idUserDesign": 381,
          "shareAccess": "public",
          "isCustomizer": 1
        },
        "runtimeBindings": [
          {
            "id": 42,
            "runtimeType": "customizer",
            "status": "active",
            "externalProductId": "wc_123"
          }
        ],
        "embeddable": {
          "viewer": true,
          "configurator": true,
          "customizer": true
        }
      }
    ],
    "total": 1
  }
}

ランタイムバインディング

ランタイムバインディングは、外部コマースの商品を Alter Product のデザインとランタイムの種類に関連付けます。主に WordPress/WooCommerce 連携や高度なストアフロントのバックエンドで使用します。

パラメータ必須詳細
designIdいいえストアフロントが所有する Alter Product のデザイン ID。
externalProductId同期時は必須外部の商品 ID。例:WooCommerce の商品 ID。
runtimeType同期時は必須viewer、configurator、customizer のいずれか。
statusいいえdraft、active、inactive、archived、legacy_active のいずれか。
legacyStorefrontProductIdいいえ旧形式のマッピング ID(任意)。
legacyBindingMetaいいえ任意の JSON メタデータ。例:manifestHash。

リクエスト例(fetch)

await alterFetch('/runtime-bindings/sync-from-wordpress', {
  method: 'POST',
  body: JSON.stringify({
    bindings: [
      {
        externalProductId: 'wc_123',
        runtimeType: 'customizer',
        status: 'active',
        designId: 381,
        legacyBindingMeta: {
          manifestHash: 'a3b1...'
        }
      }
    ]
  })
});

await alterFetch('/runtime-bindings/42', {
  method: 'PATCH',
  body: JSON.stringify({
    status: 'inactive'
  })
});

await alterFetch('/runtime-bindings/42/activate', { method: 'POST' });
await alterFetch('/runtime-bindings/42/deactivate', { method: 'POST' });

wordpress_local

await alterFetch('/runtime-bindings/sync-from-wordpress', {
  method: 'POST',
  body: JSON.stringify({
    bindings: [
      {
        externalProductId: 'wc_123',
        runtimeType: 'viewer',
        status: 'active',
        externalDesign: {
          externalDesignKey: 'wp-design-381',
          productId: 4,
          title: 'WooCommerce local design',
          manifestUrl: 'https://yourstore.com/wp-content/uploads/alter/381/manifest.json',
          assetBaseUrl: 'https://yourstore.com/wp-content/uploads/alter/381/',
          manifestHash: 'a3b1...',
          sourceMeta: {
            pluginVersion: '1.2.0'
          }
        }
      }
    ]
  })
});

レスポンス例

{
  "message": "runtimeBinding.syncCompleted",
  "runtimeBindings": [
    {
      "id": 42,
      "designId": 381,
      "externalProductId": "wc_123",
      "runtimeType": "customizer",
      "status": "active"
    }
  ]
}

埋め込みセッションとランタイムの初期化

サーバーで有効期間の短い埋め込みトークンを作成し、iframe/ランタイムに渡した後、ランタイムから Bearer トークンを使用して bootstrap を呼び出します。

パラメータ必須詳細
runtimeBindingId推奨有効なランタイムバインディングの優先識別子。
toolruntimeBindingId がない場合は必須designer | viewer | configurator | customizer | model-generator
toolIdtool: model-generatorローカルのジェネレータープロジェクトの正の数値IDです。UUIDやWooCommerceの商品IDではありません。
originはい埋め込みが表示されるオリジン。例:https://yourstore.com.
designId識別子をいずれか指定Alter Product のデザイン ID。orderId と同時に指定しないでください。
orderId識別子をいずれか指定Customizer の注文 ID。customizer のみで有効です。
cartKey + cartModeいいえCustomizer 専用のカートコンテキスト。cartMode は view または edit です。

リクエスト例(fetch)

const session = await alterFetch('/embed/session', {
  method: 'POST',
  headers: {
    'x-alter-client-fingerprint': '9f1b7a5e4b3c2d1f9f1b7a5e4b3c2d1f'
  },
  body: JSON.stringify({
    runtimeBindingId: 42,
    origin: 'https://yourstore.com'
  })
});

const bootstrapResponse = await fetch('https://alterproduct.com/public-api/v1/runtime/bootstrap', {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${session.token}`
  }
});

const bootstrap = await bootstrapResponse.json();
console.log({ session, bootstrap });

注意事項

await alterFetch('/embed/session', {
  method: 'POST',
  body: JSON.stringify({
    tool: 'customizer',
    origin: 'https://yourstore.com',
    orderId: 123
  })
});

await alterFetch('/embed/session', {
  method: 'POST',
  body: JSON.stringify({
    tool: 'viewer',
    origin: 'https://yourstore.com',
    designId: 381
  })
});

レスポンス例

{
  "token": "eyJhbGciOiJIUzI1NiIsImtpZCI6IjEifQ...",
  "expiresIn": 900,
  "kid": "1",
  "mode": "design",
  "runtimeBindingId": 42,
  "runtimeType": "customizer"
}

Runtime bootstrap

{
  "runtimeBindingId": 42,
  "designId": 381,
  "productId": "wc_123",
  "runtimeType": "customizer",
  "storageMode": "wordpress_local",
  "manifestUrl": "https://yourstore.com/wp-content/uploads/alter/381/manifest.json",
  "assetBaseUrl": "https://yourstore.com/wp-content/uploads/alter/381/",
  "manifestHash": "a3b1...",
  "planCapabilities": {
    "viewer": true,
    "configurator": true,
    "customizer": true
  },
  "cartKey": null,
  "cartMode": null,
  "orderId": null
}