> For the complete documentation index, see [llms.txt](https://docs.gem-suite.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gem-suite.com/batch-calls.md).

# 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"
    }
]
```
