# Have the agent say something

> POST /v1/conversations/{conversation_id}/say

The agent says `text` on the call, word for word and in its own voice, once it has finished what it is saying. Answers at once with the command. Needs `calls:control`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `conversation_id` | path | string (uuid) | Yes |  |

## Body

Sent as JSON. A field this operation does not take is refused, so a typo fails loudly.

| Field | Type | Required | Description |
|---|---|---|---|
| `text` | string | Yes | Said by the agent, word for word, in its voice. |

## Answer

`202` with [ConversationCommandObject](/reference/objects/ConversationCommandObject).

## Errors

Every error is a [problem document](/errors) with a stable `code`.

| Status | When |
|---|---|
| `401` | The key is missing, mistyped, unknown, revoked or expired. |
| `403` | The key lacks a permission, a live key was sent from a browser, or the organization is frozen and the request would change something. |
| `404` | This key reaches no such conversation. |
| `409` | The call has not been answered, has ended, or is not a call. |
| `422` | Validation Error |
| `429` | Too many requests for this key or its organization; see `Retry-After`. |
| `500` | Something went wrong on our side. Quote the `request_id` to support. |

## Examples

**curl**

```sh
#!/bin/sh
# Have the agent say something
curl -sS --fail-with-body -X POST "https://api.aigently.ai/v1/conversations/5b7d9f1b-3d5f-4b7d-a9f1-b3d5f7b9dbfd/say" \
  -H "Authorization: Bearer $AIGENTLY_API_KEY" \
  --json '{
  "text": "Your table for four is booked for seven this evening."
}'
```

**JavaScript**

```js
// Have the agent say something
const response = await fetch("https://api.aigently.ai/v1/conversations/5b7d9f1b-3d5f-4b7d-a9f1-b3d5f7b9dbfd/say", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.AIGENTLY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "text": "Your table for four is booked for seven this evening."
  }),
});
const answer = await response.json();
if (!response.ok) throw new Error(`${answer.code}: ${answer.detail}`);
console.log(answer);
```

**Python**

```python
# Have the agent say something
# pip install httpx
import os

import httpx

response = httpx.post(
    "https://api.aigently.ai/v1/conversations/5b7d9f1b-3d5f-4b7d-a9f1-b3d5f7b9dbfd/say",
    headers={
        "Authorization": f"Bearer {os.environ['AIGENTLY_API_KEY']}",
    },
    json={
        "text": "Your table for four is booked for seven this evening.",
    },
)
if response.is_error:
    raise SystemExit(response.text)
print(response.json())
```

**Go**

```go
// Have the agent say something
package main

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

func main() {
	payload := []byte(`{
  "text": "Your table for four is booked for seven this evening."
}`)
	request, err := http.NewRequest("POST", "https://api.aigently.ai/v1/conversations/5b7d9f1b-3d5f-4b7d-a9f1-b3d5f7b9dbfd/say", bytes.NewReader(payload))
	if err != nil {
		panic(err)
	}
	request.Header.Set("Authorization", "Bearer "+os.Getenv("AIGENTLY_API_KEY"))
	request.Header.Set("Content-Type", "application/json")
	response, err := http.DefaultClient.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()
	body, _ := io.ReadAll(response.Body)
	if response.StatusCode >= 400 {
		fmt.Fprintln(os.Stderr, string(body))
		os.Exit(1)
	}
	fmt.Println(string(body))
}
```

**Java**

```java
// Have the agent say something
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String body = """
            {
              "text": "Your table for four is booked for seven this evening."
            }
            """;
        HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.aigently.ai/v1/conversations/5b7d9f1b-3d5f-4b7d-a9f1-b3d5f7b9dbfd/say"))
            .header("Authorization", "Bearer " + System.getenv("AIGENTLY_API_KEY"))
            .header("Content-Type", "application/json")
            .method("POST", HttpRequest.BodyPublishers.ofString(body))
            .build();
        // HTTP/1.1: on a plain-http address Java's default asks to upgrade, which not every
        // server allows.
        HttpClient client = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build();
        HttpResponse<String> response =
            client.send(request, HttpResponse.BodyHandlers.ofString());
        if (response.statusCode() >= 400) {
            System.err.println(response.body());
            System.exit(1);
        }
        System.out.println(response.body());
    }
}
```

**C#**

```csharp
// Have the agent say something
using System.Net.Http.Headers;
using System.Text;

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("AIGENTLY_API_KEY"));
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.aigently.ai/v1/conversations/5b7d9f1b-3d5f-4b7d-a9f1-b3d5f7b9dbfd/say")
{
    Content = new StringContent(
        """
        {
          "text": "Your table for four is booked for seven this evening."
        }
        """,
        Encoding.UTF8,
        "application/json"),
};
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
{
    Console.Error.WriteLine(body);
    return 1;
}
Console.WriteLine(body);
return 0;
```

**PHP**

```php
<?php
// Have the agent say something
$curl = curl_init("https://api.aigently.ai/v1/conversations/5b7d9f1b-3d5f-4b7d-a9f1-b3d5f7b9dbfd/say");
curl_setopt_array($curl, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("AIGENTLY_API_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "text" => "Your table for four is booked for seven this evening.",
    ]),
]);
$body = curl_exec($curl);
if (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) >= 400) {
    fwrite(STDERR, $body . "\n");
    exit(1);
}
echo $body, "\n";
```
