> For the complete documentation index, see [llms.txt](https://developer.gyfti.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.gyfti.fr/gyfti-api/api-portail.md).

# API Portail

## Portal Users API

Use the Gyfti API to manage portal users and validate challenges.

This API allows you to:

* Update a portal user’s information
* Assign or update the user’s segment
* Add or define points for a user
* Validate a challenge

***

### 1. Update a portail user

Use this endpoint to update the information of an existing portal user.

#### Endpoint

```http
POST https://app.gyfti.fr/api/1.1/wf/edit_user
```

#### Headers

```http
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
```

[Get you API Key from your setting page ](https://app.gyfti.fr/reglages/portail?p=integrations\&tab=api-portail)

#### Request body

```json
{
  "email": "text",
  "first_name": "text",
  "last_name": "text",
  "cagnotte": "number",
  "segment": "text",
  "send_email": "boolean",
  "mode_cagnotte": "text"
}
```

#### Parameters

| Parameter       |    Type | Required | Description                                                                                                                                                |
| --------------- | ------: | :------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `email`         |  string |    Yes   | The email address of the portal user to update.                                                                                                            |
| `first_name`    |  string |    No    | The user’s first name.                                                                                                                                     |
| `last_name`     |  string |    No    | The user’s last name.                                                                                                                                      |
| `cagnotte`      |  number |    No    | The number of points to add or define for the user.                                                                                                        |
| `mode_cagnotte` |  string |    No    | Defines how the `cagnotte` value should be applied.                                                                                                        |
| `segment`       |  string |    No    | The segment name assigned to the user.                                                                                                                     |
| `send_email`    | boolean |    Yes   | Use `true` or `false` to decide whether the user should receive an email informing them they earned new points and inviting them to connect to the portal. |

#### Example request

```bash
curl -X POST https://app.gyfti.fr/api/1.1/wf/edit_user \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "first_name": "John",
    "last_name": "Doe",
    "cagnotte": 100,
    "segment": "VIP",
    "send_email": true,
    "mode_cagnotte": "add"
  }'
```

#### Example response

```json
{
  "message": "Modifications appliquées à l'utilisateur !"
}
```

***

### 2. Validate a challenge

Use this endpoint to validate a challenge for a portal user.

#### Endpoint

```http
POST https://app.gyfti.fr/api/1.1/wf/validate_challenge
```

#### Headers

```http
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
```

#### Request body

```json
{
  "challenges_form": "{challenges_form_id}"
}
```

#### Parameters

| Parameter         |   Type | Required | Description                                                                  |
| ----------------- | -----: | :------: | ---------------------------------------------------------------------------- |
| `challenges_form` | string |    Yes   | The challenge form identifier. You can get this ID by configuring a webhook. |

#### Example request

```bash
curl -X POST https://app.gyfti.fr/api/1.1/wf/validate_challenge \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "challenges_form": "challenges_form_id"
  }'
```

#### Example response

```json
{
  "message": "Challenge validated!"
}
```
