메인 콘텐츠로 건너뛰기

빠른 시작

이 가이드는 첫 번째 API 요청을 보내는 과정을 안내합니다.

사전 준비

  • API 키가 발급된 Headless Commerce 계정
  • curl 또는 HTTP 클라이언트

Step 1: API 키 확인

대시보드에서 스토어를 생성하면 두 가지 유형의 키를 받게 됩니다:
키 유형접두사용도
Secret Keysk_test_* / sk_live_*서버 사이드 전용. 전체 API 접근.
Publishable Keypk_test_* / pk_live_*클라이언트 사이드 안전. Storefront API만 접근.
Secret Key를 클라이언트 사이드 코드에 절대 노출하지 마세요. 브라우저 및 모바일 앱에서는 Publishable Key를 사용하세요.

Step 2: 상품 목록 조회

Storefront API에서 활성 상품을 조회합니다:
curl https://api.headlesscommerce.io/v1/storefront/products \
  -H "Authorization: Bearer pk_test_your_key_here"
Response
{
  "data": [
    {
      "id": "prod_abc123",
      "name": "Classic T-Shirt",
      "status": "active",
      "type": "physical",
      "variants": [...]
    }
  ],
  "has_more": false,
  "next_cursor": null
}

Step 3: 장바구니 생성

curl -X POST https://api.headlesscommerce.io/v1/storefront/carts \
  -H "Authorization: Bearer pk_test_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"session_id": "guest-session-123"}'

Step 4: 상품 추가

curl -X POST https://api.headlesscommerce.io/v1/storefront/carts/{cart_id}/items \
  -H "Authorization: Bearer pk_test_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"variant_id": "var_xxx", "quantity": 1}'

Step 5: 체크아웃

curl -X POST https://api.headlesscommerce.io/v1/storefront/carts/{cart_id}/checkout \
  -H "Authorization: Bearer pk_test_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "customer@example.com",
    "payment_provider": "stripe",
    "payment_method_id": "pm_xxx"
  }'

다음 단계

  • 인증 방식을 자세히 알아보세요
  • 전체 API 레퍼런스를 확인하세요
  • 웹훅을 설정하여 이벤트 알림을 받으세요