> 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/`

Cet endpoint vous permet d'obtenir le consentement par catégorie pour un utilisateur spécifique

#### Paramètres de requête

| Nom      | Type   | Description         |
| -------- | ------ | ------------------- |
| token    | chaîne | Jeton de sécurité   |
| user\_id | chaîne | ID de l'utilisateur |
| site     | entier | 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 Impossible de trouver un utilisateur correspondant à cette requête." %}

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

{% endtab %}
{% endtabs %}

## Consentements des visiteurs

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

Cet endpoint vous permet d'obtenir le consentement par catégorie pour un visiteur spécifique

#### Paramètres de requête

| Nom      | Type   | Description                                  |
| -------- | ------ | -------------------------------------------- |
| callback | chaîne | (facultatif) callback pour une requête jsonp |
| token    | chaîne | Jeton de sécurité                            |
| site     | entier | ID du site                                   |
| tc\_id   | Chaîne | Facultatif. ID cookie de l'utilisateur       |

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

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

{% endtab %}

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

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

{% endtab %}

{% tab title="404 " %}

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

{% endtab %}
{% endtabs %}

## Préférences utilisateur

<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 (nécessite d'avoir le module DataCommander activé)

#### Paramètres de requête

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

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

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

{% endtab %}
{% endtabs %}

**Syntaxe et limitations**

* Le payload json est représenté par une paire clé/valeur pour chaque préférence.
* Chaque propriété de préférence (clé) commence par "preferences." suivie 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ères spéciaux. Son format est `[A-Za-z0-9_-]`
* La valeur de la préférence peut contenir des espaces, 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.
