手順1:アクセストークンの取得(サーバー間認証)

重要
このサンプルに示されている変数は無効です。 プロジェクトの資格情報から<client_id>と<client_secret>を使用します。
curl -X POST 'https://ims-na1.adobelogin.com/ims/token/v3' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'grant_type=client_credentials&client_id=<client_id>&client_secret=<client_secret>&scope=openid,AdobeID,email,additional_info.projectedProductContext,profile,commerce.aco.ingestion,commerce.accs,org.read,additional_info.roles'

サンプル応答:

{
  "access_token": "eyJhbGciOiJSUzI1NiIs...",
  "token_type": "bearer",
  "expires_in": 86399
}

手順2:顧客の作成

重要
このサンプルで指定されたURLは無効です。 REST ベース URLを使用します。 「<rest_endpoint>」をURLと交換します。 このhttps://na1-sandbox.api.commerce.adobe.com/AbCYab34cdEfGHiJ27123と似ています。
このエンドポイントには、URLの一部として/rest/がありません。 それを含めるとエラーになります。

エンドポイント: POST /V1/customers

curl -X POST \
  "<rest_endpoint>/V1/customers" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "customer": {
      "email": "john.doe@example.com",
      "firstname": "John",
      "lastname": "Doe",
      "store_id": 1,
      "website_id": 1
    },
    "password": "TempPa55word!"
  }'

応答:

{
  "id": 5,
  "group_id": 1,
  "created_at": "2026-01-23 20:40:15",
  "updated_at": "2026-01-23 20:40:15",
  "created_in": "Default Store View",
  "email": "john.doe@example.com",
  "firstname": "John",
  "lastname": "Doe",
  "store_id": 1,
  "website_id": 1,
  "addresses": [],
  "disable_auto_group_change": 0
}

手順3:顧客の更新

重要
このサンプルで指定されたURLは無効です。 REST ベース URLを使用します。 「<rest_endpoint>」をURLと交換します。 このhttps://na1-sandbox.api.commerce.adobe.com/AbCYab34cdEfGHiJ27123と似ています。

次の例の数値5は、POST "id": 5,を使用して以前に作成した顧客のIDです。 リクエストで返されたIDに5を必ず変更してください。

エンドポイント: PUT /V1/customers/{customerId}

curl -X PUT \
  "<rest_endpoint>/V1/customers/5" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "customer": {
      "id": 5,
      "email": "john.doe@example.com",
      "firstname": "John",
      "lastname": "Doe-Updated"
    }
  }'

応答:

{
  "id": 5,
  "group_id": 1,
  "created_at": "2026-01-23 20:40:15",
  "updated_at": "2026-01-23 20:40:30",
  "created_in": "Default Store View",
  "email": "john.doe@example.com",
  "firstname": "John",
  "lastname": "Doe-Updated",
  "store_id": 1,
  "website_id": 1,
  "addresses": []
}

完全なスクリプト(オールインワン)

重要
このサンプルに示されている変数は無効です。 プロジェクトの資格情報からクライアント IDとクライアントの秘密鍵を使用します。 REST ベース URLを使用します。 '<rest_endpoint>'をexperience.adobe.comからREST エンドポイント URLと交換します。 このhttps://na1-sandbox.api.commerce.adobe.com/AbCDefGHiJ1234567と似ています。
#!/bin/bash

# Configuration be sure to update these with your projects unique values
CLIENT_ID="<client_id>"
CLIENT_SECRET="<client_secret>"
REST_ENDPOINT="<rest_endpoint>"

# Step 1: Get Access Token
echo "Getting access token..."
ACCESS_TOKEN=$(curl -s -X POST 'https://ims-na1.adobelogin.com/ims/token/v3' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d "grant_type=client_credentials&client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}&scope=openid,AdobeID,email,additional_info.projectedProductContext,profile,commerce.aco.ingestion,commerce.accs,org.read,additional_info.roles" | jq -r '.access_token')

echo "Token obtained: ${ACCESS_TOKEN:0:50}..."

# Step 2: Create Customer
echo ""
echo "Creating customer..."
CREATE_RESPONSE=$(curl -s -X POST \
  "${REST_ENDPOINT}/V1/customers" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -d '{
    "customer": {
      "email": "john.doe@example.com",
      "firstname": "John",
      "lastname": "Doe",
      "store_id": 1,
      "website_id": 1
    },
    "password": "TempPa55word!"
  }')

echo "Create Response:"
echo "$CREATE_RESPONSE" | jq .

# Extract customer ID
CUSTOMER_ID=$(echo "$CREATE_RESPONSE" | jq -r '.id')
echo "Customer ID: $CUSTOMER_ID"

# Step 3: Update Customer
echo ""
echo "Updating customer..."
curl -s -X PUT \
  "${REST_ENDPOINT}/V1/customers/${CUSTOMER_ID}" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -d "{
    \"customer\": {
      \"id\": ${CUSTOMER_ID},
      \"email\": \"john.doe@example.com\",
      \"firstname\": \"john\",
      \"lastname\": \"Doe-Updated\"
    }
  }" | jq .

このチュートリアルに関する注意事項

  1. URL パス: https://<server>.api.commerce.adobe.com/<tenant-id>/V1/customers — NOT https://<host>/rest/<store-view-code>/V1/customersを使用
  2. 認証:このチュートリアルでは、サーバー間(client_credentials付与タイプ)を使用しました
  3. 必要な範囲: commerce.accs
  4. トークンの有効期限: 86400秒(24時間)

参照

自動翻訳
言語セレクターを使用して、このページの英語版を表示します。
翻訳は役に立ちましたか?

Ask AI

Not sure where to start?
Ask me anything about Adobe products.

Type your question or pick a suggestion below.

Use of this AI chatbot is subject to Adobe's Privacy Policy. Don't share sensitive data. AI responses are not your Content, may be inaccurate, and any offers provided are non-binding. Generative AI Terms.