Skip to content

Commerce API

Common Information

Base URL

/api/v1

Authentication Header

Authorization: Bearer <access_token>

Response Envelope

All responses follow the standard format:

typescript
// Success response
interface SuccessResponse<T> {
  success: true;
  data: T;
  meta?: {
    pagination?: PaginationMeta;
    [key: string]: unknown;
  };
}

// Error response
interface ErrorResponse {
  success: false;
  error: {
    code: string;
    message: string;
    details?: Record<string, string[]>;
  };
}

Pagination Format

typescript
interface PaginationMeta {
  total: number;
  page: number;
  pageSize: number;
  totalPages: number;
  hasNext: boolean;
  hasPrevious: boolean;
}

Rate Limits

EndpointLimit
Product listing/details200/min
Cart operations100/min
POST /cart/checkout2/min per user
Order operations100/min

Financial Endpoint Rate Limit Headers

X-RateLimit-Limit: 2
X-RateLimit-Remaining: 1
X-RateLimit-Reset: 1705329600
X-RateLimit-Policy: financial

Product Endpoints

GET /api/v1/products

List products with filtering and pagination.

Authentication: Public

Rate Limit: 200 requests per minute

Request Headers

Authorization: Bearer <access_token>  (optional - for personalized pricing)

Request Body

None

Query Parameters

ParameterTypeDescription
pagenumberPage number (optional)
pageSizenumberItems per page, max 100 (optional)
categoryIdstringFilter by category UUID (optional)
statusstringFilter: 'ACTIVE', 'OUT_OF_STOCK' (optional)
minPricenumberMinimum price filter (optional)
maxPricenumberMaximum price filter (optional)
searchstringFull-text search on name/description (optional)
sortBystringSort field: 'price', 'name', 'createdAt', 'popularity' (optional)
sortOrderstringSort direction: 'asc', 'desc' (optional)
tagsstringComma-separated tag filter (optional)

Response (200 OK)

typescript
interface ProductsResponse {
  products: Product[];
}

interface Product {
  id: string;
  name: string;
  slug: string;
  description: string;
  shortDescription: string | null;
  price: number;
  compareAtPrice: number | null;
  currency: string;
  sku: string;
  status: 'ACTIVE' | 'DRAFT' | 'ARCHIVED' | 'OUT_OF_STOCK';
  stockQuantity: number | null;
  category: {
    id: string;
    name: string;
    slug: string;
  } | null;
  images: {
    id: string;
    url: string;
    thumbnailUrl: string;
    alt: string | null;
    isPrimary: boolean;
  }[];
  tags: string[];
  rating: {
    average: number;
    count: number;
  };
  commissionPercentage: number;
  careerPointsPercentage: number;
  createdAt: string;
}

Error Responses

StatusCodeDescription
400VALIDATION_ERRORInvalid query parameters

Example

Request:

bash
curl -X GET "https://api.iwm-platform.com/api/v1/products?categoryId=cat-123&minPrice=1000&maxPrice=50000&sortBy=price&sortOrder=asc&page=1&pageSize=20"

Response:

json
{
  "success": true,
  "data": {
    "products": [
      {
        "id": "pp0e8400-e29b-41d4-a716-446655440001",
        "name": "Premium Health Supplement",
        "slug": "premium-health-supplement",
        "description": "A comprehensive health supplement with essential vitamins and minerals.",
        "shortDescription": "Essential vitamins and minerals",
        "price": 2500,
        "compareAtPrice": 3000,
        "currency": "RUB",
        "sku": "SUP-001",
        "status": "ACTIVE",
        "stockQuantity": 150,
        "category": {
          "id": "cat-123",
          "name": "Health Supplements",
          "slug": "health-supplements"
        },
        "images": [
          {
            "id": "img-001",
            "url": "https://cdn.iwm-platform.com/products/sup-001-full.jpg",
            "thumbnailUrl": "https://cdn.iwm-platform.com/products/sup-001-thumb.jpg",
            "alt": "Premium Health Supplement bottle",
            "isPrimary": true
          }
        ],
        "tags": ["health", "vitamins", "bestseller"],
        "rating": {
          "average": 4.7,
          "count": 156
        },
        "commissionPercentage": 10,
        "careerPointsPercentage": 5,
        "createdAt": "2024-01-01T10:00:00Z"
      }
    ]
  },
  "meta": {
    "pagination": {
      "total": 85,
      "page": 1,
      "pageSize": 20,
      "totalPages": 5,
      "hasNext": true,
      "hasPrevious": false
    }
  }
}

GET /api/v1/products/:id

Get product details.

Authentication: Public

Rate Limit: 200 requests per minute

Request Headers

Authorization: Bearer <access_token>  (optional - for personalized pricing)

Path Parameters

ParameterTypeDescription
idstring (UUID)Product ID

Request Body

None

Query Parameters

None

Response (200 OK)

typescript
interface ProductDetailResponse {
  id: string;
  name: string;
  slug: string;
  description: string;
  shortDescription: string | null;
  price: number;
  compareAtPrice: number | null;
  currency: string;
  sku: string;
  status: 'ACTIVE' | 'DRAFT' | 'ARCHIVED' | 'OUT_OF_STOCK';
  stockQuantity: number | null;
  trackInventory: boolean;
  weight: number | null;
  dimensions: {
    length: number | null;
    width: number | null;
    height: number | null;
  };
  category: {
    id: string;
    name: string;
    slug: string;
    breadcrumb: {
      id: string;
      name: string;
      slug: string;
    }[];
  } | null;
  images: {
    id: string;
    url: string;
    thumbnailUrl: string;
    alt: string | null;
    isPrimary: boolean;
    position: number;
  }[];
  variants: {
    id: string;
    name: string;
    sku: string;
    price: number;
    stockQuantity: number | null;
    attributes: Record<string, string>;
  }[];
  attributes: Record<string, string>;
  tags: string[];
  rating: {
    average: number;
    count: number;
    distribution: {
      1: number;
      2: number;
      3: number;
      4: number;
      5: number;
    };
  };
  commissionPercentage: number;
  careerPointsPercentage: number;
  relatedProducts: {
    id: string;
    name: string;
    slug: string;
    price: number;
    thumbnailUrl: string | null;
  }[];
  createdAt: string;
  updatedAt: string;
}

Error Responses

StatusCodeDescription
404PRODUCT_NOT_FOUNDProduct not found

Example

Request:

bash
curl -X GET https://api.iwm-platform.com/api/v1/products/pp0e8400-e29b-41d4-a716-446655440001

Response:

json
{
  "success": true,
  "data": {
    "id": "pp0e8400-e29b-41d4-a716-446655440001",
    "name": "Premium Health Supplement",
    "slug": "premium-health-supplement",
    "description": "A comprehensive health supplement with essential vitamins and minerals for daily wellness.",
    "shortDescription": "Essential vitamins and minerals",
    "price": 2500,
    "compareAtPrice": 3000,
    "currency": "RUB",
    "sku": "SUP-001",
    "status": "ACTIVE",
    "stockQuantity": 150,
    "trackInventory": true,
    "weight": 250,
    "dimensions": {
      "length": 10,
      "width": 10,
      "height": 15
    },
    "category": {
      "id": "cat-123",
      "name": "Health Supplements",
      "slug": "health-supplements",
      "breadcrumb": [
        { "id": "cat-001", "name": "Health & Wellness", "slug": "health-wellness" },
        { "id": "cat-123", "name": "Health Supplements", "slug": "health-supplements" }
      ]
    },
    "images": [
      {
        "id": "img-001",
        "url": "https://cdn.iwm-platform.com/products/sup-001-full.jpg",
        "thumbnailUrl": "https://cdn.iwm-platform.com/products/sup-001-thumb.jpg",
        "alt": "Premium Health Supplement bottle",
        "isPrimary": true,
        "position": 1
      }
    ],
    "variants": [],
    "attributes": {
      "servingSize": "2 capsules",
      "servingsPerContainer": "60",
      "form": "Capsules"
    },
    "tags": ["health", "vitamins", "bestseller"],
    "rating": {
      "average": 4.7,
      "count": 156,
      "distribution": {
        "1": 2,
        "2": 5,
        "3": 12,
        "4": 45,
        "5": 92
      }
    },
    "commissionPercentage": 10,
    "careerPointsPercentage": 5,
    "relatedProducts": [
      {
        "id": "pp0e8400-e29b-41d4-a716-446655440002",
        "name": "Omega-3 Fish Oil",
        "slug": "omega-3-fish-oil",
        "price": 1800,
        "thumbnailUrl": "https://cdn.iwm-platform.com/products/omega-thumb.jpg"
      }
    ],
    "createdAt": "2024-01-01T10:00:00Z",
    "updatedAt": "2024-01-15T12:00:00Z"
  }
}

GET /api/v1/products/:id/reviews

Get product reviews.

Authentication: Public

Rate Limit: 200 requests per minute

Request Headers

Authorization: Bearer <access_token>  (optional)

Path Parameters

ParameterTypeDescription
idstring (UUID)Product ID

Request Body

None

Query Parameters

ParameterTypeDescription
pagenumberPage number (optional)
pageSizenumberItems per page, max 50 (optional)
ratingnumberFilter by rating (1-5) (optional)
sortBystringSort field: 'createdAt', 'rating', 'helpful' (optional)
sortOrderstringSort direction: 'asc', 'desc' (optional)

Response (200 OK)

typescript
interface ProductReviewsResponse {
  reviews: Review[];
  summary: {
    average: number;
    count: number;
    distribution: {
      1: number;
      2: number;
      3: number;
      4: number;
      5: number;
    };
  };
}

interface Review {
  id: string;
  author: {
    id: string;
    name: string;
    avatarUrl: string | null;
    isVerifiedPurchaser: boolean;
  };
  rating: number;
  title: string | null;
  content: string;
  pros: string[];
  cons: string[];
  helpfulCount: number;
  isHelpful: boolean | null;      // null if user not authenticated
  images: {
    url: string;
    thumbnailUrl: string;
  }[];
  response: {
    content: string;
    respondedAt: string;
  } | null;
  createdAt: string;
  updatedAt: string | null;
}

Error Responses

StatusCodeDescription
404PRODUCT_NOT_FOUNDProduct not found

Example

Request:

bash
curl -X GET "https://api.iwm-platform.com/api/v1/products/pp0e8400-e29b-41d4-a716-446655440001/reviews?page=1&pageSize=10&sortBy=helpful&sortOrder=desc"

Response:

json
{
  "success": true,
  "data": {
    "reviews": [
      {
        "id": "rv0e8400-e29b-41d4-a716-446655440001",
        "author": {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "John D.",
          "avatarUrl": "https://cdn.iwm-platform.com/avatars/550e8400.jpg",
          "isVerifiedPurchaser": true
        },
        "rating": 5,
        "title": "Excellent quality supplement",
        "content": "I've been taking this supplement for a month and noticed significant improvement in my energy levels.",
        "pros": ["High quality ingredients", "Easy to swallow", "Fast shipping"],
        "cons": ["Price could be lower"],
        "helpfulCount": 24,
        "isHelpful": null,
        "images": [],
        "response": {
          "content": "Thank you for your feedback! We're glad you're enjoying the product.",
          "respondedAt": "2024-01-10T12:00:00Z"
        },
        "createdAt": "2024-01-08T15:30:00Z",
        "updatedAt": null
      }
    ],
    "summary": {
      "average": 4.7,
      "count": 156,
      "distribution": {
        "1": 2,
        "2": 5,
        "3": 12,
        "4": 45,
        "5": 92
      }
    }
  },
  "meta": {
    "pagination": {
      "total": 156,
      "page": 1,
      "pageSize": 10,
      "totalPages": 16,
      "hasNext": true,
      "hasPrevious": false
    }
  }
}

POST /api/v1/products/:id/reviews

Add a product review.

Authentication: Required

Rate Limit: 100 requests per minute

Request Headers

Authorization: Bearer <access_token>

Path Parameters

ParameterTypeDescription
idstring (UUID)Product ID

Request Body

typescript
interface CreateReviewRequest {
  rating: number;                 // 1-5
  title?: string;                 // Optional title (max 100 chars)
  content: string;                // Review content (min 10, max 2000 chars)
  pros?: string[];                // List of pros (max 5, each max 100 chars)
  cons?: string[];                // List of cons (max 5, each max 100 chars)
}

Query Parameters

None

Response (201 Created)

typescript
interface CreateReviewResponse {
  id: string;
  rating: number;
  title: string | null;
  content: string;
  pros: string[];
  cons: string[];
  status: 'PENDING' | 'PUBLISHED';
  createdAt: string;
}

Error Responses

StatusCodeDescription
400VALIDATION_ERRORInvalid input data
401UNAUTHORIZEDInvalid or expired access token
403NOT_PURCHASEDMust purchase product to review
404PRODUCT_NOT_FOUNDProduct not found
409ALREADY_REVIEWEDUser already reviewed this product

Example

Request:

bash
curl -X POST https://api.iwm-platform.com/api/v1/products/pp0e8400-e29b-41d4-a716-446655440001/reviews \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "rating": 5,
    "title": "Great product",
    "content": "This supplement has really helped improve my daily energy levels. Highly recommend!",
    "pros": ["High quality", "Fast delivery"],
    "cons": ["Packaging could be better"]
  }'

Response:

json
{
  "success": true,
  "data": {
    "id": "rv0e8400-e29b-41d4-a716-446655440002",
    "rating": 5,
    "title": "Great product",
    "content": "This supplement has really helped improve my daily energy levels. Highly recommend!",
    "pros": ["High quality", "Fast delivery"],
    "cons": ["Packaging could be better"],
    "status": "PENDING",
    "createdAt": "2024-01-15T20:00:00Z"
  }
}

Category Endpoints

GET /api/v1/categories

List all categories.

Authentication: Public

Rate Limit: 200 requests per minute

Request Headers

None required

Request Body

None

Query Parameters

ParameterTypeDescription
parentIdstringFilter by parent category (optional, null for root)
includeProductsbooleanInclude product count (optional)

Response (200 OK)

typescript
interface CategoriesResponse {
  categories: Category[];
}

interface Category {
  id: string;
  name: string;
  slug: string;
  description: string | null;
  imageUrl: string | null;
  parentId: string | null;
  level: number;
  position: number;
  productCount: number | null;
  children: Category[];
  isActive: boolean;
}

Error Responses

StatusCodeDescription
400VALIDATION_ERRORInvalid query parameters

Example

Request:

bash
curl -X GET "https://api.iwm-platform.com/api/v1/categories?includeProducts=true"

Response:

json
{
  "success": true,
  "data": {
    "categories": [
      {
        "id": "cat-001",
        "name": "Health & Wellness",
        "slug": "health-wellness",
        "description": "Products for your health and wellbeing",
        "imageUrl": "https://cdn.iwm-platform.com/categories/health.jpg",
        "parentId": null,
        "level": 0,
        "position": 1,
        "productCount": 125,
        "children": [
          {
            "id": "cat-123",
            "name": "Health Supplements",
            "slug": "health-supplements",
            "description": "Vitamins, minerals, and supplements",
            "imageUrl": "https://cdn.iwm-platform.com/categories/supplements.jpg",
            "parentId": "cat-001",
            "level": 1,
            "position": 1,
            "productCount": 85,
            "children": [],
            "isActive": true
          }
        ],
        "isActive": true
      }
    ]
  }
}

GET /api/v1/categories/:id

Get category with products.

Authentication: Public

Rate Limit: 200 requests per minute

Request Headers

None required

Path Parameters

ParameterTypeDescription
idstring (UUID)Category ID

Request Body

None

Query Parameters

ParameterTypeDescription
pagenumberPage number for products (optional)
pageSizenumberItems per page, max 100 (optional)
sortBystringSort products by: 'price', 'name', 'createdAt', 'popularity' (optional)
sortOrderstringSort direction: 'asc', 'desc' (optional)

Response (200 OK)

typescript
interface CategoryDetailResponse {
  id: string;
  name: string;
  slug: string;
  description: string | null;
  imageUrl: string | null;
  parent: {
    id: string;
    name: string;
    slug: string;
  } | null;
  breadcrumb: {
    id: string;
    name: string;
    slug: string;
  }[];
  children: {
    id: string;
    name: string;
    slug: string;
    productCount: number;
  }[];
  products: Product[];
  filters: {
    priceRange: {
      min: number;
      max: number;
    };
    tags: {
      name: string;
      count: number;
    }[];
  };
}

Error Responses

StatusCodeDescription
404CATEGORY_NOT_FOUNDCategory not found

Example

Request:

bash
curl -X GET "https://api.iwm-platform.com/api/v1/categories/cat-123?page=1&pageSize=20"

Response:

json
{
  "success": true,
  "data": {
    "id": "cat-123",
    "name": "Health Supplements",
    "slug": "health-supplements",
    "description": "Vitamins, minerals, and supplements for daily wellness",
    "imageUrl": "https://cdn.iwm-platform.com/categories/supplements.jpg",
    "parent": {
      "id": "cat-001",
      "name": "Health & Wellness",
      "slug": "health-wellness"
    },
    "breadcrumb": [
      { "id": "cat-001", "name": "Health & Wellness", "slug": "health-wellness" },
      { "id": "cat-123", "name": "Health Supplements", "slug": "health-supplements" }
    ],
    "children": [
      { "id": "cat-124", "name": "Vitamins", "slug": "vitamins", "productCount": 32 },
      { "id": "cat-125", "name": "Minerals", "slug": "minerals", "productCount": 18 }
    ],
    "products": [],
    "filters": {
      "priceRange": {
        "min": 500,
        "max": 15000
      },
      "tags": [
        { "name": "vitamins", "count": 32 },
        { "name": "bestseller", "count": 15 }
      ]
    }
  },
  "meta": {
    "pagination": {
      "total": 85,
      "page": 1,
      "pageSize": 20,
      "totalPages": 5,
      "hasNext": true,
      "hasPrevious": false
    }
  }
}

Cart Endpoints

GET /api/v1/cart

Get current cart.

Authentication: Required

Rate Limit: 100 requests per minute

Request Headers

Authorization: Bearer <access_token>

Request Body

None

Query Parameters

None

Response (200 OK)

typescript
interface CartResponse {
  id: string;
  items: CartItem[];
  summary: {
    subtotal: number;
    discount: number;
    shipping: number | null;
    tax: number;
    total: number;
    currency: string;
    itemCount: number;
    totalQuantity: number;
  };
  appliedCoupons: {
    code: string;
    discount: number;
    type: 'PERCENTAGE' | 'FIXED';
  }[];
  estimatedCommission: number | null;
  estimatedCareerPoints: number | null;
  updatedAt: string;
}

interface CartItem {
  id: string;
  product: {
    id: string;
    name: string;
    slug: string;
    sku: string;
    price: number;
    compareAtPrice: number | null;
    thumbnailUrl: string | null;
    status: string;
    stockQuantity: number | null;
  };
  variantId: string | null;
  variantAttributes: Record<string, string> | null;
  quantity: number;
  unitPrice: number;
  totalPrice: number;
  addedAt: string;
}

Error Responses

StatusCodeDescription
401UNAUTHORIZEDInvalid or expired access token

Example

Request:

bash
curl -X GET https://api.iwm-platform.com/api/v1/cart \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."

Response:

json
{
  "success": true,
  "data": {
    "id": "ct0e8400-e29b-41d4-a716-446655440001",
    "items": [
      {
        "id": "ci0e8400-e29b-41d4-a716-446655440001",
        "product": {
          "id": "pp0e8400-e29b-41d4-a716-446655440001",
          "name": "Premium Health Supplement",
          "slug": "premium-health-supplement",
          "sku": "SUP-001",
          "price": 2500,
          "compareAtPrice": 3000,
          "thumbnailUrl": "https://cdn.iwm-platform.com/products/sup-001-thumb.jpg",
          "status": "ACTIVE",
          "stockQuantity": 150
        },
        "variantId": null,
        "variantAttributes": null,
        "quantity": 2,
        "unitPrice": 2500,
        "totalPrice": 5000,
        "addedAt": "2024-01-15T18:00:00Z"
      }
    ],
    "summary": {
      "subtotal": 5000,
      "discount": 0,
      "shipping": null,
      "tax": 1000,
      "total": 6000,
      "currency": "RUB",
      "itemCount": 1,
      "totalQuantity": 2
    },
    "appliedCoupons": [],
    "estimatedCommission": null,
    "estimatedCareerPoints": null,
    "updatedAt": "2024-01-15T18:00:00Z"
  }
}

POST /api/v1/cart/items

Add item to cart.

Authentication: Required

Rate Limit: 100 requests per minute

Request Headers

Authorization: Bearer <access_token>

Request Body

typescript
interface AddCartItemRequest {
  productId: string;              // Product UUID
  variantId?: string;             // Product variant UUID (if applicable)
  quantity: number;               // Quantity to add (min 1)
}

Query Parameters

None

Response (201 Created)

typescript
interface AddCartItemResponse {
  cartItemId: string;
  product: {
    id: string;
    name: string;
  };
  quantity: number;
  unitPrice: number;
  totalPrice: number;
  cartSummary: {
    total: number;
    itemCount: number;
    totalQuantity: number;
  };
}

Error Responses

StatusCodeDescription
400VALIDATION_ERRORInvalid input data
401UNAUTHORIZEDInvalid or expired access token
404PRODUCT_NOT_FOUNDProduct not found
404VARIANT_NOT_FOUNDProduct variant not found
400PRODUCT_UNAVAILABLEProduct is not available
400INSUFFICIENT_STOCKNot enough stock available
400MAX_QUANTITY_EXCEEDEDMaximum quantity per item exceeded

Example

Request:

bash
curl -X POST https://api.iwm-platform.com/api/v1/cart/items \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "productId": "pp0e8400-e29b-41d4-a716-446655440001",
    "quantity": 2
  }'

Response:

json
{
  "success": true,
  "data": {
    "cartItemId": "ci0e8400-e29b-41d4-a716-446655440001",
    "product": {
      "id": "pp0e8400-e29b-41d4-a716-446655440001",
      "name": "Premium Health Supplement"
    },
    "quantity": 2,
    "unitPrice": 2500,
    "totalPrice": 5000,
    "cartSummary": {
      "total": 6000,
      "itemCount": 1,
      "totalQuantity": 2
    }
  }
}

PATCH /api/v1/cart/items/:id

Update cart item quantity.

Authentication: Required

Rate Limit: 100 requests per minute

Request Headers

Authorization: Bearer <access_token>

Path Parameters

ParameterTypeDescription
idstring (UUID)Cart item ID

Request Body

typescript
interface UpdateCartItemRequest {
  quantity: number;               // New quantity (min 1)
}

Query Parameters

None

Response (200 OK)

typescript
interface UpdateCartItemResponse {
  cartItemId: string;
  quantity: number;
  unitPrice: number;
  totalPrice: number;
  cartSummary: {
    total: number;
    itemCount: number;
    totalQuantity: number;
  };
}

Error Responses

StatusCodeDescription
400VALIDATION_ERRORInvalid quantity
401UNAUTHORIZEDInvalid or expired access token
404CART_ITEM_NOT_FOUNDCart item not found
400INSUFFICIENT_STOCKNot enough stock available
400MAX_QUANTITY_EXCEEDEDMaximum quantity exceeded

Example

Request:

bash
curl -X PATCH https://api.iwm-platform.com/api/v1/cart/items/ci0e8400-e29b-41d4-a716-446655440001 \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "quantity": 3
  }'

Response:

json
{
  "success": true,
  "data": {
    "cartItemId": "ci0e8400-e29b-41d4-a716-446655440001",
    "quantity": 3,
    "unitPrice": 2500,
    "totalPrice": 7500,
    "cartSummary": {
      "total": 9000,
      "itemCount": 1,
      "totalQuantity": 3
    }
  }
}

DELETE /api/v1/cart/items/:id

Remove item from cart.

Authentication: Required

Rate Limit: 100 requests per minute

Request Headers

Authorization: Bearer <access_token>

Path Parameters

ParameterTypeDescription
idstring (UUID)Cart item ID

Request Body

None

Query Parameters

None

Response (200 OK)

typescript
interface RemoveCartItemResponse {
  message: string;
  cartItemId: string;
  cartSummary: {
    total: number;
    itemCount: number;
    totalQuantity: number;
  };
}

Error Responses

StatusCodeDescription
401UNAUTHORIZEDInvalid or expired access token
404CART_ITEM_NOT_FOUNDCart item not found

Example

Request:

bash
curl -X DELETE https://api.iwm-platform.com/api/v1/cart/items/ci0e8400-e29b-41d4-a716-446655440001 \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."

Response:

json
{
  "success": true,
  "data": {
    "message": "Item removed from cart",
    "cartItemId": "ci0e8400-e29b-41d4-a716-446655440001",
    "cartSummary": {
      "total": 0,
      "itemCount": 0,
      "totalQuantity": 0
    }
  }
}

DELETE /api/v1/cart

Clear cart.

Authentication: Required

Rate Limit: 100 requests per minute

Request Headers

Authorization: Bearer <access_token>

Request Body

None

Query Parameters

None

Response (200 OK)

typescript
interface ClearCartResponse {
  message: string;
  itemsRemoved: number;
}

Error Responses

StatusCodeDescription
401UNAUTHORIZEDInvalid or expired access token

Example

Request:

bash
curl -X DELETE https://api.iwm-platform.com/api/v1/cart \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."

Response:

json
{
  "success": true,
  "data": {
    "message": "Cart cleared successfully",
    "itemsRemoved": 3
  }
}

POST /api/v1/cart/checkout

Start checkout process.

Authentication: Required

Rate Limit: 2 requests per minute (financial endpoint)

Request Headers

Authorization: Bearer <access_token>

Request Body

typescript
interface CheckoutRequest {
  shippingAddressId: string;      // Saved address ID
  billingAddressId?: string;      // If different from shipping
  shippingMethodId: string;       // Selected shipping method
  paymentMethod: 'CARD' | 'BANK_TRANSFER' | 'EWALLET' | 'BALANCE';
  couponCodes?: string[];         // Applied coupon codes
  notes?: string;                 // Order notes
  usePartnerBalance?: boolean;    // Use partner balance for payment
}

Query Parameters

None

Response (201 Created)

typescript
interface CheckoutResponse {
  orderId: string;
  orderNumber: string;
  status: 'PENDING_PAYMENT';
  payment: {
    method: string;
    amount: number;
    currency: string;
    // For card payments
    paymentUrl?: string;
    // For bank transfer
    bankDetails?: {
      bankName: string;
      accountNumber: string;
      bik: string;
      purpose: string;
    };
    expiresAt: string;
  };
  summary: {
    subtotal: number;
    discount: number;
    shipping: number;
    tax: number;
    total: number;
  };
  estimatedDelivery: string | null;
}

Error Responses

StatusCodeDescription
400VALIDATION_ERRORInvalid input data
400CART_EMPTYCart is empty
400ITEMS_UNAVAILABLESome items are no longer available
400INSUFFICIENT_STOCKNot enough stock for some items
400INVALID_ADDRESSShipping address is invalid
400INVALID_SHIPPING_METHODShipping method not available
400INVALID_COUPONCoupon code is invalid or expired
401UNAUTHORIZEDInvalid or expired access token
403KYC_REQUIREDKYC verification required for this purchase
429RATE_LIMIT_EXCEEDEDToo many checkout attempts

Example

Request:

bash
curl -X POST https://api.iwm-platform.com/api/v1/cart/checkout \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "shippingAddressId": "aa0e8400-e29b-41d4-a716-446655440000",
    "shippingMethodId": "ship-001",
    "paymentMethod": "CARD",
    "couponCodes": ["WELCOME10"]
  }'

Response:

json
{
  "success": true,
  "data": {
    "orderId": "or0e8400-e29b-41d4-a716-446655440001",
    "orderNumber": "ORD-2024-00001234",
    "status": "PENDING_PAYMENT",
    "payment": {
      "method": "CARD",
      "amount": 8100,
      "currency": "RUB",
      "paymentUrl": "https://payment.iwm-platform.com/pay/abc123",
      "expiresAt": "2024-01-15T22:00:00Z"
    },
    "summary": {
      "subtotal": 7500,
      "discount": 750,
      "shipping": 350,
      "tax": 1000,
      "total": 8100
    },
    "estimatedDelivery": "2024-01-20"
  }
}

Order Endpoints

GET /api/v1/orders

List orders.

Authentication: Required

Rate Limit: 100 requests per minute

Request Headers

Authorization: Bearer <access_token>

Request Body

None

Query Parameters

ParameterTypeDescription
pagenumberPage number (optional)
pageSizenumberItems per page, max 50 (optional)
statusstringFilter by status (optional)
dateFromstringStart date (ISO 8601) (optional)
dateTostringEnd date (ISO 8601) (optional)

Response (200 OK)

typescript
interface OrdersResponse {
  orders: OrderSummary[];
}

interface OrderSummary {
  id: string;
  orderNumber: string;
  status: 'PENDING_PAYMENT' | 'PAID' | 'PROCESSING' | 'SHIPPED' | 'DELIVERED' | 'CANCELLED' | 'REFUNDED';
  paymentStatus: 'PENDING' | 'PAID' | 'FAILED' | 'REFUNDED';
  itemCount: number;
  total: number;
  currency: string;
  createdAt: string;
  updatedAt: string;
}

Error Responses

StatusCodeDescription
400VALIDATION_ERRORInvalid query parameters
401UNAUTHORIZEDInvalid or expired access token

Example

Request:

bash
curl -X GET "https://api.iwm-platform.com/api/v1/orders?status=DELIVERED&page=1&pageSize=10" \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."

Response:

json
{
  "success": true,
  "data": {
    "orders": [
      {
        "id": "or0e8400-e29b-41d4-a716-446655440001",
        "orderNumber": "ORD-2024-00001234",
        "status": "DELIVERED",
        "paymentStatus": "PAID",
        "itemCount": 3,
        "total": 8100,
        "currency": "RUB",
        "createdAt": "2024-01-10T14:00:00Z",
        "updatedAt": "2024-01-15T10:00:00Z"
      }
    ]
  },
  "meta": {
    "pagination": {
      "total": 15,
      "page": 1,
      "pageSize": 10,
      "totalPages": 2,
      "hasNext": true,
      "hasPrevious": false
    }
  }
}

GET /api/v1/orders/:id

Get order details.

Authentication: Required

Rate Limit: 100 requests per minute

Request Headers

Authorization: Bearer <access_token>

Path Parameters

ParameterTypeDescription
idstring (UUID)Order ID

Request Body

None

Query Parameters

None

Response (200 OK)

typescript
interface OrderDetailResponse {
  id: string;
  orderNumber: string;
  status: string;
  paymentStatus: string;
  items: {
    id: string;
    product: {
      id: string;
      name: string;
      sku: string;
      thumbnailUrl: string | null;
    };
    variantId: string | null;
    variantAttributes: Record<string, string> | null;
    quantity: number;
    unitPrice: number;
    totalPrice: number;
  }[];
  pricing: {
    subtotal: number;
    discount: number;
    shipping: number;
    tax: number;
    total: number;
    currency: string;
  };
  shippingAddress: {
    recipientName: string;
    street: string;
    city: string;
    region: string;
    country: string;
    postalCode: string;
    phone: string | null;
  };
  billingAddress: {
    street: string;
    city: string;
    region: string;
    country: string;
    postalCode: string;
  } | null;
  shippingMethod: {
    name: string;
    carrier: string | null;
    estimatedDelivery: string | null;
  };
  payment: {
    method: string;
    transactionId: string | null;
    paidAt: string | null;
  };
  appliedCoupons: {
    code: string;
    discount: number;
  }[];
  notes: string | null;
  statusHistory: {
    status: string;
    changedAt: string;
    note: string | null;
  }[];
  canCancel: boolean;
  canRefund: boolean;
  createdAt: string;
  updatedAt: string;
}

Error Responses

StatusCodeDescription
401UNAUTHORIZEDInvalid or expired access token
404ORDER_NOT_FOUNDOrder not found

Example

Request:

bash
curl -X GET https://api.iwm-platform.com/api/v1/orders/or0e8400-e29b-41d4-a716-446655440001 \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."

Response:

json
{
  "success": true,
  "data": {
    "id": "or0e8400-e29b-41d4-a716-446655440001",
    "orderNumber": "ORD-2024-00001234",
    "status": "DELIVERED",
    "paymentStatus": "PAID",
    "items": [
      {
        "id": "oi0e8400-e29b-41d4-a716-446655440001",
        "product": {
          "id": "pp0e8400-e29b-41d4-a716-446655440001",
          "name": "Premium Health Supplement",
          "sku": "SUP-001",
          "thumbnailUrl": "https://cdn.iwm-platform.com/products/sup-001-thumb.jpg"
        },
        "variantId": null,
        "variantAttributes": null,
        "quantity": 3,
        "unitPrice": 2500,
        "totalPrice": 7500
      }
    ],
    "pricing": {
      "subtotal": 7500,
      "discount": 750,
      "shipping": 350,
      "tax": 1000,
      "total": 8100,
      "currency": "RUB"
    },
    "shippingAddress": {
      "recipientName": "John Doe",
      "street": "Tverskaya 15, apt. 42",
      "city": "Moscow",
      "region": "Moscow Oblast",
      "country": "RU",
      "postalCode": "125009",
      "phone": "+79991234567"
    },
    "billingAddress": null,
    "shippingMethod": {
      "name": "Standard Delivery",
      "carrier": "Russian Post",
      "estimatedDelivery": "2024-01-20"
    },
    "payment": {
      "method": "CARD",
      "transactionId": "TXN-2024011500001",
      "paidAt": "2024-01-10T14:05:00Z"
    },
    "appliedCoupons": [
      {
        "code": "WELCOME10",
        "discount": 750
      }
    ],
    "notes": null,
    "statusHistory": [
      { "status": "PENDING_PAYMENT", "changedAt": "2024-01-10T14:00:00Z", "note": null },
      { "status": "PAID", "changedAt": "2024-01-10T14:05:00Z", "note": "Payment confirmed" },
      { "status": "PROCESSING", "changedAt": "2024-01-11T09:00:00Z", "note": null },
      { "status": "SHIPPED", "changedAt": "2024-01-12T15:00:00Z", "note": "Tracking: RP123456789RU" },
      { "status": "DELIVERED", "changedAt": "2024-01-15T10:00:00Z", "note": null }
    ],
    "canCancel": false,
    "canRefund": true,
    "createdAt": "2024-01-10T14:00:00Z",
    "updatedAt": "2024-01-15T10:00:00Z"
  }
}

GET /api/v1/orders/:id/tracking

Get tracking information.

Authentication: Required

Rate Limit: 100 requests per minute

Request Headers

Authorization: Bearer <access_token>

Path Parameters

ParameterTypeDescription
idstring (UUID)Order ID

Request Body

None

Query Parameters

None

Response (200 OK)

typescript
interface TrackingResponse {
  orderId: string;
  orderNumber: string;
  status: string;
  carrier: string | null;
  trackingNumber: string | null;
  trackingUrl: string | null;
  estimatedDelivery: string | null;
  events: {
    status: string;
    location: string | null;
    description: string;
    timestamp: string;
  }[];
  shippedAt: string | null;
  deliveredAt: string | null;
}

Error Responses

StatusCodeDescription
401UNAUTHORIZEDInvalid or expired access token
404ORDER_NOT_FOUNDOrder not found
400NOT_SHIPPEDOrder has not been shipped yet

Example

Request:

bash
curl -X GET https://api.iwm-platform.com/api/v1/orders/or0e8400-e29b-41d4-a716-446655440001/tracking \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."

Response:

json
{
  "success": true,
  "data": {
    "orderId": "or0e8400-e29b-41d4-a716-446655440001",
    "orderNumber": "ORD-2024-00001234",
    "status": "DELIVERED",
    "carrier": "Russian Post",
    "trackingNumber": "RP123456789RU",
    "trackingUrl": "https://pochta.ru/tracking#RP123456789RU",
    "estimatedDelivery": "2024-01-20",
    "events": [
      {
        "status": "DELIVERED",
        "location": "Moscow",
        "description": "Package delivered",
        "timestamp": "2024-01-15T10:00:00Z"
      },
      {
        "status": "OUT_FOR_DELIVERY",
        "location": "Moscow",
        "description": "Out for delivery",
        "timestamp": "2024-01-15T08:00:00Z"
      },
      {
        "status": "IN_TRANSIT",
        "location": "Moscow Sorting Center",
        "description": "Arrived at sorting center",
        "timestamp": "2024-01-14T16:00:00Z"
      },
      {
        "status": "SHIPPED",
        "location": "Warehouse",
        "description": "Package shipped",
        "timestamp": "2024-01-12T15:00:00Z"
      }
    ],
    "shippedAt": "2024-01-12T15:00:00Z",
    "deliveredAt": "2024-01-15T10:00:00Z"
  }
}

POST /api/v1/orders/:id/cancel

Cancel order.

Authentication: Required

Rate Limit: 100 requests per minute

Request Headers

Authorization: Bearer <access_token>

Path Parameters

ParameterTypeDescription
idstring (UUID)Order ID

Request Body

typescript
interface CancelOrderRequest {
  reason: string;                 // Cancellation reason
}

Query Parameters

None

Response (200 OK)

typescript
interface CancelOrderResponse {
  orderId: string;
  orderNumber: string;
  status: 'CANCELLED';
  refundStatus: 'PENDING' | 'PROCESSING' | 'COMPLETED' | null;
  refundAmount: number | null;
  message: string;
}

Error Responses

StatusCodeDescription
400VALIDATION_ERRORReason not provided
401UNAUTHORIZEDInvalid or expired access token
404ORDER_NOT_FOUNDOrder not found
400CANNOT_CANCELOrder cannot be cancelled (already shipped/delivered)

Example

Request:

bash
curl -X POST https://api.iwm-platform.com/api/v1/orders/or0e8400-e29b-41d4-a716-446655440002/cancel \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "reason": "Changed my mind"
  }'

Response:

json
{
  "success": true,
  "data": {
    "orderId": "or0e8400-e29b-41d4-a716-446655440002",
    "orderNumber": "ORD-2024-00001235",
    "status": "CANCELLED",
    "refundStatus": "PENDING",
    "refundAmount": 5000,
    "message": "Order cancelled successfully. Refund will be processed within 3-5 business days."
  }
}

POST /api/v1/orders/:id/refund

Request refund.

Authentication: Required

Rate Limit: 100 requests per minute

Request Headers

Authorization: Bearer <access_token>

Path Parameters

ParameterTypeDescription
idstring (UUID)Order ID

Request Body

typescript
interface RefundRequest {
  reason: string;                 // Refund reason
  itemIds?: string[];             // Specific item IDs to refund (optional, all if not specified)
  description?: string;           // Additional description
}

Query Parameters

None

Response (201 Created)

typescript
interface RefundResponse {
  refundRequestId: string;
  orderId: string;
  orderNumber: string;
  status: 'PENDING_REVIEW';
  requestedAmount: number;
  items: {
    itemId: string;
    productName: string;
    quantity: number;
    amount: number;
  }[];
  message: string;
  createdAt: string;
}

Error Responses

StatusCodeDescription
400VALIDATION_ERRORInvalid input data
401UNAUTHORIZEDInvalid or expired access token
404ORDER_NOT_FOUNDOrder not found
400CANNOT_REFUNDOrder is not eligible for refund
400REFUND_PERIOD_EXPIREDRefund period has expired
409REFUND_ALREADY_REQUESTEDRefund request already pending

Example

Request:

bash
curl -X POST https://api.iwm-platform.com/api/v1/orders/or0e8400-e29b-41d4-a716-446655440001/refund \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "reason": "Product defective",
    "description": "The supplement bottle cap was damaged on arrival"
  }'

Response:

json
{
  "success": true,
  "data": {
    "refundRequestId": "rf0e8400-e29b-41d4-a716-446655440001",
    "orderId": "or0e8400-e29b-41d4-a716-446655440001",
    "orderNumber": "ORD-2024-00001234",
    "status": "PENDING_REVIEW",
    "requestedAmount": 8100,
    "items": [
      {
        "itemId": "oi0e8400-e29b-41d4-a716-446655440001",
        "productName": "Premium Health Supplement",
        "quantity": 3,
        "amount": 7500
      }
    ],
    "message": "Refund request submitted. You will be notified once reviewed.",
    "createdAt": "2024-01-15T21:00:00Z"
  }
}

Shipping Endpoints

GET /api/v1/shipping/methods

Get available shipping methods.

Authentication: Optional

Rate Limit: 200 requests per minute

Request Headers

Authorization: Bearer <access_token>  (optional)

Request Body

None

Query Parameters

ParameterTypeDescription
countrystringDestination country code (ISO 3166-1 alpha-2)
postalCodestringDestination postal code (optional)
cartIdstringCart ID for accurate calculation (optional)

Response (200 OK)

typescript
interface ShippingMethodsResponse {
  methods: ShippingMethod[];
}

interface ShippingMethod {
  id: string;
  name: string;
  carrier: string;
  description: string | null;
  estimatedDays: {
    min: number;
    max: number;
  };
  price: number;
  currency: string;
  isFree: boolean;
  freeThreshold: number | null;
}

Error Responses

StatusCodeDescription
400VALIDATION_ERRORInvalid country code
400SHIPPING_NOT_AVAILABLENo shipping available to this location

Example

Request:

bash
curl -X GET "https://api.iwm-platform.com/api/v1/shipping/methods?country=RU&postalCode=125009"

Response:

json
{
  "success": true,
  "data": {
    "methods": [
      {
        "id": "ship-001",
        "name": "Standard Delivery",
        "carrier": "Russian Post",
        "description": "Delivered to your nearest post office",
        "estimatedDays": {
          "min": 5,
          "max": 10
        },
        "price": 350,
        "currency": "RUB",
        "isFree": false,
        "freeThreshold": 5000
      },
      {
        "id": "ship-002",
        "name": "Express Delivery",
        "carrier": "CDEK",
        "description": "Fast delivery to your door",
        "estimatedDays": {
          "min": 2,
          "max": 4
        },
        "price": 650,
        "currency": "RUB",
        "isFree": false,
        "freeThreshold": 10000
      }
    ]
  }
}

POST /api/v1/shipping/calculate

Calculate shipping cost.

Authentication: Optional

Rate Limit: 200 requests per minute

Request Headers

Authorization: Bearer <access_token>  (optional)

Request Body

typescript
interface CalculateShippingRequest {
  destination: {
    country: string;              // ISO 3166-1 alpha-2
    region?: string;
    city?: string;
    postalCode: string;
  };
  items: {
    productId: string;
    quantity: number;
    variantId?: string;
  }[];
  // OR
  cartId?: string;                // Use current cart items
}

Query Parameters

None

Response (200 OK)

typescript
interface CalculateShippingResponse {
  destination: {
    country: string;
    postalCode: string;
  };
  package: {
    totalWeight: number;
    dimensions: {
      length: number;
      width: number;
      height: number;
    };
  };
  options: {
    methodId: string;
    name: string;
    carrier: string;
    price: number;
    currency: string;
    estimatedDelivery: {
      min: string;                // ISO 8601 date
      max: string;                // ISO 8601 date
    };
    isFree: boolean;
  }[];
}

Error Responses

StatusCodeDescription
400VALIDATION_ERRORInvalid input data
400INVALID_DESTINATIONCannot ship to this destination
404PRODUCT_NOT_FOUNDOne or more products not found

Example

Request:

bash
curl -X POST https://api.iwm-platform.com/api/v1/shipping/calculate \
  -H "Content-Type: application/json" \
  -d '{
    "destination": {
      "country": "RU",
      "postalCode": "125009"
    },
    "items": [
      {
        "productId": "pp0e8400-e29b-41d4-a716-446655440001",
        "quantity": 3
      }
    ]
  }'

Response:

json
{
  "success": true,
  "data": {
    "destination": {
      "country": "RU",
      "postalCode": "125009"
    },
    "package": {
      "totalWeight": 750,
      "dimensions": {
        "length": 25,
        "width": 15,
        "height": 20
      }
    },
    "options": [
      {
        "methodId": "ship-001",
        "name": "Standard Delivery",
        "carrier": "Russian Post",
        "price": 350,
        "currency": "RUB",
        "estimatedDelivery": {
          "min": "2024-01-20",
          "max": "2024-01-25"
        },
        "isFree": false
      },
      {
        "methodId": "ship-002",
        "name": "Express Delivery",
        "carrier": "CDEK",
        "price": 650,
        "currency": "RUB",
        "estimatedDelivery": {
          "min": "2024-01-17",
          "max": "2024-01-19"
        },
        "isFree": false
      }
    ]
  }
}