# 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 %}


---

# 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://developer.leaderos.net/store/buy.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.
