> 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/api-reference/resources/clients.md).

# Clients

## List all clients

<mark style="color:blue;">`GET`</mark> `https://app.gem-books.com/api/clients`

This endpoint allows you to get the list of your clients. \
The clients are returned sorted by code (A-Z).

#### Query Parameters

| Name      | Type    | Description                                                               |
| --------- | ------- | ------------------------------------------------------------------------- |
| page      | integer | The number of the page you wish to see. Default is 1.                     |
| per\_page | integer | The number of the desired result per page. Default is 20. Maximum is 100. |

#### Headers

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

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

```
{
    "data": [
        {
            "id": 2088,
            "code": "TEST1",
            "name": "TEST1",
            "inactive": 0,
            "creation_date": "2020-08-17",
            "address": "",
            "adresse2": "",
            "city": "",
            "state": "QC",
            "zipcode": "",
            "phone": "",
            "phone2": "",
            "fax": "",
            "email": "",
            "website": "",
            "phone_work": "",
            "credit": "0.00",
            "term": 37,
            "contacts": [
                {
                    "id": 1,
                    "nom": "Contact test",
                    "fonction": "",
                    "departement": "",
                    "email": "",
                    "telephone": "",
                    "cell": "",
                    "fax": ""
                }
            ]
        },
        {
            "id": 2,
            "code": "13559",
            "name": "1TEST2",
            "inactive": 1,
            "creation_date": "2020-07-06",
            "address": "",
            "adresse2": "",
            "city": "",
            "state": "QC",
            "zipcode": "",
            "phone": "",
            "phone2": "",
            "fax": "",
            "email": "",
            "website": "",
            "phone_work": "",
            "credit": "0.00",
            "term": 37,
            "contacts": [
                {
                    "id": 1,
                    "nom": "Contact test",
                    "fonction": "",
                    "departement": "",
                    "email": "",
                    "telephone": "",
                    "cell": "",
                    "fax": ""
                }
            ]
        }
    ],
    "meta": {
        "current_page": 1,
        "last_page": 1,
        "per_page": 25,
        "total": 2
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

## Retrieve a client

<mark style="color:blue;">`GET`</mark> `https://app.gem-books.com/api/clients/:id`

This endpoint allows you to get the details of the client.

#### Path Parameters

| Name | Type    | Description                       |
| ---- | ------- | --------------------------------- |
| id   | integer | The ID of the client to retrieve. |

#### Headers

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

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

```
{
    "data": {
        "id": 2091,
        "code": "TEST11",
        "name": "Test Client",
        "inactive": 0,
        "creation_date": "2020-08-19",
        "address": null,
        "adresse2": null,
        "city": null,
        "state": "QC",
        "zipcode": null,
        "phone": null,
        "phone2": null,
        "fax": null,
        "email": null,
        "website": null,
        "phone_work": null,
        "credit": "0.00",
        "term": 0,
        "contacts": [
                {
                    "id": 1,
                    "nom": "Contact test",
                    "fonction": "",
                    "departement": "",
                    "email": "",
                    "telephone": "",
                    "cell": "",
                    "fax": ""
                }
            ]
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

## Create a client

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

This endpoint allows you to create a client.\
Returns the created client.

#### Headers

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

#### Request Body

| Name | Type   | Description  |
| ---- | ------ | ------------ |
| code | string | Client code. |
| name | string | Client name. |

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

```
{
    "data": {
        "id": 2091,
        "code": "TEST11",
        "name": "Test Client",
        "inactive": 0,
        "creation_date": "2020-08-19",
        "address": null,
        "adresse2": null,
        "city": null,
        "state": "QC",
        "zipcode": null,
        "phone": null,
        "phone2": null,
        "fax": null,
        "email": null,
        "website": null,
        "phone_work": null,
        "credit": "0.00",
        "term": 0,
        "contacts": []
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

```
{
    "code": "TEST11",
    "name": "Test Client",
    "creation_date" : "2020-08-19"
}
```

## Update a client

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

This endpoint allows you to update a specific client. \
Returns the updated client.

#### Path Parameters

| Name | Type    | Description          |
| ---- | ------- | -------------------- |
| id   | integer | Client id to update. |

#### Headers

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

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

```javascript
{
    "data": {
        "id": 2091,
        ...
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

```
{
    "name": "Default client"
}
```
