> For the complete documentation index, see [llms.txt](https://doc.commandersact.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.commandersact.com/fr/fonctionnalites/consent-management/rest-data-api/get-put-consents-preferences.md).

# GET/PUT consentements / préférences

Récupérer/mettre à jour le consentement utilisateur stocké dans DataCommander

## Consentements des utilisateurs

<mark style="color:bleu;">`GET`</mark> `https://api.commander1.com/engage/user/`

Ce point de terminaison permet de récupérer le consentement aux catégories d’un utilisateur spécifique.

#### Paramètres de requête

| Nom      | Type    | Description         |
| -------- | ------- | ------------------- |
| token    | string  | Jeton de sécurité   |
| user\_id | string  | ID de l’utilisateur |
| site     | integer | ID du site          |

{% tabs %}
{% tab title="200 Consentement récupéré avec succès." %}

```javascript
{
    "user_privacy_optin": 1,
    "user_privacy_categories": [
      "11",
      "12",
      "13"
    ]
}
```

{% endtab %}

{% tab title="404 Aucun utilisateur correspondant à cette requête n’a été trouvé." %}

```javascript
{
    "message": "Person not found"
}
```

{% endtab %}
{% endtabs %}

## Consentements des visiteurs

<mark style="color:bleu;">`GET`</mark> `https://api.commander1.com/v1.0/engage/visitors/`

Ce point de terminaison permet de récupérer le consentement aux catégories d’un visiteur spécifique.

#### Paramètres de requête

| Nom      | Type    | Description                                  |
| -------- | ------- | -------------------------------------------- |
| callback | string  | (facultatif) Callback pour une requête JSONP |
| token    | string  | Jeton de sécurité                            |
| site     | integer | ID du site                                   |
| tc\_id   | String  | Facultatif. ID du cookie de l’utilisateur    |

{% tabs %}
{% tab title="200 Exemple de réponse avec optin" %}

```javascript
{
    "user_privacy_optin": 1,
    "user_privacy_categories": [
      "11",
      "12",
      "13"
    ]
}
```

{% endtab %}

{% tab title="202 Exemple de réponse avec optout" %}

```
{
    "user_privacy_optin": 0,
    "user_privacy_categories": []
}
```

{% endtab %}

{% tab title="404 " %}

```
{
    "message": "visitor not found"
}
```

{% endtab %}
{% endtabs %}

## Préférences des utilisateurs

<mark style="color:orange;">`PUT`</mark> `https://api.commander1.com/engage/user/`

Insérer ou mettre à jour une préférence dans la base de données (le module DataCommander doit être activé)

#### Paramètres de requête

| Nom      | Type   | Description                                                              |
| -------- | ------ | ------------------------------------------------------------------------ |
| site     | string | ID du site (compte)                                                      |
| user\_id | string | ID de l’utilisateur. Obligatoire si le paramètre tc\_id n’est pas défini |
| token    | string | Jeton de sécurité                                                        |

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

```
{"success":true}
```

{% endtab %}
{% endtabs %}

**Syntaxe et limitations**

* La charge utile JSON est représentée par une paire clé/valeur pour chaque préférence.
* Le nom de chaque propriété de préférence (clé) commence par "preferences." suivi du nom de la préférence : `preferences.your_preference_name`
* Le nom de la préférence ne doit pas contenir d’espace, de point ni de caractère spécial. Son format est `[A-Za-z0-9_-]`
* La valeur de la préférence peut contenir des espaces et des points, mais pas de caractères spéciaux.
* L’API accepte un **maximum de 20 préférences**

**Exemple de requête**

`PUT`

<https://api.commander1.com/engage/user/?site=1234\\&user\\_id=1234\\&token=WvNIX8955cnZ7WF0f632s0Wb99Ql3rtA>

```
{
  "preferences": {
    "news_monthly": true,
    "news_sales": true
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://doc.commandersact.com/fr/fonctionnalites/consent-management/rest-data-api/get-put-consents-preferences.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
