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

# Create a product

> Creates a new product for the authenticated user

## Request Structure

```json expandable
{
  "data": {
    "type": "products",
    "attributes": {
      "code": "SKU-001",
      "description": "Widget A - Standard Size",
      "stock_unit_type_id": 1,
      "barcode": "5012345678901",
      "commodity_code": "84719000",
      "country_of_manufacture": "GB",
      "shelf_life_min": 30,
      "shelf_life_max": 365
    }
  }
}
```

## Key Fields

| Field                | Required | Description                |
| -------------------- | -------- | -------------------------- |
| `code`               | No       | Unique product SKU code    |
| `description`        | Yes      | Short product description  |
| `stock_unit_type_id` | Yes      | Unit of measure type ID    |
| `barcode`            | No       | Primary product barcode    |
| `commodity_code`     | No       | HS code for customs        |
| `shelf_life_min`     | No       | Minimum shelf life in days |
| `shelf_life_max`     | No       | Maximum shelf life in days |


## OpenAPI

````yaml openapi.yaml post /product
openapi: 3.0.3
info:
  title: Lightyshare API
  description: >
    API for client access/integrations via user token.


    ## Versioning


    Inspired by Stripe's versioning strategy, we use date-based versioning to
    maintain backwards compatibility.


    ### Version Format

    API versions use the format `YYYY-MM-DD` (e.g., `2025-08-16`).


    ### How Versioning Works


    1. **Token-based versioning**: When you create an API token, it's
    automatically tied to the latest API version available at that time

    2. **Request-level override**: You can override the token's version for
    specific requests using the `lighty-version` header

    3. **Stable URLs**: API URLs remain stable - version is handled
    transparently via token or header


    ### Examples


    ```bash

    # Using token's default version (2025-08-16 in this example)

    curl -H "Authorization: Bearer lsh_live_abc123..." \
         https://lightyshare.com/api/token-secured/rental/123

    # Override with header to use a different version

    curl -H "Authorization: Bearer lsh_live_abc123..." \
         -H "lighty-version: 2025-01-15" \
         https://lightyshare.com/api/token-secured/rental/123
    ```


    The API version used is always returned in the `X-API-Version` response
    header.
  version: 0.1.0
  contact:
    name: Support Lightyshare
    url: https://support.lightyshare.com
servers:
  - url: https://lightyshare.com/api/token-secured
    description: Stable API endpoint (version handled via token/header)
security:
  - tokenAuth: []
paths:
  /product:
    post:
      tags:
        - Products
      summary: Create a product
      description: Creates a new product for the authenticated user
      operationId: createProduct
      parameters:
        - $ref: '#/components/parameters/tokenParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductCreate'
      responses:
        '201':
          description: Product successfully created
          headers:
            X-API-Version:
              $ref: '#/components/headers/ApiVersion'
            Location:
              schema:
                type: string
                example: /api/v1/token-secured/product/14567
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  id:
                    type: integer
                    example: 14567
                  location:
                    type: string
                    example: /api/token-secured/product/14567
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  parameters:
    tokenParam:
      name: token
      in: query
      required: true
      description: User authentication token
      schema:
        type: string
        example: YOUR_TOKEN
  schemas:
    ProductCreate:
      type: object
      required:
        - product
      properties:
        product:
          type: object
          required:
            - title
            - rent
          properties:
            title:
              type: string
              maxLength: 255
              example: 4K Pro Camera
            description:
              type: string
              description: Description in Markdown or HTML
              example: Professional camera with full frame sensor
            rent:
              type: number
              format: float
              minimum: 0.01
              example: 250
            cost:
              type: number
              format: float
              minimum: 0
              example: 3500
            productType:
              type: integer
              enum:
                - 0
                - 1
              default: 0
              description: 0 = product, 1 = bundle
            stock_type:
              type: integer
              enum:
                - 0
                - 1
              default: 0
              description: 0 = unit stock, 1 = without unit management
            sku:
              type: string
              description: Required if stock_type = 0
              example: CAM-4K-001
            quantity:
              type: integer
              minimum: 1
              default: 1
              example: 2
            equipments:
              type: array
              maxItems: 50
              items:
                type: object
                required:
                  - name
                  - quantity
                properties:
                  name:
                    type: string
                    example: Battery
                  quantity:
                    type: integer
                    minimum: 1
                    example: 4
            images:
              type: array
              maxItems: 5
              items:
                type: object
                required:
                  - src
                properties:
                  src:
                    type: string
                    format: uri
                    example: https://cdn.example.com/camera-front.jpg
            online:
              type: boolean
              default: true
            archived:
              type: boolean
              default: false
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        errors:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
                example: sku
              code:
                type: string
                example: REQUIRED
              message:
                type: string
                example: SKU is required for unit stock
  headers:
    ApiVersion:
      description: API version in YYYY-MM-DD format
      schema:
        type: string
        example: '2025-08-16'
  responses:
    BadRequest:
      description: Invalid request
      headers:
        X-API-Version:
          $ref: '#/components/headers/ApiVersion'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing or invalid token
      headers:
        X-API-Version:
          $ref: '#/components/headers/ApiVersion'
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: Invalid or missing token
    TooManyRequests:
      description: Too many requests
      headers:
        X-API-Version:
          $ref: '#/components/headers/ApiVersion'
        Retry-After:
          description: Number of seconds before retry is allowed
          schema:
            type: integer
            example: 60
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: Request limit exceeded
  securitySchemes:
    tokenAuth:
      type: http
      scheme: bearer
      bearerFormat: token
      description: >
        Use your API token in the Authorization header with Bearer scheme.

        Alternative: You can also pass the token as a query parameter
        `?token=your_token` for backward compatibility.

````