# Ajouter un commentaire

> Ajoute un commentaire public à une demande au nom de votre intégration.

`POST /v1/tickets/{number}/comments` (scope: `write`)

Ajoute un commentaire public à une demande au nom de votre intégration. Les agents assignés sont notifiés comme pour toute réponse.

## Paramètres de chemin

| Nom | Type | Description |
| --- | --- | --- |
| `number` **obligatoire** | `string` | Numéro de la demande, par exemple `GM-000123`. |

## Corps de la requête

| Champ | Type | Description |
| --- | --- | --- |
| `body` **obligatoire** | `string` | Texte du commentaire. Texte brut ; les sauts de ligne sont conservés. De 1 à 20000 caractères. |

```json title="Exemple"
{
  "body": "The issue is back after the restart. Attaching the client log."
}
```

## Réponse

`201 Created` · `data`

| Champ | Type | Description |
| --- | --- | --- |
| `author` | `object` | Auteur du commentaire. |
| `author.name` | `string` | Nom dans la langue d’`Accept-Language`. |
| `author.type` | `string` | L’une des valeurs `agent`, `contact`, `integration`. |
| `body` | `string` | Texte du commentaire. |
| `createdAt` | `date-time` | Date de création. |
| `id` | `integer` | Identifiant unique. |

```json title="Exemple"
{
  "data": {
    "id": 512,
    "body": "We replaced the VPN profile. Can you confirm it holds?",
    "author": {
      "type": "agent",
      "name": "Luis Gómez"
    },
    "createdAt": "2026-12-06T15:40:00Z"
  }
}
```

## Erreurs

Toutes les erreurs ont la même forme ; voir [Erreurs](/fr/api/errors/) pour chaque clé.

## Exemples de code

<Tabs syncKey="code">
<TabItem label="cURL">

```sh
curl -X POST 'https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123/comments' \
  -H "Authorization: Bearer $DUTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "body": "The issue is back after the restart. Attaching the client log."
}'
```

</TabItem>
<TabItem label="JavaScript">

```javascript
const response = await fetch('https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123/comments', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.DUTY_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "body": "The issue is back after the restart. Attaching the client log."
  }),
});
const body = await response.json();
if (!response.ok) throw new Error(`${body.error}: ${body.message}`);
console.log(body.data);
```

</TabItem>
<TabItem label="Python">

```python
import os

import requests

response = requests.request(
    "POST",
    "https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123/comments",
    headers={"Authorization": f"Bearer {os.environ['DUTY_API_KEY']}"},
    json={
      "body": "The issue is back after the restart. Attaching the client log."
    },
    timeout=30,
)
response.raise_for_status()
print(response.json()["data"])
```

</TabItem>
<TabItem label="Go">

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	payload := strings.NewReader(`{
  "body": "The issue is back after the restart. Attaching the client log."
}`)
	req, _ := http.NewRequest("POST", "https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123/comments", payload)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("DUTY_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	data, _ := io.ReadAll(res.Body)
	fmt.Println(res.Status, string(data))
}
```

</TabItem>
<TabItem label="PHP">

```php
<?php
$ch = curl_init('https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123/comments');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('DUTY_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => <<<'JSON'
{
  "body": "The issue is back after the restart. Attaching the client log."
}
JSON,
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
echo $status, PHP_EOL, $response;
```

</TabItem>
<TabItem label="C#">

```csharp
using System.Net.Http.Headers;

using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123/comments");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("DUTY_API_KEY"));
request.Content = new StringContent("""
    {
      "body": "The issue is back after the restart. Attaching the client log."
    }
    """, System.Text.Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
```

</TabItem>
<TabItem label="Java">

```java
import java.net.URI;
import java.net.http.*;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123/comments"))
    .header("Authorization", "Bearer " + System.getenv("DUTY_API_KEY"))
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("""
        {
          "body": "The issue is back after the restart. Attaching the client log."
        }
        """))
    .build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
```

</TabItem>
</Tabs>
