# Batch Calls

## Insert multiple products

<mark style="color:green;">`POST`</mark> `https://app.gem-books.com/api/RESOURCE_ENDPOINT`

This endpoint allows you to create a batch call for an endpoint.

\*\* Refer to endpoint for body details

#### Notes

* ***Batch calls are supported for all endpoints that accept POST requests.***
* ***The input must be a JSON array of objects.***
* ***Each object in the array is processed independently.***
* ***The order of the results matches the order of the input objects.***
* ***If you send a single object (not an array), the API behaves as usual.***

#### Headers

| Name           | Type   | Description                   |
| -------------- | ------ | ----------------------------- |
| Authentication | string | Bearer token.                 |
| Content-Type   | string | Should be `application/json`. |
| Accept         | string | Should be `application/json`. |

#### Request Body

Example of request body for an endpoint

| Name     | Type   | Description           |
| -------- | ------ | --------------------- |
| code     | string | Product code.         |
| name\_fr | string | Product French name.  |
| name\_en | string | Product English name. |

{% tabs %}
{% tab title="200 " %}

```json
{
    "results": [
        {
            "result": "success",
            "table_id": 22
        },
        {
            "result": "success",
            "table_id": 23
        },
        {
            "result": "success",
            "table_id": 24
        }
    ],
    "success": true
}
```

{% endtab %}
{% endtabs %}

#### Body example

```javascript
[
    {
      "code": "demo",
      "name_fr": "Produit demo",
      "name_en": "Demo Prodcut"
    },
    {
      "code": "005",
      "name_fr": "La Franchise",
      "name_en": "Franchise"
    },
    {
      "code": "006",
      "name_fr": "Autre",
      "name_en": "Other"
    }
]
```

## Update multiple products

<mark style="color:green;">`PUT`</mark> `https://app.gem-books.com/api/RESOURCE_ENDPOINT`

This endpoint allows you to create a batch call for an endpoint.

\*\* Refer to endpoint for body details

#### Notes

* ***Batch calls are supported for all endpoints that accept POST requests.***
* ***The input must be a JSON array of objects and the body must contain the ID for each record.***
* ***Each object in the array is processed independently.***
* ***The order of the results matches the order of the input objects.***
* ***If you send a single object (not an array), the endpoint requires the :id: the API behaves as usual.***

#### Headers

| Name           | Type   | Description                   |
| -------------- | ------ | ----------------------------- |
| Authentication | string | Bearer token.                 |
| Content-Type   | string | Should be `application/json`. |
| Accept         | string | Should be `application/json`. |

#### Request Body

Example of request body for an endpoint

| Name     | Type   | Description           |
| -------- | ------ | --------------------- |
| id       | int    | ID of the record      |
| code     | string | Product code.         |
| name\_fr | string | Product French name.  |
| name\_en | string | Product English name. |

{% tabs %}
{% tab title="200 " %}

```json
{
    "results": {
        "success": [
            {
                "result": "success",
                "table_id": 1
            },
            {
                "result": "success",
                "table_id": 2
            },
            {
                "result": "success",
                "table_id": 3
            }
        ],
        "error": [
            {
                "result":"error",
                "error":"Update failed: Missing ID",
                "data":{
                    "code": "006",
                    "name_fr": "Autre",
                    "name_en": "Other"
                }
            }
        ],
    "success": true
}
```

{% endtab %}
{% endtabs %}

#### Body example

```javascript
[
    {
      "id": "1",    
      "code": "demo",
      "name_fr": "Produit demo",
      "name_en": "Demo Prodcut"
    },
    {
      "id": "2",
      "code": "005",
      "name_fr": "La Franchise",
      "name_en": "Franchise"
    },
    {
      
      "code": "006",
      "name_fr": "Autre",
      "name_en": "Other"
    }
]
```


---

# 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://docs.gem-suite.com/batch-calls.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.
