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

# Update a product

> Updates a product belonging to the authenticated user

## Request Structure

```json expandable
{
  "data": {
    "type": "products",
    "attributes": {
      "description": "Widget A - Large Size",
      "barcode": "5012345678902",
      "shelf_life_min": 60,
      "shelf_life_max": 730
    }
  }
}
```

## Key Fields

| Field                | Required | Description                |
| -------------------- | -------- | -------------------------- |
| `code`               | No       | Updated product SKU        |
| `description`        | No       | Updated description        |
| `barcode`            | No       | Updated barcode            |
| `shelf_life_min/max` | No       | Updated shelf life in days |


## OpenAPI

````yaml openapi.yaml put /product/{id}
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/{id}:
    put:
      tags:
        - Products
      summary: Update a product
      description: Updates a product belonging to the authenticated user
      operationId: updateProduct
      parameters:
        - $ref: '#/components/parameters/idParam'
        - $ref: '#/components/parameters/tokenParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductUpdate'
      responses:
        '200':
          description: Product successfully updated
          headers:
            X-API-Version:
              $ref: '#/components/headers/ApiVersion'
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    idParam:
      name: id
      in: path
      required: true
      description: Resource identifier
      schema:
        type: integer
        example: 12345
    tokenParam:
      name: token
      in: query
      required: true
      description: User authentication token
      schema:
        type: string
        example: YOUR_TOKEN
  schemas:
    ProductUpdate:
      type: object
      required:
        - product
      properties:
        product:
          type: object
          properties:
            title:
              type: string
              maxLength: 255
            description:
              type: string
            rent:
              type: number
              format: float
              minimum: 0.01
            cost:
              type: number
              format: float
              minimum: 0
            stock_type:
              type: integer
              enum:
                - 0
                - 1
            sku:
              type: string
            quantity:
              type: integer
              minimum: 1
            equipments:
              type: array
              maxItems: 50
              items:
                type: object
                required:
                  - name
                  - quantity
                properties:
                  name:
                    type: string
                  quantity:
                    type: integer
                    minimum: 1
            images:
              type: array
              maxItems: 5
              items:
                type: object
                required:
                  - src
                properties:
                  src:
                    type: string
                    format: uri
            online:
              type: boolean
            archived:
              type: boolean
    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
    Forbidden:
      description: Access denied
      headers:
        X-API-Version:
          $ref: '#/components/headers/ApiVersion'
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: Access denied to this resource
    NotFound:
      description: Resource not found
      headers:
        X-API-Version:
          $ref: '#/components/headers/ApiVersion'
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: Resource not found
  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.

````