> For the complete documentation index, see [llms.txt](https://developer.leaderos.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.leaderos.net/store/buy.md).

# Buy

## Buy action

<mark style="color:green;">`POST`</mark> `https://yourwebsite.com/api/store/buy`

#### Request Body

| Name                                       | Type  | Description             |
| ------------------------------------------ | ----- | ----------------------- |
| products<mark style="color:red;">\*</mark> | array | An array of product IDs |
| userID<mark style="color:red;">\*</mark>   | int   | User ID                 |

{% tabs %}
{% tab title="201: Created " %}

```json
{
    "status": true,
    "orderID": "123",
    "credits": "10.00",
    "products": [
        {
            "id": 1,
            "quantity": 1,
            "variables": []
        }
    ],
    "cashback": "1.00",
    "total": "10.00",
    "subtotal": "10.00",
    "discount": "0.00"
}
```

{% endtab %}

{% tab title="404: Not Found User not found" %}

```json
{
    "status": false,
    "error": "USER_NOT_FOUND",
    "message": "User not found!"
}
```

{% endtab %}

{% tab title="404: Not Found Product not found" %}

```json
{
    "status": false,
    "error": "PRODUCT_NOT_FOUND",
    "message": "Product not found!"
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid quantity" %}

```json
{
    "status": false,
    "error": "INVALID_QUANTITY",
    "message": "Invalid quantity!"
}
```

{% endtab %}

{% tab title="400: Bad Request Insufficient balance" %}

```json
{
    "status": false,
    "error": "INSUFFICIENT_BALANCE",
    "message": "Insufficient balance!"
}
```

{% endtab %}

{% tab title="400: Bad Request Out of stock" %}

```json
{
    "status": false,
    "error": "OUT_OF_STOCK",
    "message": "Out of stock!"
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid Variable" %}

```json
{
    "status": false,
    "error": "INVALID_VARIABLE",
    "message": "Invalid variable provided for product ID: 1"
}
```

{% endtab %}
{% endtabs %}
