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

# Creating Products

> Step-by-step tutorial for creating products in the Lightyshare API

This tutorial will walk you through creating products in the Lightyshare API, from basic products to complex setups with equipment and images.

## Prerequisites

* Valid API token
* Basic understanding of HTTP requests
* JSON data structure knowledge

## Basic Product Creation

Let's start with a simple camera product:

```bash theme={null}
curl -X POST https://lightyshare.com/api/token-secured/product \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "product": {
      "title": "Canon EOS R5",
      "description": "Professional mirrorless camera with 45MP sensor",
      "rent": 150.0,
      "cost": 3800.0,
      "productType": 0,
      "stock_type": 0,
      "sku": "CANON-R5-001",
      "quantity": 1,
      "online": true
    }
  }'
```

### Response

```json theme={null}
{
  "success": true,
  "id": 12345,
  "location": "/api/token-secured/product/12345"
}
```

## Product with Equipment

Create a camera kit with included accessories:

```bash theme={null}
curl -X POST https://lightyshare.com/api/token-secured/product \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "product": {
      "title": "Sony A7III Kit",
      "description": "Full-frame mirrorless camera with professional accessories",
      "rent": 200.0,
      "cost": 3200.0,
      "productType": 0,
      "stock_type": 0,
      "sku": "SONY-A7III-KIT-001",
      "quantity": 2,
      "equipments": [
        {
          "name": "Camera Body",
          "quantity": 1
        },
        {
          "name": "24-70mm f/2.8 Lens",
          "quantity": 1
        },
        {
          "name": "Battery Pack",
          "quantity": 3
        },
        {
          "name": "64GB Memory Card",
          "quantity": 2
        },
        {
          "name": "Camera Bag",
          "quantity": 1
        },
        {
          "name": "Lens Cleaning Kit",
          "quantity": 1
        }
      ],
      "online": true
    }
  }'
```

## Product with Images

Add high-quality images to showcase your product:

```bash theme={null}
curl -X POST https://lightyshare.com/api/token-secured/product \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "product": {
      "title": "DJI Mavic 3 Pro",
      "description": "Professional drone with 4/3 Hasselblad camera",
      "rent": 300.0,
      "cost": 2200.0,
      "productType": 0,
      "stock_type": 0,
      "sku": "DJI-MAVIC3-001",
      "quantity": 1,
      "equipments": [
        {
          "name": "Drone",
          "quantity": 1
        },
        {
          "name": "Controller",
          "quantity": 1
        },
        {
          "name": "Battery",
          "quantity": 3
        },
        {
          "name": "Propellers",
          "quantity": 8
        },
        {
          "name": "Carrying Case",
          "quantity": 1
        }
      ],
      "images": [
        {
          "src": "https://cdn.example.com/dji-mavic3-front.jpg"
        },
        {
          "src": "https://cdn.example.com/dji-mavic3-side.jpg"
        },
        {
          "src": "https://cdn.example.com/dji-mavic3-controller.jpg"
        },
        {
          "src": "https://cdn.example.com/dji-mavic3-case.jpg"
        }
      ],
      "online": true
    }
  }'
```

## Lighting Equipment

Create a professional lighting setup:

```bash theme={null}
curl -X POST https://lightyshare.com/api/token-secured/product \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "product": {
      "title": "Professional LED Lighting Kit",
      "description": "Complete studio lighting setup with softboxes and stands",
      "rent": 120.0,
      "cost": 800.0,
      "productType": 0,
      "stock_type": 0,
      "sku": "LED-KIT-STUDIO-001",
      "quantity": 3,
      "equipments": [
        {
          "name": "LED Panel 100W",
          "quantity": 2
        },
        {
          "name": "Softbox 60cm",
          "quantity": 2
        },
        {
          "name": "Light Stand",
          "quantity": 2
        },
        {
          "name": "Barn Doors",
          "quantity": 2
        },
        {
          "name": "Gel Set",
          "quantity": 1
        },
        {
          "name": "Carrying Bag",
          "quantity": 1
        }
      ],
      "images": [
        {
          "src": "https://cdn.example.com/led-kit-setup.jpg"
        },
        {
          "src": "https://cdn.example.com/led-kit-packed.jpg"
        }
      ],
      "online": true
    }
  }'
```

## Bulk Product Creation

If you need to create multiple products, use a script:

```javascript theme={null}
const products = [
  {
    title: "Canon 70-200mm f/2.8",
    description: "Professional telephoto zoom lens",
    rent: 80.0,
    cost: 2100.0,
    sku: "CANON-70-200-001",
    quantity: 1
  },
  {
    title: "Manfrotto Tripod",
    description: "Professional carbon fiber tripod",
    rent: 40.0,
    cost: 600.0,
    sku: "MANFROTTO-TRIPOD-001",
    quantity: 2
  },
  {
    title: "Rode NTG5 Shotgun Mic",
    description: "Professional shotgun microphone",
    rent: 35.0,
    cost: 400.0,
    sku: "RODE-NTG5-001",
    quantity: 1
  }
];

async function createProducts(token, products) {
  const results = [];
  
  for (const productData of products) {
    try {
      const response = await fetch('https://lightyshare.com/api/token-secured/product', {
        method: 'POST',
        headers: {
          'Authorization': `Bearer ${token}`,
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          product: {
            ...productData,
            productType: 0,
            stock_type: 0,
            online: true
          }
        })
      });
      
      if (response.ok) {
        const result = await response.json();
        results.push({ success: true, id: result.id, title: productData.title });
      } else {
        results.push({ success: false, title: productData.title, error: response.status });
      }
    } catch (error) {
      results.push({ success: false, title: productData.title, error: error.message });
    }
  }
  
  return results;
}
```

## Common Mistakes to Avoid

### 1. Missing Required Fields

```json theme={null}
// ❌ Missing 'rent' field
{
  "product": {
    "title": "Camera",
    "sku": "CAM-001"
  }
}

// ✅ Correct
{
  "product": {
    "title": "Camera",
    "rent": 100.0,
    "sku": "CAM-001"
  }
}
```

### 2. Invalid SKU for Unit Stock

```json theme={null}
// ❌ Missing SKU for unit stock
{
  "product": {
    "title": "Camera",
    "rent": 100.0,
    "stock_type": 0
  }
}

// ✅ Correct
{
  "product": {
    "title": "Camera",
    "rent": 100.0,
    "stock_type": 0,
    "sku": "CAM-001"
  }
}
```

### 3. Invalid Equipment Structure

```json theme={null}
// ❌ Missing quantity in equipment
{
  "equipments": [
    {
      "name": "Battery"
    }
  ]
}

// ✅ Correct
{
  "equipments": [
    {
      "name": "Battery",
      "quantity": 2
    }
  ]
}
```

## Best Practices

### 1. Descriptive Titles

* Use clear, descriptive titles
* Include brand and model when applicable
* Keep titles under 255 characters

### 2. Detailed Descriptions

* Include key specifications
* Mention included accessories
* Use Markdown formatting for better readability

### 3. Realistic Pricing

* Research market rates
* Consider equipment value and condition
* Factor in maintenance costs

### 4. Quality Images

* Use high-resolution photos
* Show multiple angles
* Include images of accessories

### 5. Accurate Inventory

* Keep SKU numbers unique
* Update quantities regularly
* Mark items as offline when unavailable

## Next Steps

After creating your products, you can:

1. **Update products** to modify details
2. **Create bundles** to group related products
3. **Manage inventory** by updating quantities
4. **Monitor rentals** to track usage

Check out the [Products](/resources/products) and [Bundles](/resources/bundles) documentation for more details.
