> For the complete documentation index, see [llms.txt](https://en.help.firstline.cc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://en.help.firstline.cc/developer/api/product.md).

# Products

### Product API (`api/product`)

{% hint style="success" %}
&#x20;This API is available for versions v.2.62.11 and later after 2024-10-04.
{% endhint %}

## Search Products

**Request method**: `GET`\
**Endpoint**: `/api/v1/product`\
**Instructions**: Search for a list of products that match the criteria.

**Curl Example**

```bash
curl -X GET \
     -H "Content-Type: application/json" \
     '{
       "name": "phone",
       "sku": "SKU12345",
       "price__lower": 1000,
       "price__upper": 5000,
     }' \
     https://{API_HOST}/api/v1/product
```

**URL Parameters**

| Parameter Name | Type   | Instructions                |
| -------------- | ------ | --------------------------- |
| `name`         | String | Product name keyword search |
| `sku`          | String | Product SKU number          |
| `price__lower` | Number | Minimum price filter        |
| `price__upper` | Number | Maximum price filter        |

**Response Example**

```json
{
    "data": [
        {
            "id": 101,
            "name": "iPhone 15",
            "sku": "SKU12345",
            "description": "The latest iPhone 15 with advanced features.",
            "price": "999.99",
            "stock": 150,
            "category": "Electronics",
            "created_at": "2024-09-01 12:00:00",
            "updated_at": "2024-09-15 08:30:45"
        },
        // More product data...
    ],
    "links": {
        // Pagination related links
    },
    "meta": {
        // Pagination related metadata
    }
}
```

***

## Get Single Product

**Request method**: `GET`\
**Endpoint**: `/api/v1/product/{product_id}`\
**Instructions**: Get detailed information for a single product by product ID.

**Curl Example**

```bash
curl -X GET \
     -H "Content-Type: application/json" \
     https://{API_HOST}/api/v1/product/101
```

**URL Parameters**

| Parameter Name | Type   | Instructions                      |
| -------------- | ------ | --------------------------------- |
| `product_id`   | Number | Unique identifier for the product |

**Response Example**

```json
{
    "data": {
        "id": 101,
        "name": "iPhone 15",
        "sku": "SKU12345",
        "description": "The latest iPhone 15 with advanced features.",
        "price": "999.99",
        "stock": 150,
        "category": "Electronics",
        "created_at": "2024-09-01 12:00:00",
        "updated_at": "2024-09-15 08:30:45"
    }
}
```

***

## Add product

**Request method**: `POST`\
**Endpoint**: `/api/v1/product`\
**Instructions**: Add a new product.

**Curl Example**

```bash
curl -X POST \
     -H "Content-Type: application/json" \
     '{
       "name": "Galaxy S24",
       "sku": "SKU67890",
       "description": "The latest Galaxy S24 with powerful features.",
       "price": 899.99,
       "stock": 200,
       "category": "Electronics"
     }' \
     https://{API_HOST}/api/v1/product
```

**Form Data**

| Field Name    | Type   | Instructions        | Required |
| ------------- | ------ | ------------------- | -------- |
| `name`        | String | Product name        | Yes      |
| `sku`         | String | Product SKU number  | Yes      |
| `description` | String | Product description | No       |
| `price`       | Number | Product price       | Yes      |
| `stock`       | Number | Stock quantity      | Yes      |
| `category`    | String | Product category    | Yes      |

**Response Example**

```json
{
    "data": {
        "id": 102,
        "name": "Galaxy S24",
        "sku": "SKU67890",
        "description": "The latest Galaxy S24 with powerful features.",
        "price": "899.99",
        "stock": 200,
        "category": "Electronics",
        "created_at": "2024-10-04 09:15:30",
        "updated_at": "2024-10-04 09:15:30"
    }
}
```

***

## Update Product

**Request method**: `PUT`\
**Endpoint**: `/api/v1/product/{product_id}`\
**Instructions**: Update the specified product's data.

**Curl Example**

```bash
curl -X PUT \
     -H "Content-Type: application/json" \
     '{
       "price": 949.99,
       "stock": 180
     }' \
     https://{API_HOST}/api/v1/product/101
```

**URL Parameters**

| Parameter Name | Type   | Instructions                      |
| -------------- | ------ | --------------------------------- |
| `product_id`   | Number | Unique identifier for the product |

**Form Data**

| Field Name    | Type   | Instructions        | Required |
| ------------- | ------ | ------------------- | -------- |
| `name`        | String | Product name        | No       |
| `sku`         | String | Product SKU number  | No       |
| `description` | String | Product description | No       |
| `price`       | Number | Product price       | No       |
| `stock`       | Number | Stock quantity      | No       |
| `category`    | String | Product category    | No       |

**Response Example**

```json
{
    "data": {
        "id": 101,
        "name": "iPhone 15",
        "sku": "SKU12345",
        "description": "The latest iPhone 15 with advanced features.",
        "price": "949.99",
        "stock": 180,
        "category": "Electronics",
        "created_at": "2024-09-01 12:00:00",
        "updated_at": "2024-10-04 10:25:50"
    }
}
```

***

#### Product Data Model

The following are the structure and descriptions of product data:

| **Field Name** | **Type** | **Instructions**    |
| -------------- | -------- | ------------------- |
| `id`           | Number   | Product ID          |
| `name`         | String   | Product name        |
| `sku`          | String   | Product SKU number  |
| `description`  | String   | Product description |
| `price`        | Number   | Price               |
| `stock`        | Number   | Stock quantity      |
| `created_at`   | String   | Creation time       |
| `updated_at`   | String   | Updated at          |
