> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spn.wtf/llms.txt
> Use this file to discover all available pages before exploring further.

# Catalog API

> Product catalog management

# Catalog API

Manage product catalog with bulk upload and WhatsApp XML feed.

## Endpoints

| Method | Path                             | Description       |
| ------ | -------------------------------- | ----------------- |
| GET    | `/catalog`                       | List products     |
| GET    | `/catalog/{id}`                  | Get product       |
| POST   | `/catalog`                       | Create product    |
| PATCH  | `/catalog/{id}`                  | Update product    |
| DELETE | `/catalog/{id}`                  | Delete product    |
| POST   | `/catalog/bulk`                  | Bulk upload       |
| GET    | `/catalog/feed/{company_id}.xml` | WhatsApp XML feed |

## List Products

```bash theme={null}
GET /catalog
```

### Query Parameters

| Parameter   | Type   | Description        |
| ----------- | ------ | ------------------ |
| page        | int    | Page number        |
| limit       | int    | Items per page     |
| category    | string | Filter by category |
| company\_id | uuid   | Filter by company  |
| search      | string | Search products    |

## Create Product

```bash theme={null}
POST /catalog
```

### Request Body

```json theme={null}
{
  "name": "Gold Ring",
  "description": "22K gold ring",
  "category": "Jewelry",
  "sub_category": "Rings",
  "price_amount": 50000,
  "price_currency": "INR",
  "moq": 1,
  "_country": "India",
  "images": ["originhttps://..."]
}
```

### Fields

| Field             | Type    | Description                        |
| ----------------- | ------- | ---------------------------------- |
| name              | string  | Product name                       |
| description       | string  | Product description                |
| category          | string  | Category                           |
| sub\_category     | string  | Sub-category                       |
| price\_amount     | integer | Price in paise                     |
| price\_currency   | string  | Currency code                      |
| moq               | integer | Minimum order quantity             |
| origin\_country   | string  | Country of origin                  |
| importer\_name    | string  | Importer name (for imported goods) |
| importer\_address | string  | Importer address                   |

## Bulk Upload

Upload multiple products via CSV or Excel.

```bash theme={null}
POST /catalog/bulk
```

### Request

* Content-Type: `multipart/form-data`
* File: CSV or Excel file

### Response

```json theme={null}
{
  "success": true,
  "created": 50,
  "failed": 2,
  "errors": [
    {"row": 5, "error": "Invalid price format"}
  ]
}
```

## WhatsApp XML Feed

Generate XML feed for Meta Commerce Manager.

```bash theme={null}
GET /catalog/feed/{company_id}.xml
```

### Example

```bash theme={null}
curl http://localhost:8000/api/v1/catalog/feed/company-uuid.xml
```

### Output

```xml theme={null}
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
  <product>
    <id>prod-001</id>
    <name>Gold Ring</name>
    <description>22K gold ring</description>
    <price>500.00</price>
    <currency>INR</currency>
    <image>https://...</image>
    <availability>in stock</availability>
  </product>
</catalog>
```

### WhatsApp Setup

1. Generate XML feed URL
2. Go to Meta Commerce Manager
3. Add catalog → Connect via feed
4. Configure hourly sync

## Rate Limits

| Endpoint      | Limit   |
| ------------- | ------- |
| List/Search   | 120/min |
| Create/Update | 120/min |
| Bulk Upload   | 10/min  |
