Store Sync API Reference
本ドキュメントは、Mainサイト (store-sync-receiver) が提供するREST APIの技術仕様書です。
将来的な拡張や、他システムからの連携を行う際の参照資料として利用してください。
エンドポイント
URL: https://netguide.site/wp-json/store-sync/v1/update-status
Method: POST
Auth: Custom Header (X-Store-Sync-Secret)
リクエストヘッダー
| Header Key | Value | Description |
|---|---|---|
Content-Type |
application/json |
JSON形式で送信 |
X-Store-Sync-Secret |
{SECRET_KEY} |
wp-config.php に設定した STORE_SYNC_SECRET と一致する文字列 |
リクエストボディ (JSON)
{
"username": "takao_dev",
"product_slug": "cross-poster-pro",
"status": "active",
"expires_at": "2025-12-31 23:59:59"
}
| Parameter | Type | Required | Description |
|---|---|---|---|
username |
string | Yes | 連携するWordPressユーザーのログインID (user_login)。 |
product_slug |
string | Yes | 製品を一意に識別するスラッグ (例: cross-poster-pro)。 |
status |
string | Yes | ライセンスの状態。active, expired, cancelled など(現在は active のみがバッジ表示対象)。 |
expires_at |
string | No | 有効期限の日時 (MySQL DATETIME format: Y-m-d H:i:s)。 |
レスポンス
Success (200 OK)
ユーザーのメタデータ更新に成功した場合。
{
"success": true
}
Error Responses
| Status | Code | Message |
|---|---|---|
| 403 | forbidden |
Invalid secret key (シークレットキー不一致) |
| 400 | missing_params |
Required parameters missing (必須パラメータ不足) |
| 404 | user_not_found |
User not found (指定されたusernameがMainサイトに存在しない) |
内部処理仕様 (Implementation Details)
データの保存場所
Mainサイトの wp_usermeta テーブルに保存されます。
- Key:
storesync_license_{product_slug} - Value: Serialized Array
php array( 'status' => 'active', 'expires_at' => '2025-12-31 23:59:59', 'updated_at' => '2024-01-01 12:00:00' )
バッジ表示ロジック
以下の条件をすべて満たす場合のみバッジが表示されます。
1. ユーザー設定 storesync_show_badges が 1 (ON) である。
2. ステータスが active である。
3. expires_at が現在時刻より未来である(または設定されていない)。