> 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/resources-1.md).

# Campaigns

## List all campaigns

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

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

#### Query Parameters

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

#### Headers

| Name                                             | Type   | Description                   |
| ------------------------------------------------ | ------ | ----------------------------- |
| Authentication<mark style="color:red;">\*</mark> | string | Bearer token.                 |
| Accept<mark style="color:red;">\*</mark>         | string | Should be `application/json`. |

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

```
{
    "data": [
        {
            "id": 19,
            "name": "Votre opinion compte pour nous",
            "active": 1,
            "date_start": "2024-12-01",
            "date_end": "0000-00-00",
            "client_type": "0",
            "client_lead": "",
            "clent_reference": "",
            "client_labels": "",
            "client_needs": "",
            "client_notes": "",
            "has_entreposages": 0,
            "type": "sms",
            "automatic": 1,
            "automatic_type": 2,
            "automatic_value": 1,
            "image": "",
            "subject": "Votre rendez-vous arrive à grand pas  ",
            "content": "<p>Bonjour {client},<br /><br />Votre rendez vous pour le véhicule {car} est prévu pour le {date}.<br />Si vous n'êtes pas dans la possibilité de vous présenter à votre rendez-vous, il serait apprécié de nous appeler afin de nous en informer.</p>",
            "history": [],
            "history_sms": [],
            "system_id": 99598
        },
        {
            "id": 18,
            "name": "",
            "active": 1,
            "date_start": "0000-00-00",
            "date_end": "0000-00-00",
            "client_type": "0",
            "client_lead": "",
            "clent_reference": "",
            "client_labels": "",
            "client_needs": "",
            "client_notes": "",
            "has_entreposages": 0,
            "type": "social_medias",
            "automatic": 1,
            "automatic_type": 1,
            "automatic_value": 0,
            "image": "",
            "subject": "Votre opinion compte pour nous",
            "content": "<p>Bonjour {client},<br /><br />Suite à votre rendez-vous récent, nous aimerions avoir votre opinion sur notre service.<br />S'il est possible pour vous de prendre quelques minutes pour nous écrire sur notre page Google, cela serait grandement apprécié.</p>",
            "history": [
                {
                    "id": 341,
                    "date": "2024-11-08 11:01:13",
                    "subject": "",
                    "from": "noreply@gem-books.com",
                    "to": "nomistim9000@gmail.com",
                    "cc": "",
                    "html": "",
                    "attachement": "0",
                    "clientID": 1,
                    "idmessage": null,
                    "date_read": null,
                    "system_id": 99598
                },
                {
                    "id": 340,
                    "date": "2024-11-08 11:00:58",
                    "subject": "",
                    "from": "noreply@gem-books.com",
                    "to": "koko@gmail.com",
                    "cc": "",
                    "html": "",
                    "attachement": "0",
                    "clientID": 4,
                    "idmessage": null,
                    "date_read": null,
                    "system_id": 99598
                }
            ],
            "history_sms": [],
            "system_id": 99598
        },
```

{% endtab %}
{% endtabs %}

## Retrieve a campaign

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

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

#### Path Parameters

| Name | Type   | Description                        |
| ---- | ------ | ---------------------------------- |
| id   | string | The ID of the campaign to retrieve |

#### Headers

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

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

```
{
    "data": {
        "id": 5,
        "name": "Promotion d'été",
        "active": 1,
        "date_start": "0000-00-00",
        "date_end": "0000-00-00",
        "client_type": "0",
        "client_lead": "",
        "clent_reference": "",
        "client_labels": "",
        "client_needs": "",
        "client_notes": "",
        "has_entreposages": 0,
        "type": "emails",
        "automatic": 1,
        "automatic_type": 1,
        "automatic_value": 0,
        "image": "/3e6cd3f05ff70b01e90dba20caefbb1e/3c265d2c37ffab0e768c4a32b834f202/aquisauto_footer_2.avif",
        "subject": "Votre opinion compte pour nous",
        "content": "<p>Bonjour {client},<br /><br />Suite à votre rendez-vous récent, nous aimerions avoir votre opinion sur notre service.<br />S'il est possible pour vous de prendre quelques minutes pour nous écrire sur notre page Google, cela serait grandement apprécié.</p>",
        "history": [],
        "history_sms": [],
        "system_id": 99598
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

## Create a campaign&#x20;

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

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

#### Headers

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

#### Request Body

| Name | Type   | Description      |
| ---- | ------ | ---------------- |
| code | string | Code of campaign |
| name | string | Name of campaign |

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

```
{
    "data": {
        "name": "Promotion d'hiver",
        "active": 1,
        "date_start": "0000-00-00",
        "date_end": "0000-00-00",
        "client_type": "0",
        "client_lead": "",
        "clent_reference": "",
        "client_labels": "",
        "client_needs": "",
        "client_notes": "",
        "has_entreposages": 0,
        "type": "emails",
        "automatic": 1,
        "automatic_type": 1,
        "automatic_value": 0,
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

## Update a campaign

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

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

#### Path Parameters

| Name | Type   | Description              |
| ---- | ------ | ------------------------ |
| id   | string | ID of campaign to update |

#### Headers

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

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

```
{
    "data": {
        "id": 404,
        "name": "Promotion d'automne",
        "active": 1,
        "date_start": "0000-00-00",
        "date_end": "0000-00-00",
        "client_type": "0",
        "client_lead": "",
        "clent_reference": "",
        "client_labels": "",
        "client_needs": "",
        "client_notes": "",
        "has_entreposages": 0,
        "type": "emails",
        "automatic": 1,
        "automatic_type": 1,
        "automatic_value": 0,
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}
