> ## 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.

# Products

> Learn how to create, update, and manage products in the Lightyshare API

Products are the core resources in Lightyshare that represent items available for rental. Each product can be a single item or a bundle of multiple items.

## Product Types

### Individual Products (productType: 0)

Single items that can be rented individually, such as cameras, lenses, or lighting equipment.

### Bundles (productType: 1)

Collections of multiple products that are rented together as a package.

## Stock Management

### Unit Stock (stock\_type: 0)

Products with individual unit tracking. Each unit has a unique SKU and can be tracked separately.

**Required fields:**

* `sku`: Unique identifier for the product unit
* `quantity`: Number of units available

### Without Unit Management (stock\_type: 1)

Products without individual unit tracking. Only the total quantity is managed.

## Creating a Product

### Basic Product Creation

```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": "4K Pro Camera",
      "description": "Professional camera with full frame sensor",
      "rent": 250.0,
      "cost": 3500.0,
      "productType": 0,
      "stock_type": 0,
      "sku": "CAM-4K-001",
      "quantity": 2,
      "online": true
    }
  }'
```

### Product with Equipment

```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": "Complete Camera Kit",
      "description": "Professional camera with accessories",
      "rent": 300.0,
      "cost": 4500.0,
      "productType": 0,
      "stock_type": 0,
      "sku": "KIT-CAM-001",
      "quantity": 1,
      "equipments": [
        {
          "name": "Battery",
          "quantity": 4
        },
        {
          "name": "Memory Card",
          "quantity": 2
        },
        {
          "name": "Lens Cap",
          "quantity": 1
        }
      ],
      "images": [
        {
          "src": "https://cdn.example.com/camera-front.jpg"
        },
        {
          "src": "https://cdn.example.com/camera-back.jpg"
        }
      ],
      "online": true
    }
  }'
```

## Updating a Product

### Partial Update

```bash theme={null}
curl -X PUT https://lightyshare.com/api/token-secured/product/12345 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "product": {
      "rent": 275.0,
      "quantity": 3,
      "online": false
    }
  }'
```

## Product Fields

### Required Fields

| Field   | Type   | Description                   | Example         |
| ------- | ------ | ----------------------------- | --------------- |
| `title` | string | Product title (max 255 chars) | "4K Pro Camera" |
| `rent`  | float  | Rental price (min 0.01)       | 250.0           |

### Optional Fields

| Field         | Type    | Description                         | Example                  |
| ------------- | ------- | ----------------------------------- | ------------------------ |
| `description` | string  | Product description (Markdown/HTML) | "Professional camera..." |
| `cost`        | float   | Product cost (min 0)                | 3500.0                   |
| `productType` | integer | 0=product, 1=bundle                 | 0                        |
| `stock_type`  | integer | 0=unit stock, 1=no unit management  | 0                        |
| `sku`         | string  | Required if stock\_type=0           | "CAM-4K-001"             |
| `quantity`    | integer | Number of units (min 1)             | 2                        |
| `equipments`  | array   | List of included equipment          | See example above        |
| `images`      | array   | Product images (max 5)              | See example above        |
| `online`      | boolean | Available for rental                | true                     |
| `archived`    | boolean | Archived product                    | false                    |

## Equipment Items

Each equipment item requires:

```json theme={null}
{
  "name": "Equipment name",
  "quantity": 1
}
```

## Image Requirements

Each image requires:

```json theme={null}
{
  "src": "https://cdn.example.com/image.jpg"
}
```

* Maximum 5 images per product
* Images must be accessible URLs
* Recommended format: WEBP, JPG, PNG
* Recommended size: 1200x800 pixels

## Response Examples

### Successful Creation

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

### Successful Update

```json theme={null}
{
  "success": true
}
```

## Error Handling

### Validation Errors

```json theme={null}
{
  "success": false,
  "errors": [
    {
      "field": "sku",
      "code": "REQUIRED",
      "message": "SKU is required for unit stock"
    }
  ]
}
```

### Common Error Codes

* `REQUIRED`: Missing required field
* `INVALID_FORMAT`: Invalid data format
* `MIN_VALUE`: Value below minimum
* `MAX_LENGTH`: String exceeds maximum length
