# Products (Admin)

Products are one of the main entities of commerce system. They are the entity which describes exactly what are the collection and tokens that are being sold in your e-commerce.

You can create products that represents one entire collection or even represents one unique and specific token from your collection/contract. If you have one product that contains more than one token, you can also specify different prices depending on the token that you want to sell. See more in [Public Products Page](/w3block-eng/dev-docs/api/commerce-api-services/products.md).

{% hint style="info" %}
Products can have some kind of rules which specify if some user can purchase it or not or even the maximum amount of tokens and the time period that some user can purchase the token. This is specified by [product order rules](/w3block-eng/dev-docs/api/commerce-api-services/company-administration/products-admin/order-rules-admin.md).
{% endhint %}

<details>

<summary>Product Model (Example)</summary>

```json
{
    "id": "6368dfb5-f48c-48b1-be13-dd413548a558",
    "createdAt": "2022-10-17T21:47:12.505Z",
    "updatedAt": "2022-10-17T22:04:00.373Z",
    "companyId": "010e92ea-d3af-40d9-a19e-a263fdfe6e92",
    "name": "Test",
    "description": "block",
    "images": [
        {
            "thumb": "https://dummyimage.com/200x200/fff/000",
            "original": "https://dummyimage.com/600x400/fff/000"
        }
    ],
    "prices": [
        {
            "amount": "1.20",
            "currencyId": "8c43ece8-99b0-4877-aed3-2170d2deb4bf",
            "currency": {
                "id": "8c43ece8-99b0-4877-aed3-2170d2deb4bf",
                "createdAt": "2022-09-02T11:23:53.575Z",
                "updatedAt": "2022-09-02T11:23:53.575Z",
                "name": "USD",
                "crypto": false,
                "symbol": "US$",
                "code": "USD"
            }
        }
    ],
    "distributionType": "random",
    "pricingType": "product",
    "contractAddress": "0x5478a7790e45bb08213b9d7384bf50f65fc0a667",
    "chainId": 80001,
    "startSaleAt": null,
    "endSaleAt": null,
    "status": "published",
    "draftData": {
        "range": "1",
        "quantity": 1,
        "keyCollectionId": "2e90e88b-7263-4cdc-a9dd-b7cdf3df4c91"
    },
    "slug": "string",
    "tags": [],
}
```

</details>

## Service Methods

### Creates a product inside the company

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/products" method="post" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Lists all product of some company

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/products" method="get" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Gets a company product by slug

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/products/get-by-slug/{slug}" method="get" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Gets a company product by id

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/products/{productId}" method="get" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Updates some company product

{% hint style="warning" %}
*You can't update tokens amount or collection from published product tokens. In a near future we are planning to offer that, but for a while, you will need to create a new one.*
{% endhint %}

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/products/{productId}" method="patch" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Publish a company product

Only published products can be purchased because is this endpoint that gets the permission of transfer and all other things about blockchain tokens informations.

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/products/{productId}/publish" method="patch" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://w3block.gitbook.io/w3block-eng/dev-docs/api/commerce-api-services/company-administration/products-admin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
