카테고리 API

중첩 계층을 지원하는 제품 카테고리를 관리합니다.

엔드포인트
GET

/categories

categories:read

모든 카테고리의 플랫 목록을 조회합니다.

GET

/categories/tree

categories:read

중첩된 하위 카테고리를 포함한 전체 카테고리 트리를 조회합니다.

GET

/categories/:id

categories:read

ID로 단일 카테고리를 조회합니다.

POST

/categories

categories:write

새 카테고리를 생성합니다. parentId를 설정하여 하위 카테고리를 만들 수 있습니다.

PUT

/categories/:id

categories:write

기존 카테고리를 수정합니다. 부분 업데이트가 지원됩니다.

DELETE

/categories/:id

categories:write

카테고리를 소프트 삭제합니다. 이 카테고리의 제품에는 영향을 미치지 않습니다.

필드 참조
필드유형필수설명

id

string

아니오

고유 카테고리 식별자 (읽기 전용)

name

string

카테고리 이름

slug

string

아니오

URL 친화적 슬러그 (생략 시 자동 생성)

description

string

아니오

카테고리 설명

parentId

string

아니오

중첩을 위한 상위 카테고리 ID

imageUrl

string

아니오

카테고리 이미지 URL

sortOrder

integer

아니오

표시 정렬 순서 (낮을수록 먼저)

isActive

boolean

아니오

카테고리 활성화 여부 (기본값: true)

children

Category[]

아니오

중첩된 하위 카테고리 (트리 엔드포인트에서만)

createdAt

datetime

아니오

ISO 8601 타임스탬프 (읽기 전용)

updatedAt

datetime

아니오

ISO 8601 타임스탬프 (읽기 전용)

예시
카테고리 트리 조회
bash
curl "https://api.mercozy.com/api/v1/external/categories/tree" \
  -H "X-API-Key: mk_live_xxxxx"
카테고리 생성
bash
curl -X POST "https://api.mercozy.com/api/v1/external/categories" \
  -H "X-API-Key: mk_live_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Electronics",
    "description": "Electronic devices and accessories",
    "sortOrder": 1,
    "isActive": true
  }'
응답 예시 (트리)
json
{
  "data": [
    {
      "id": "cat_abc123",
      "name": "Electronics",
      "slug": "electronics",
      "description": "Electronic devices and accessories",
      "parentId": null,
      "imageUrl": null,
      "sortOrder": 1,
      "isActive": true,
      "children": [
        {
          "id": "cat_def456",
          "name": "Smartphones",
          "slug": "smartphones",
          "description": "Mobile phones",
          "parentId": "cat_abc123",
          "imageUrl": null,
          "sortOrder": 1,
          "isActive": true,
          "children": []
        }
      ],
      "createdAt": "2025-12-15T10:30:00Z",
      "updatedAt": "2025-12-15T10:30:00Z"
    }
  ]
}