# Providers

## List all providers

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

This endpoint allows you to get the list of your providers. \
The providers 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 values is 100. |

#### Headers

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

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

```
{
    "data": [
        {
            "id": 1,
            "code": "1",
            "name": "Provider 1",
            "inactive": 0,
            "creation_date": "2020-07-06",
            "address": "",
            "address2": "",
            "city": "",
            "state": "QC",
            "zipcode": "",
            "phone": "",
            "fax": "",
            "email": "",
            "website": "",
            "term": 0,
            "credit": 0
        },
        {
            "id": 2,
            "code": "2",
            "name": "Provider 2",
            "inactive": 0,
            "creation_date": "2020-07-06",
            "address": "",
            "address2": "",
            "city": "",
            "state": "QC",
            "zipcode": "",
            "phone": "",
            "fax": null,
            "email": null,
            "website": null,
            "term": null,
            "credit": null
        }
    ],
    "meta": {
        "current_page": 1,
        "last_page": 1,
        "per_page": 25,
        "total": 2
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

## Retrieve a provider

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

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

#### Path Parameters

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

#### Headers

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

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

```
{
    "data": {
        "id": 1,
        "code": "1",
        "name": "Provider 1",
        "inactive": 0,
        "creation_date": "2020-07-06",
        "address": "",
        "address2": "",
        "city": "",
        "state": "QC",
        "zipcode": "",
        "phone": "",
        "fax": "",
        "email": "",
        "website": "",
        "term": 0,
        "credit": 0
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

## Create a provider

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

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

#### 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 | Provider code. |
| name | string | Provider name. |

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

```
{
    "data": {
        "id": 1,
        "code": "TEST",
        "name": "Test Provider",
        "inactive": 0,
        "creation_date": "2020-07-06",
        "address": "",
        "address2": "",
        "city": "",
        "state": "QC",
        "zipcode": "",
        "phone": "",
        "fax": "",
        "email": "",
        "website": "",
        "term": 0,
        "credit": 0
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

```
{
    "code": "TEST",
    "name": "Test Provider"
}
```

## Update a provider

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

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

#### Path Parameters

| Name | Type    | Description            |
| ---- | ------- | ---------------------- |
| id   | integer | Provider 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 " %}

```
{
    "data": {
        "id": 1,
        "code": "TEST",
        "name": "Test Provider",
        "inactive": 0,
        "creation_date": "2020-07-06",
        "address": "",
        "address2": "",
        "city": "",
        "state": "QC",
        "zipcode": "",
        "phone": "",
        "fax": "",
        "email": "",
        "website": "",
        "term": 0,
        "credit": 0
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

```
{
    "name": "Test Provider"
}
```


---

# 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/api-reference/resources/providers.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.
