# Conversation API

Start, message in, end, and list the history of chat conversation sessions.

Type: reference · Mode: develop · Status: unverified

---
The Conversation API manages real-time chat conversations with users, starting a chat
session, sending messages, ending the session, and retrieving conversation history. This
is commonly used for customer-support chat scenarios.

See [REST API reference](/reference/rest-api/) for the base URL and authentication header
every request below needs.

## POST /v1/conversation/startSession

**Start Conversation Session:** initiate a new chat conversation session with a user.

**Request body:**

<div class="sym-spec-table">

| Field | Type | Need | Notes |
| --- | --- | --- | --- |
| `targetSymphonaAgentID` | string (UUID) | Required | The Agent the user will interact with. |
| `channelType` | string | Optional | Channel type (only `Web Chat` is supported). |
| `channelName` | string | Optional | Name given to this conversation instance. |
| `userFirstName` | string | Optional | The user's first name. |
| `userLastName` | string | Optional | The user's last name. |
| `userID` | string | Optional | The ID of the user having the conversation. |
| `userEmail` | array of strings | Optional | The user's email address(es). |
| `userPhone` | array of strings | Optional | The user's phone number(s). |

</div>

**Example request:**

```
curl --location 'https://app.symphona.ai/dashboard/api/v1/conversation/startSession' \
--header 'apiKey: xxxxxx' \
--header 'Content-Type: application/json' \
--data '{
  "channelType": "Web Chat",
  "channelName": "Test",
  "targetSymphonaAgentID": "0201f741-cdeb-45c9-a12e-7bf33dcb7b35",
  "userID": "user111"
}'
```

**Sample response (200 OK):**

```json
{
  "conversationSessionID": "609c655b-48a3-49fb-94be-7a2d8d2b616a",
  "message": "Hello! How can I assist you today?"
}
```

## POST /v1/conversation/sendMessage

**Send Message:** send a message within an ongoing conversation session. Either the user
or the Agent side can call this to add a message to the chat.

Request body (all fields required):

<div class="sym-spec-table">

| Field | Type | Notes |
| --- | --- | --- |
| `conversationSessionID` | string | The session ID returned by `startSession`. |
| `message` | string | The message to send. |

</div>

**Example request:**

```
curl --location 'https://app.symphona.ai/dashboard/api/v1/conversation/sendMessage' \
--header 'apiKey: xxxxxx' \
--header 'Content-Type: application/json' \
--data '{
  "conversationSessionID": "609c655b-48a3-49fb-94be-7a2d8d2b616a",
  "message": "How are you doing today?"
}'
```

**Sample response (200 OK):**

```json
{
  "response": "I'm doing well, thank you! How can I assist you today?"
}
```

## POST /v1/conversation/endSession

**End Conversation Session:** terminate an active conversation session, indicating the
chat has concluded (resolved or otherwise ended).

Request body (required):

<div class="sym-spec-table">

| Field | Type | Notes |
| --- | --- | --- |
| `conversationSessionID` | string | The session ID to end. |

</div>

**Example request:**

```
curl --location 'https://app.symphona.ai/dashboard/api/v1/conversation/endSession' \
--header 'apiKey: xxxxxx' \
--header 'Content-Type: application/json' \
--data '{
  "conversationSessionID": "609c655b-48a3-49fb-94be-7a2d8d2b616a"
}'
```

**Sample response:** `200 OK` with no body means the conversation ended.

## GET /v1/conversation/history

**Get Conversation History:** retrieve a list of closed conversation sessions, for
example past chats that may need follow-up or review.

Query parameters (none mandatory)

<div class="sym-spec-table">

| Parameter | Type | Default | Notes |
| --- | --- | --- | --- |
| `sortOrder` | string | `firstClosed` | How the list is sorted. |
| `isAscending` | string | `true` | Sort direction. |
| `pageNumber` | int32 | `0` | Page of results to return. |
| `pageSize` | int32 | `25` | Number of results per page. |

</div>

**Example request:**

```
curl --location 'https://app.symphona.ai/dashboard/api/v1/conversation/history?pageNumber=0' \
--header 'apiKey: xxxxxx'
```

**Sample response (200 OK):**

```json
{
  "content": [],
  "number": 0,
  "size": 25,
  "totalElements": 0,
  "last": true,
  "first": true,
  "numberOfElements": 0,
  "totalPages": 0,
  "hasContent": false
}
```